Skip to content

Commit a2d9099

Browse files
tsaloyarikoptic
authored andcommitted
Update entity orders based on entity table.
1 parent aaf199e commit a2d9099

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

heudiconv/convert.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ def update_complex_name(fileinfo, this_prefix_basename, suffix):
251251
else:
252252
mag_or_phase = suffix
253253

254+
# Determine scan suffix
255+
filetype = '_' + this_prefix_basename.split('_')[-1]
256+
254257
# Insert reconstruction label
255258
if not ('_rec-%s' % mag_or_phase) in this_prefix_basename:
256259
# If "_rec-" is specified, prepend the 'mag_or_phase' value.
@@ -262,12 +265,18 @@ def update_complex_name(fileinfo, this_prefix_basename, suffix):
262265

263266
# If not, insert "_rec-" + 'mag_or_phase' into the prefix_basename
264267
# **before** "_run", "_echo" or "_sbref", whichever appears first:
265-
for label in ['_run', '_echo', '_sbref']:
266-
if (label in this_prefix_basename):
268+
for label in ['_dir', '_run', '_mod', '_echo', '_recording', '_proc', '_space', filetype]:
269+
if label == filetype:
270+
this_prefix_basename = this_prefix_basename.replace(
271+
filetype, "_rec-%s%s" % (mag_or_phase, filetype)
272+
)
273+
break
274+
elif (label in this_prefix_basename):
267275
this_prefix_basename = this_prefix_basename.replace(
268276
label, "_rec-%s%s" % (mag_or_phase, label)
269277
)
270278
break
279+
271280
return this_prefix_basename
272281

273282

@@ -289,10 +298,12 @@ def update_multiecho_name(fileinfo, this_prefix_basename, echo_times):
289298
echo_number = fileinfo['EchoNumber']
290299
else:
291300
echo_number = echo_times.index(fileinfo['EchoTime']) + 1
301+
302+
# Determine scan suffix
292303
filetype = '_' + this_prefix_basename.split('_')[-1]
293304

294305
# Insert it **before** the following string(s), whichever appears first.
295-
for label in ['_run', filetype]:
306+
for label in ['_recording', '_proc', '_space', filetype]:
296307
if label == filetype:
297308
this_prefix_basename = this_prefix_basename.replace(
298309
filetype, "_echo-%s%s" % (echo_number, filetype)
@@ -321,10 +332,13 @@ def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
321332
channel_number = ''.join([c for c in fileinfo['CoilString'] if c.isdigit()])
322333
if not channel_number:
323334
channel_number = channel_names.index(fileinfo['CoilString']) + 1
335+
336+
# Determine scan suffix
324337
filetype = '_' + this_prefix_basename.split('_')[-1]
325338

326339
# Insert it **before** the following string(s), whichever appears first.
327-
for label in ['_run', '_echo', filetype]:
340+
# Choosing to put channel near the end since it's not in the specification yet.
341+
for label in ['_recording', '_proc', '_space', filetype]:
328342
if label == filetype:
329343
this_prefix_basename = this_prefix_basename.replace(
330344
filetype, "_channel-%s%s" % (channel_number, filetype)

0 commit comments

Comments
 (0)