Skip to content

Commit e4fb1b9

Browse files
author
Dan Levitas
committed
[FIX] Address MEG issue with .ds format
1 parent 804d196 commit e4fb1b9

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

handler/ezBIDS_core/ezBIDS_core.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,9 @@ def fix_multiple_dots(uploaded_img_list):
314314
fix = True
315315
ext = '.json'
316316
elif img_file.endswith(tuple(MEG_extensions)) and img_file.count('.') > 1: # for MEG
317-
fix = True
318-
ext = img_file.split('.')[-1]
317+
if not img_file.endswith('.ds'):
318+
fix = True
319+
ext = '.' + img_file.split('.')[-1]
319320
else:
320321
pass
321322

@@ -385,10 +386,13 @@ def generate_MEG_json_sidecars(uploaded_img_list):
385386
from mne_bids.config import MANUFACTURERS
386387

387388
for meg in MEG_img_files:
388-
ext = Path(meg).suffix
389+
if meg.endswith('.ds'):
390+
ext = '.ds'
391+
else:
392+
ext = Path(meg).suffix
389393

390394
fname = f"{DATA_DIR}/{meg}"
391-
json_output_name = fname.split(".")[0] + ".json"
395+
json_output_name = fname.split(ext)[0] + ".json"
392396
raw = mne.io.read_raw(fname, verbose=0)
393397
acquisition_date_time = raw.info["meas_date"].strftime("%Y-%m-%dT%H:%M:%S.%f")
394398
acquisition_date = acquisition_date_time.split("T")[0]
@@ -481,6 +485,8 @@ def modify_uploaded_dataset_list(uploaded_img_list):
481485
ext = '.nii.gz'
482486
elif img_file.endswith('.v.gz'):
483487
ext = '.v.gz'
488+
elif img_file.endswith('.ds'):
489+
ext = '.ds'
484490
else:
485491
ext = Path(img_file).suffix
486492

@@ -918,6 +924,8 @@ def generate_dataset_list(uploaded_files_list, exclude_data):
918924
ext = '.nii.gz'
919925
elif img_file.endswith('.v.gz'):
920926
ext = '.v.gz'
927+
elif img_file.endswith('.ds'):
928+
ext = '.ds'
921929
else:
922930
ext = Path(img_file).suffix
923931

@@ -2931,7 +2939,10 @@ def modify_objects_info(dataset_list):
29312939
"pngPaths": [],
29322940
"headers": protocol["headers"]})
29332941
elif item.endswith(tuple(MEG_extensions)):
2934-
name = Path(item).suffix
2942+
if item.endswith('.ds'):
2943+
name = '.ds'
2944+
else:
2945+
name = Path(item).suffix
29352946
items.append({"path": item,
29362947
"name": name,
29372948
"pngPaths": [],
@@ -3028,7 +3039,6 @@ def extract_series_info(dataset_list_unique_series):
30283039
uploaded_img_list = fix_multiple_dots(uploaded_img_list)
30293040

30303041
# Generate MEG json files, if MEG data was provided
3031-
# uploaded_img_list = generate_MEG_json_sidecars(uploaded_img_list)
30323042
generate_MEG_json_sidecars(uploaded_img_list)
30333043

30343044
# Filter uploaded files list for files that ezBIDS can't use and check for ezBIDS configuration file

handler/find_img_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def find_img_data(dir):
9696
find_cmd = os.popen(f"find . -maxdepth 9 -type {type_search} -name '{meg_ext}'").read()
9797
if find_cmd != '':
9898
meg_data_list.append(find_cmd)
99+
99100
if len(meg_data_list):
100-
meg_data_list = [x for x in meg_data_list[0].split('\n') if x != '']
101+
# TODO - won't this remove different extensions?
102+
meg_data_list = [x for x in meg_data_list[0].split('\n') if x != '' and 'hz.ds' not in x]
101103

102104
# Save the MRI, PET, MEG, and NIfTI lists (if they exist) to separate files
103105
file = open(f'{root}/dcm2niix.list', 'w')

0 commit comments

Comments
 (0)