Skip to content

Commit 9501c09

Browse files
author
Robert D. Vincent
committed
Address more comments, add a test case for 4d float64 data.
1 parent 3974afa commit 9501c09

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

nibabel/minc1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def get_data_shape(self):
9595
def get_zooms(self):
9696
""" Get real-world sizes of voxels """
9797
# zooms must be positive; but steps in MINC can be negative
98-
return tuple([abs(float(dim.step)) if hasattr(dim, 'step') else 1.0 for dim in self._dims])
98+
return tuple([abs(float(dim.step)) if hasattr(dim, 'step') else 1.0
99+
for dim in self._dims])
99100

100101
def get_affine(self):
101102
nspatial = len(self._spatial_dims)

nibabel/minc2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def _get_dimensions(self, var):
7777
dimorder = var.attrs['dimorder'].decode()
7878
except KeyError: # No specified dimensions
7979
return []
80+
# The dimension name list must contain only as many entries
81+
# as the variable has dimensions. This reduces errors when an
82+
# unnecessary dimorder attribute is left behind.
8083
return dimorder.split(',')[:len(var.shape)]
8184

8285
def get_data_dtype(self):

nibabel/tests/data/minc2-4d-d.mnc

180 KB
Binary file not shown.

nibabel/tests/test_minc2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@
8888
max=0.74901961,
8989
mean=0.6061103),
9090
is_proxy=True),
91+
dict(
92+
fname=pjoin(data_path, 'minc2-4d-d.mnc'),
93+
shape=(5, 16, 16, 16),
94+
dtype=np.float64,
95+
affine=np.array([[1., 0., 0., -6.96 ],
96+
[0., 1., 0., -12.453],
97+
[0., 0., 1., -9.48 ],
98+
[0., 0., 0., 1.]]),
99+
zooms=(1., 1., 1., 1.),
100+
# These values from mincstats
101+
data_summary=dict(
102+
min=0.0,
103+
max=5.0,
104+
mean=2.00078125),
105+
is_proxy=True),
91106
]
92107

93108
if have_h5py:

0 commit comments

Comments
 (0)