Skip to content

Commit 70585e9

Browse files
authored
Merge pull request #719 from nipreps/fix/me-multi-t1w
FIX: Account for potential lists of lists in multi-echo cases
2 parents aac2625 + 8b6851b commit 70585e9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

niworkflows/utils/misc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,20 @@ def fix_multi_T1w_source_name(in_files):
107107
... '/path/to/sub-045_ses-retest_T1w.nii.gz'])
108108
'/path/to/sub-045_T1w.nii.gz'
109109
110+
111+
>>> fix_multi_T1w_source_name([
112+
... ('/path/to/sub-045-echo-1_T1w.nii.gz', 'path/to/sub-045-echo-2_T1w.nii.gz')])
113+
'/path/to/sub-045_T1w.nii.gz'
114+
110115
"""
111116
import os
112117
from nipype.utils.filemanip import filename_to_list
113118

114-
base, in_file = os.path.split(filename_to_list(in_files)[0])
119+
in_file = filename_to_list(in_files)[0]
120+
if isinstance(in_file, (list, tuple)):
121+
in_file = in_file[0]
122+
123+
base, in_file = os.path.split(in_file)
115124
subject_label = in_file.split("_", 1)[0].split("-")[1]
116125
return os.path.join(base, "sub-%s_T1w.nii.gz" % subject_label)
117126

0 commit comments

Comments
 (0)