Skip to content

Commit 7858bbc

Browse files
committed
Change part back to rec.
And mag back to magnitude.
1 parent 95e574b commit 7858bbc

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
@@ -232,47 +232,52 @@ def prep_conversion(sid, dicoms, outdir, heuristic, converter, anon_sid,
232232

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

242243
# Check to see if it is magnitude or phase reconstruction:
243244
if 'M' in fileinfo.get('ImageType'):
244-
mag_or_phase = 'mag'
245+
mag_or_phase = 'magnitude'
245246
elif 'P' in fileinfo.get('ImageType'):
246247
mag_or_phase = 'phase'
247248
else:
248249
mag_or_phase = suffix
249250

250251
# Insert reconstruction label
251-
if not ('_part-%s' % mag_or_phase) in this_prefix_basename:
252-
# If "_part-" is specified, prepend the 'mag_or_phase' value.
253-
if '_part-' in this_prefix_basename:
252+
if not ('_rec-%s' % mag_or_phase) in this_prefix_basename:
253+
# If "_rec-" is specified, prepend the 'mag_or_phase' value.
254+
if '_rec-' in this_prefix_basename:
254255
raise BIDSError(
255-
"Part label for images will be automatically set, remove "
256+
"Rec label for images will be automatically set, remove "
256257
"from heuristic"
257258
)
258259

259-
# If not, insert "_part-" + 'mag_or_phase' into the prefix_basename
260+
# If not, insert "_rec-" + 'mag_or_phase' into the prefix_basename
260261
# **before** "_run", "_echo" or "_sbref", whichever appears first:
261262
for label in ['_run', '_echo', '_sbref']:
262263
if (label in this_prefix_basename):
263264
this_prefix_basename = this_prefix_basename.replace(
264-
label, "_part-%s%s" % (mag_or_phase, label)
265+
label, "_rec-%s%s" % (mag_or_phase, label)
265266
)
266267
break
267268
return this_prefix_basename
268269

269270

270-
def update_multiecho_name(fileinfo, this_prefix_basename, echo_times, suffix):
271+
def update_multiecho_name(fileinfo, this_prefix_basename, echo_times):
271272
"""
272273
Insert `_echo-<num>` entity into filename if data are from a multi-echo
273274
sequence.
274275
"""
275-
unsupported_types = ['_magnitude1', '_magnitude2', '_phasediff', '_phase1', '_phase2']
276+
# Field maps separate echoes differently
277+
unsupported_types = [
278+
'_magnitude', '_magnitude1', '_magnitude2',
279+
'_phasediff', '_phase1', '_phase2', '_fieldmap'
280+
]
276281
if any(ut in this_prefix_basename for ut in unsupported_types):
277282
return this_prefix_basename
278283

@@ -299,11 +304,16 @@ def update_multiecho_name(fileinfo, this_prefix_basename, echo_times, suffix):
299304
return this_prefix_basename
300305

301306

302-
def update_uncombined_name(fileinfo, this_prefix_basename, channel_names, suffix):
307+
def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
303308
"""
304309
Insert `_channel-<num>` entity into filename if data are from a sequence
305310
with "save uncombined".
306311
"""
312+
# In case any scan types separate channels differently
313+
unsupported_types = []
314+
if any(ut in this_prefix_basename for ut in unsupported_types):
315+
return this_prefix_basename
316+
307317
# Determine the channel number
308318
channel_number = ''.join([c for c in fileinfo['CoilString'] if c.isdigit()])
309319
if not channel_number:
@@ -657,12 +667,9 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
657667
this_prefix_basename = prefix_basename
658668

659669
# Update name if multi-echo
660-
# (Note: it can be _sbref and multiecho, so don't use "elif"):
661-
# For multi-echo sequences, we have to specify the echo number in
662-
# the file name:
663670
if bids_file and is_multiecho:
664671
this_prefix_basename = update_multiecho_name(
665-
fileinfo, this_prefix_basename, echo_times, suffix
672+
fileinfo, this_prefix_basename, echo_times
666673
)
667674

668675
# Update name if complex data
@@ -674,7 +681,7 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
674681
# Update name if uncombined (channel-level) data
675682
if bids_file and is_uncombined:
676683
this_prefix_basename = update_uncombined_name(
677-
fileinfo, this_prefix_basename, channel_names, suffix
684+
fileinfo, this_prefix_basename, channel_names
678685
)
679686

680687
# Fallback option:

0 commit comments

Comments
 (0)