Skip to content

Commit 8eb3bce

Browse files
committed
FIX: Various unit issues
1 parent 5b8dd0e commit 8eb3bce

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
@@ -1632,8 +1632,6 @@ def set_xyzt_units(self, xyz=None, t=None):
16321632
xyz = 0
16331633
if t is None:
16341634
t = 0
1635-
xyz_code = self.structarr['xyzt_units'] % 8
1636-
t_code = self.structarr['xyzt_units'] - xyz_code
16371635
xyz_code = unit_codes[xyz]
16381636
t_code = unit_codes[t]
16391637
self.structarr['xyzt_units'] = xyz_code + t_code
@@ -1663,11 +1661,11 @@ def get_norm_zooms(self, raise_unknown=False):
16631661
if t_msg:
16641662
warnings.warn('{} - assuming sec'.format(t_msg))
16651663

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

1669-
xyz_zooms = tuple(np.array(xyz_zooms) / xyz_factor)
1670-
t_zoom = (t_zoom / t_factor,) if t_zoom is not None else ()
1667+
xyz_zooms = tuple(np.array(xyz_zooms) * xyz_factor)
1668+
t_zoom = (t_zoom * t_factor,) if t_zoom is not None else ()
16711669

16721670
return xyz_zooms + t_zoom
16731671

0 commit comments

Comments
 (0)