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