@@ -232,47 +232,52 @@ def prep_conversion(sid, dicoms, outdir, heuristic, converter, anon_sid,
232
232
233
233
def update_complex_name (fileinfo , this_prefix_basename , suffix ):
234
234
"""
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
236
236
with magnitude/phase reconstruction.
237
237
"""
238
+ # Functional scans separate magnitude/phase differently
238
239
unsupported_types = ['_bold' , '_phase' ]
239
240
if any (ut in this_prefix_basename for ut in unsupported_types ):
240
241
return this_prefix_basename
241
242
242
243
# Check to see if it is magnitude or phase reconstruction:
243
244
if 'M' in fileinfo .get ('ImageType' ):
244
- mag_or_phase = 'mag '
245
+ mag_or_phase = 'magnitude '
245
246
elif 'P' in fileinfo .get ('ImageType' ):
246
247
mag_or_phase = 'phase'
247
248
else :
248
249
mag_or_phase = suffix
249
250
250
251
# 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 :
254
255
raise BIDSError (
255
- "Part label for images will be automatically set, remove "
256
+ "Rec label for images will be automatically set, remove "
256
257
"from heuristic"
257
258
)
258
259
259
- # If not, insert "_part -" + 'mag_or_phase' into the prefix_basename
260
+ # If not, insert "_rec -" + 'mag_or_phase' into the prefix_basename
260
261
# **before** "_run", "_echo" or "_sbref", whichever appears first:
261
262
for label in ['_run' , '_echo' , '_sbref' ]:
262
263
if (label in this_prefix_basename ):
263
264
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 )
265
266
)
266
267
break
267
268
return this_prefix_basename
268
269
269
270
270
- def update_multiecho_name (fileinfo , this_prefix_basename , echo_times , suffix ):
271
+ def update_multiecho_name (fileinfo , this_prefix_basename , echo_times ):
271
272
"""
272
273
Insert `_echo-<num>` entity into filename if data are from a multi-echo
273
274
sequence.
274
275
"""
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
+ ]
276
281
if any (ut in this_prefix_basename for ut in unsupported_types ):
277
282
return this_prefix_basename
278
283
@@ -299,11 +304,16 @@ def update_multiecho_name(fileinfo, this_prefix_basename, echo_times, suffix):
299
304
return this_prefix_basename
300
305
301
306
302
- def update_uncombined_name (fileinfo , this_prefix_basename , channel_names , suffix ):
307
+ def update_uncombined_name (fileinfo , this_prefix_basename , channel_names ):
303
308
"""
304
309
Insert `_channel-<num>` entity into filename if data are from a sequence
305
310
with "save uncombined".
306
311
"""
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
+
307
317
# Determine the channel number
308
318
channel_number = '' .join ([c for c in fileinfo ['CoilString' ] if c .isdigit ()])
309
319
if not channel_number :
@@ -657,12 +667,9 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
657
667
this_prefix_basename = prefix_basename
658
668
659
669
# 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:
663
670
if bids_file and is_multiecho :
664
671
this_prefix_basename = update_multiecho_name (
665
- fileinfo , this_prefix_basename , echo_times , suffix
672
+ fileinfo , this_prefix_basename , echo_times
666
673
)
667
674
668
675
# Update name if complex data
@@ -674,7 +681,7 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
674
681
# Update name if uncombined (channel-level) data
675
682
if bids_file and is_uncombined :
676
683
this_prefix_basename = update_uncombined_name (
677
- fileinfo , this_prefix_basename , channel_names , suffix
684
+ fileinfo , this_prefix_basename , channel_names
678
685
)
679
686
680
687
# Fallback option:
0 commit comments