Skip to content

Commit 8306ed1

Browse files
committed
Convert variables to lists and check for lists in functions.
1 parent f4c2dd2 commit 8306ed1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

heudiconv/convert.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ def update_multiecho_name(metadata, filename, echo_times):
319319
if any(ut in filename for ut in unsupported_types):
320320
return filename
321321

322+
assert isinstance(echo_times, list), 'Argument "echo_times" must be a list.'
323+
322324
# Get the EchoNumber from json file info. If not present, use EchoTime
323325
if 'EchoNumber' in metadata.keys():
324326
echo_number = metadata['EchoNumber']
@@ -364,6 +366,8 @@ def update_uncombined_name(metadata, filename, channel_names):
364366
if any(ut in filename for ut in unsupported_types):
365367
return filename
366368

369+
assert isinstance(channel_names, list), 'Argument "channel_names" must be a list.'
370+
367371
# Determine the channel number
368372
channel_number = ''.join([c for c in metadata['CoilString'] if c.isdigit()])
369373
if not channel_number:
@@ -696,6 +700,8 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
696700
is_multiecho = len(set(filter(bool, echo_times))) > 1 # Check for varying echo times
697701
is_uncombined = len(set(filter(bool, channel_names))) > 1 # Check for uncombined data
698702
is_complex = 'M' in image_types and 'P' in image_types # Determine if data are complex (magnitude + phase)
703+
echo_times = sorted(echo_times) # also converts to list
704+
channel_names = sorted(channel_names) # also converts to list
699705

700706
### Loop through the bids_files, set the output name and save files
701707
for fl, suffix, bids_file, bids_meta in zip(res_files, suffixes, bids_files, bids_metas):

0 commit comments

Comments
 (0)