From 6e72c166ddd424d61c465ac501f3e76c1f5e3112 Mon Sep 17 00:00:00 2001 From: slwatkins Date: Wed, 17 Jul 2024 15:26:00 -0600 Subject: [PATCH 1/2] update convert_li_to_h5 to be compatible with large LI files --- src/splendaq/io/_io.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/splendaq/io/_io.py b/src/splendaq/io/_io.py index 811c406..d36b6c1 100644 --- a/src/splendaq/io/_io.py +++ b/src/splendaq/io/_io.py @@ -235,6 +235,7 @@ def convert_li_to_h5(li_file, my_os): """ Converting a LI file to a splendaq HDF5 file. + Parameters ---------- li_file : str @@ -247,9 +248,16 @@ def convert_li_to_h5(li_file, my_os): """ convert_li(li_file, my_os, filetype='mat') - mat_filename = Path(li_file).with_suffix('.mat') - mat_file = loadmat(mat_filename, simplify_cells=True)['moku'] - os.remove(mat_filename) + mat_filenames = sorted( + Path('.').glob(f"{Path(li_file).with_suffix('')}*.mat") + ) + mat_files = [] + for ff in mat_filenames: + mat_files.append(loadmat(ff, simplify_cells=True)['moku']) + os.remove(ff) + + # get metadata from the first file + mat_file = mat_files[0] comment_str = mat_file['comment'] comment = list( @@ -270,7 +278,7 @@ def convert_li_to_h5(li_file, my_os): s for s in comment if kw_fs in s ][0][len(kw_fs):].split('Hz')[0]) - arr = mat_file['data'] + arr = np.vstack([m['data'] for m in mat_files]) columns = mat_file['legend'] new_filename = Path(li_file).with_suffix('.h5') @@ -293,4 +301,3 @@ def convert_li_to_h5(li_file, my_os): parentseriesnumber=[seriesnumber] * datashape[0], parenteventnumber=np.arange(datashape[0]), ) - From fa4965e191421441182244359eeeb8c770821a04 Mon Sep 17 00:00:00 2001 From: Samuel Watkins <35979561+slwatkins@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:31:53 -0600 Subject: [PATCH 2/2] remove added white space --- src/splendaq/io/_io.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/splendaq/io/_io.py b/src/splendaq/io/_io.py index d36b6c1..8ca92f8 100644 --- a/src/splendaq/io/_io.py +++ b/src/splendaq/io/_io.py @@ -235,7 +235,6 @@ def convert_li_to_h5(li_file, my_os): """ Converting a LI file to a splendaq HDF5 file. - Parameters ---------- li_file : str