Skip to content

Commit aaf199e

Browse files
tsaloyarikoptic
authored andcommitted
Change part back to rec.
And mag back to magnitude.
1 parent 85189f1 commit aaf199e

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

heudiconv/convert.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,47 +235,52 @@ def prep_conversion(sid, dicoms, outdir, heuristic, converter, anon_sid,
235235

236236
def update_complex_name(fileinfo, this_prefix_basename, suffix):
237237
"""
238-
Insert `_part-<mag|phase>` entity into filename if data are from a sequence
238+
Insert `_rec-<magnitude|phase>` entity into filename if data are from a sequence
239239
with magnitude/phase reconstruction.
240240
"""
241+
# Functional scans separate magnitude/phase differently
241242
unsupported_types = ['_bold', '_phase']
242243
if any(ut in this_prefix_basename for ut in unsupported_types):
243244
return this_prefix_basename
244245

245246
# Check to see if it is magnitude or phase reconstruction:
246247
if 'M' in fileinfo.get('ImageType'):
247-
mag_or_phase = 'mag'
248+
mag_or_phase = 'magnitude'
248249
elif 'P' in fileinfo.get('ImageType'):
249250
mag_or_phase = 'phase'
250251
else:
251252
mag_or_phase = suffix
252253

253254
# Insert reconstruction label
254-
if not ('_part-%s' % mag_or_phase) in this_prefix_basename:
255-
# If "_part-" is specified, prepend the 'mag_or_phase' value.
256-
if '_part-' in this_prefix_basename:
255+
if not ('_rec-%s' % mag_or_phase) in this_prefix_basename:
256+
# If "_rec-" is specified, prepend the 'mag_or_phase' value.
257+
if '_rec-' in this_prefix_basename:
257258
raise BIDSError(
258-
"Part label for images will be automatically set, remove "
259+
"Rec label for images will be automatically set, remove "
259260
"from heuristic"
260261
)
261262

262-
# If not, insert "_part-" + 'mag_or_phase' into the prefix_basename
263+
# If not, insert "_rec-" + 'mag_or_phase' into the prefix_basename
263264
# **before** "_run", "_echo" or "_sbref", whichever appears first:
264265
for label in ['_run', '_echo', '_sbref']:
265266
if (label in this_prefix_basename):
266267
this_prefix_basename = this_prefix_basename.replace(
267-
label, "_part-%s%s" % (mag_or_phase, label)
268+
label, "_rec-%s%s" % (mag_or_phase, label)
268269
)
269270
break
270271
return this_prefix_basename
271272

272273

273-
def update_multiecho_name(fileinfo, this_prefix_basename, echo_times, suffix):
274+
def update_multiecho_name(fileinfo, this_prefix_basename, echo_times):
274275
"""
275276
Insert `_echo-<num>` entity into filename if data are from a multi-echo
276277
sequence.
277278
"""
278-
unsupported_types = ['_magnitude1', '_magnitude2', '_phasediff', '_phase1', '_phase2']
279+
# Field maps separate echoes differently
280+
unsupported_types = [
281+
'_magnitude', '_magnitude1', '_magnitude2',
282+
'_phasediff', '_phase1', '_phase2', '_fieldmap'
283+
]
279284
if any(ut in this_prefix_basename for ut in unsupported_types):
280285
return this_prefix_basename
281286

@@ -302,11 +307,16 @@ def update_multiecho_name(fileinfo, this_prefix_basename, echo_times, suffix):
302307
return this_prefix_basename
303308

304309

305-
def update_uncombined_name(fileinfo, this_prefix_basename, channel_names, suffix):
310+
def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
306311
"""
307312
Insert `_channel-<num>` entity into filename if data are from a sequence
308313
with "save uncombined".
309314
"""
315+
# In case any scan types separate channels differently
316+
unsupported_types = []
317+
if any(ut in this_prefix_basename for ut in unsupported_types):
318+
return this_prefix_basename
319+
310320
# Determine the channel number
311321
channel_number = ''.join([c for c in fileinfo['CoilString'] if c.isdigit()])
312322
if not channel_number:
@@ -661,12 +671,9 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
661671
this_prefix_basename = prefix_basename
662672

663673
# Update name if multi-echo
664-
# (Note: it can be _sbref and multiecho, so don't use "elif"):
665-
# For multi-echo sequences, we have to specify the echo number in
666-
# the file name:
667674
if bids_file and is_multiecho:
668675
this_prefix_basename = update_multiecho_name(
669-
bids_meta, this_prefix_basename, echo_times, suffix
676+
bids_meta, this_prefix_basename, echo_times
670677
)
671678

672679
# Update name if complex data
@@ -678,7 +685,7 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
678685
# Update name if uncombined (channel-level) data
679686
if bids_file and is_uncombined:
680687
this_prefix_basename = update_uncombined_name(
681-
bids_meta, this_prefix_basename, channel_names, suffix
688+
bids_meta, this_prefix_basename, channel_names
682689
)
683690

684691
# Fallback option:

0 commit comments

Comments
 (0)