Skip to content

Commit e201289

Browse files
committed
FIX: add image_type_mr as a sort key. This is to support scans where multiple image types (real, imag, magnitude, phase) were selected
1 parent f55e7a9 commit e201289

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

nibabel/parrec.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ def get_sorted_slice_indices(self):
10561056
dynamics = self.image_defs['dynamic scan number']
10571057
phases = self.image_defs['cardiac phase number']
10581058
echos = self.image_defs['echo number']
1059+
image_type = self.image_defs['image_type_mr']
10591060

10601061
# try adding keys only present in a subset of .PAR files
10611062
idefs = self.image_defs
@@ -1076,7 +1077,7 @@ def get_sorted_slice_indices(self):
10761077

10771078
# Define the desired sort order (last key is highest precedence)
10781079
keys = (slice_nos, echos, phases) + \
1079-
diffusion_keys + asl_keys + (dynamics, )
1080+
diffusion_keys + asl_keys + (dynamics, image_type)
10801081

10811082
"""
10821083
Data sorting is done in two stages:
@@ -1098,8 +1099,8 @@ def get_sorted_slice_indices(self):
10981099
vol_nos = np.asarray(vol_nos)[unsort_indices]
10991100

11001101
# final set of sort keys
1101-
keys += (vol_nos, np.logical_not(is_full), )
1102-
sort_order = np.lexsort(keys)
1102+
keys += (vol_nos, np.logical_not(is_full)) # highest priority
1103+
sort_order = np.lexsort(tuple(keys))
11031104

11041105
# Figure out how many we need to remove from the end, and trim them.
11051106
# Based on our sorting, they should always be last.

0 commit comments

Comments
 (0)