Skip to content

Commit 3b29db8

Browse files
committed
Change channel to ch and rec to part.
1 parent 788bd96 commit 3b29db8

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

heudiconv/convert.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,17 @@ def prep_conversion(sid, dicoms, outdir, heuristic, converter, anon_sid,
232232

233233
def update_complex_name(fileinfo, this_prefix_basename, suffix):
234234
"""
235-
Insert `_rec-<magnitude|phase>` entity into filename if data are from a sequence
236-
with magnitude/phase reconstruction.
235+
Insert `_part-<magnitude|phase>` entity into filename if data are from a sequence
236+
with magnitude/phase part.
237237
"""
238238
# Functional scans separate magnitude/phase differently
239239
unsupported_types = ['_bold', '_phase']
240240
if any(ut in this_prefix_basename for ut in unsupported_types):
241241
return this_prefix_basename
242242

243-
# Check to see if it is magnitude or phase reconstruction:
243+
# Check to see if it is magnitude or phase part:
244244
if 'M' in fileinfo.get('ImageType'):
245-
mag_or_phase = 'magnitude'
245+
mag_or_phase = 'mag'
246246
elif 'P' in fileinfo.get('ImageType'):
247247
mag_or_phase = 'phase'
248248
else:
@@ -251,26 +251,26 @@ def update_complex_name(fileinfo, this_prefix_basename, suffix):
251251
# Determine scan suffix
252252
filetype = '_' + this_prefix_basename.split('_')[-1]
253253

254-
# Insert reconstruction label
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:
254+
# Insert part label
255+
if not ('_part-%s' % mag_or_phase) in this_prefix_basename:
256+
# If "_part-" is specified, prepend the 'mag_or_phase' value.
257+
if '_part-' in this_prefix_basename:
258258
raise BIDSError(
259-
"Rec label for images will be automatically set, remove "
259+
"Part label for images will be automatically set, remove "
260260
"from heuristic"
261261
)
262262

263-
# If not, insert "_rec-" + 'mag_or_phase' into the prefix_basename
263+
# If not, insert "_part-" + 'mag_or_phase' into the prefix_basename
264264
# **before** "_run", "_echo" or "_sbref", whichever appears first:
265265
for label in ['_dir', '_run', '_mod', '_echo', '_recording', '_proc', '_space', filetype]:
266266
if label == filetype:
267267
this_prefix_basename = this_prefix_basename.replace(
268-
filetype, "_rec-%s%s" % (mag_or_phase, filetype)
268+
filetype, "_part-%s%s" % (mag_or_phase, filetype)
269269
)
270270
break
271271
elif (label in this_prefix_basename):
272272
this_prefix_basename = this_prefix_basename.replace(
273-
label, "_rec-%s%s" % (mag_or_phase, label)
273+
label, "_part-%s%s" % (mag_or_phase, label)
274274
)
275275
break
276276

@@ -317,7 +317,7 @@ def update_multiecho_name(fileinfo, this_prefix_basename, echo_times):
317317

318318
def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
319319
"""
320-
Insert `_channel-<num>` entity into filename if data are from a sequence
320+
Insert `_ch-<num>` entity into filename if data are from a sequence
321321
with "save uncombined".
322322
"""
323323
# In case any scan types separate channels differently
@@ -329,6 +329,7 @@ def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
329329
channel_number = ''.join([c for c in fileinfo['CoilString'] if c.isdigit()])
330330
if not channel_number:
331331
channel_number = channel_names.index(fileinfo['CoilString']) + 1
332+
channel_number = channel_number.zfill(2)
332333

333334
# Determine scan suffix
334335
filetype = '_' + this_prefix_basename.split('_')[-1]
@@ -338,12 +339,12 @@ def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
338339
for label in ['_recording', '_proc', '_space', filetype]:
339340
if label == filetype:
340341
this_prefix_basename = this_prefix_basename.replace(
341-
filetype, "_channel-%s%s" % (channel_number, filetype)
342+
filetype, "_ch-%s%s" % (channel_number, filetype)
342343
)
343344
break
344345
elif (label in this_prefix_basename):
345346
this_prefix_basename = this_prefix_basename.replace(
346-
label, "_channel-%s%s" % (channel_number, label)
347+
label, "_ch-%s%s" % (channel_number, label)
347348
)
348349
break
349350
return this_prefix_basename

0 commit comments

Comments
 (0)