Skip to content

Commit de4808b

Browse files
committed
Change rec to part for complex-valued data.
1 parent d855f64 commit de4808b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

heudiconv/convert.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def prep_conversion(sid, dicoms, outdir, heuristic, converter, anon_sid,
235235

236236
def update_complex_name(metadata, filename, suffix):
237237
"""
238-
Insert `_rec-<magnitude|phase>` entity into filename if data are from a
238+
Insert `_part-<mag|phase>` entity into filename if data are from a
239239
sequence with magnitude/phase part.
240240
241241
Parameters
@@ -254,15 +254,18 @@ def update_complex_name(metadata, filename, suffix):
254254
Updated filename with rec entity added in appropriate position.
255255
"""
256256
# Some scans separate magnitude/phase differently
257-
unsupported_types = ['_bold', '_phase',
257+
# A small note: _phase is deprecated, but this may add part-mag to
258+
# magnitude data while leaving phase data with a separate suffix,
259+
# depending on how one sets up their heuristic.
260+
unsupported_types = ['_phase',
258261
'_magnitude', '_magnitude1', '_magnitude2',
259262
'_phasediff', '_phase1', '_phase2']
260263
if any(ut in filename for ut in unsupported_types):
261264
return filename
262265

263266
# Check to see if it is magnitude or phase part:
264267
if 'M' in metadata.get('ImageType'):
265-
mag_or_phase = 'magnitude'
268+
mag_or_phase = 'mag'
266269
elif 'P' in metadata.get('ImageType'):
267270
mag_or_phase = 'phase'
268271
else:
@@ -272,19 +275,19 @@ def update_complex_name(metadata, filename, suffix):
272275
filetype = '_' + filename.split('_')[-1]
273276

274277
# Insert rec label
275-
if not ('_rec-%s' % mag_or_phase) in filename:
276-
# If "_rec-" is specified, prepend the 'mag_or_phase' value.
277-
if '_rec-' in filename:
278+
if not ('_part-%s' % mag_or_phase) in filename:
279+
# If "_part-" is specified, prepend the 'mag_or_phase' value.
280+
if '_part-' in filename:
278281
raise BIDSError(
279-
"Reconstruction label for images will be automatically set, "
282+
"Part label for images will be automatically set, "
280283
"remove from heuristic"
281284
)
282285

283286
# Insert it **before** the following string(s), whichever appears first.
284-
for label in ['_dir', '_run', '_mod', '_echo', '_recording', '_proc', '_space', filetype]:
287+
for label in ['_recording', '_proc', '_space', filetype]:
285288
if (label == filetype) or (label in filename):
286289
filename = filename.replace(
287-
label, "_rec-%s%s" % (mag_or_phase, label)
290+
label, "_part-%s%s" % (mag_or_phase, label)
288291
)
289292
break
290293

0 commit comments

Comments
 (0)