Skip to content

Commit 9b8a7fa

Browse files
committed
FIX: Various unit issues
1 parent 1efc5e2 commit 9b8a7fa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

nibabel/nifti1.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1620,8 +1620,6 @@ def set_xyzt_units(self, xyz=None, t=None):
16201620
xyz = 0
16211621
if t is None:
16221622
t = 0
1623-
xyz_code = self.structarr['xyzt_units'] % 8
1624-
t_code = self.structarr['xyzt_units'] - xyz_code
16251623
xyz_code = unit_codes[xyz]
16261624
t_code = unit_codes[t]
16271625
self.structarr['xyzt_units'] = xyz_code + t_code
@@ -1651,11 +1649,11 @@ def get_norm_zooms(self, raise_unknown=False):
16511649
if t_msg:
16521650
warnings.warn('{} - assuming sec'.format(t_msg))
16531651

1654-
xyz_factor = {'meter': 0.001, 'mm': 1, 'usec': 1000}[xyz_code]
1655-
t_factor = {'sec': 1, 'msec': 1000, 'usec': 1000000}[t_code]
1652+
xyz_factor = {'meter': 1000, 'mm': 1, 'micron': 0.001}[xyz_code]
1653+
t_factor = {'sec': 1, 'msec': 0.001, 'usec': 0.000001}[t_code]
16561654

1657-
xyz_zooms = tuple(np.array(xyz_zooms) / xyz_factor)
1658-
t_zoom = (t_zoom / t_factor,) if t_zoom is not None else ()
1655+
xyz_zooms = tuple(np.array(xyz_zooms) * xyz_factor)
1656+
t_zoom = (t_zoom * t_factor,) if t_zoom is not None else ()
16591657

16601658
return xyz_zooms + t_zoom
16611659

0 commit comments

Comments
 (0)