Skip to content

Commit 939dd92

Browse files
committed
FIX: Various unit issues
1 parent cacb96e commit 939dd92

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

nibabel/nifti1.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,8 +1630,6 @@ def set_xyzt_units(self, xyz=None, t=None):
16301630
xyz = 0
16311631
if t is None:
16321632
t = 0
1633-
xyz_code = self.structarr['xyzt_units'] % 8
1634-
t_code = self.structarr['xyzt_units'] - xyz_code
16351633
xyz_code = unit_codes[xyz]
16361634
t_code = unit_codes[t]
16371635
self.structarr['xyzt_units'] = xyz_code + t_code
@@ -1661,11 +1659,11 @@ def get_norm_zooms(self, raise_unknown=False):
16611659
if t_msg:
16621660
warnings.warn('{} - assuming sec'.format(t_msg))
16631661

1664-
xyz_factor = {'meter': 0.001, 'mm': 1, 'usec': 1000}[xyz_code]
1665-
t_factor = {'sec': 1, 'msec': 1000, 'usec': 1000000}[t_code]
1662+
xyz_factor = {'meter': 1000, 'mm': 1, 'micron': 0.001}[xyz_code]
1663+
t_factor = {'sec': 1, 'msec': 0.001, 'usec': 0.000001}[t_code]
16661664

1667-
xyz_zooms = tuple(np.array(xyz_zooms) / xyz_factor)
1668-
t_zoom = (t_zoom / t_factor,) if t_zoom is not None else ()
1665+
xyz_zooms = tuple(np.array(xyz_zooms) * xyz_factor)
1666+
t_zoom = (t_zoom * t_factor,) if t_zoom is not None else ()
16691667

16701668
return xyz_zooms + t_zoom
16711669

0 commit comments

Comments
 (0)