Skip to content

Commit 0e106e9

Browse files
committed
FIX: dim_info reorientation
1 parent b99ae4c commit 0e106e9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

nibabel/nifti1.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,13 +2014,10 @@ def as_reoriented(self, ornt):
20142014
return img
20152015

20162016
# Also apply the transform to the dim_info fields
2017-
new_dim = list(img.header.get_dim_info())
2018-
for idx, value in enumerate(new_dim):
2019-
# For each value, leave as None if it was that way,
2020-
# otherwise check where we have mapped it to
2021-
if value is None:
2022-
continue
2023-
new_dim[idx] = np.where(ornt[:, 0] == idx)[0]
2017+
orig_dim_info = img.header.get_dim_info()
2018+
new_dim = [None] * 3
2019+
for idx in range(3):
2020+
new_dim[int(ornt[idx][0])] = orig_dim_info[idx]
20242021

20252022
img.header.set_dim_info(*new_dim)
20262023

0 commit comments

Comments
 (0)