Skip to content

Commit 788bd96

Browse files
committed
Update entity orders based on entity table.
1 parent 7858bbc commit 788bd96

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
@@ -248,6 +248,9 @@ def update_complex_name(fileinfo, this_prefix_basename, suffix):
248248
else:
249249
mag_or_phase = suffix
250250

251+
# Determine scan suffix
252+
filetype = '_' + this_prefix_basename.split('_')[-1]
253+
251254
# Insert reconstruction label
252255
if not ('_rec-%s' % mag_or_phase) in this_prefix_basename:
253256
# If "_rec-" is specified, prepend the 'mag_or_phase' value.
@@ -259,12 +262,18 @@ def update_complex_name(fileinfo, this_prefix_basename, suffix):
259262

260263
# If not, insert "_rec-" + 'mag_or_phase' into the prefix_basename
261264
# **before** "_run", "_echo" or "_sbref", whichever appears first:
262-
for label in ['_run', '_echo', '_sbref']:
263-
if (label in this_prefix_basename):
265+
for label in ['_dir', '_run', '_mod', '_echo', '_recording', '_proc', '_space', filetype]:
266+
if label == filetype:
267+
this_prefix_basename = this_prefix_basename.replace(
268+
filetype, "_rec-%s%s" % (mag_or_phase, filetype)
269+
)
270+
break
271+
elif (label in this_prefix_basename):
264272
this_prefix_basename = this_prefix_basename.replace(
265273
label, "_rec-%s%s" % (mag_or_phase, label)
266274
)
267275
break
276+
268277
return this_prefix_basename
269278

270279

@@ -286,10 +295,12 @@ def update_multiecho_name(fileinfo, this_prefix_basename, echo_times):
286295
echo_number = fileinfo['EchoNumber']
287296
else:
288297
echo_number = echo_times.index(fileinfo['EchoTime']) + 1
298+
299+
# Determine scan suffix
289300
filetype = '_' + this_prefix_basename.split('_')[-1]
290301

291302
# Insert it **before** the following string(s), whichever appears first.
292-
for label in ['_run', filetype]:
303+
for label in ['_recording', '_proc', '_space', filetype]:
293304
if label == filetype:
294305
this_prefix_basename = this_prefix_basename.replace(
295306
filetype, "_echo-%s%s" % (echo_number, filetype)
@@ -318,10 +329,13 @@ def update_uncombined_name(fileinfo, this_prefix_basename, channel_names):
318329
channel_number = ''.join([c for c in fileinfo['CoilString'] if c.isdigit()])
319330
if not channel_number:
320331
channel_number = channel_names.index(fileinfo['CoilString']) + 1
332+
333+
# Determine scan suffix
321334
filetype = '_' + this_prefix_basename.split('_')[-1]
322335

323336
# Insert it **before** the following string(s), whichever appears first.
324-
for label in ['_run', '_echo', filetype]:
337+
# Choosing to put channel near the end since it's not in the specification yet.
338+
for label in ['_recording', '_proc', '_space', filetype]:
325339
if label == filetype:
326340
this_prefix_basename = this_prefix_basename.replace(
327341
filetype, "_channel-%s%s" % (channel_number, filetype)

0 commit comments

Comments
 (0)