Skip to content

Commit 5c30366

Browse files
committed
FIX: Various unit issues
1 parent de9323c commit 5c30366

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
@@ -1671,8 +1671,6 @@ def set_xyzt_units(self, xyz=None, t=None):
16711671
xyz = 0
16721672
if t is None:
16731673
t = 0
1674-
xyz_code = self.structarr['xyzt_units'] % 8
1675-
t_code = self.structarr['xyzt_units'] - xyz_code
16761674
xyz_code = unit_codes[xyz]
16771675
t_code = unit_codes[t]
16781676
self.structarr['xyzt_units'] = xyz_code + t_code
@@ -1702,11 +1700,11 @@ def get_norm_zooms(self, raise_unknown=False):
17021700
if t_msg:
17031701
warnings.warn('{} - assuming sec'.format(t_msg))
17041702

1705-
xyz_factor = {'meter': 0.001, 'mm': 1, 'usec': 1000}[xyz_code]
1706-
t_factor = {'sec': 1, 'msec': 1000, 'usec': 1000000}[t_code]
1703+
xyz_factor = {'meter': 1000, 'mm': 1, 'micron': 0.001}[xyz_code]
1704+
t_factor = {'sec': 1, 'msec': 0.001, 'usec': 0.000001}[t_code]
17071705

1708-
xyz_zooms = tuple(np.array(xyz_zooms) / xyz_factor)
1709-
t_zoom = (t_zoom / t_factor,) if t_zoom is not None else ()
1706+
xyz_zooms = tuple(np.array(xyz_zooms) * xyz_factor)
1707+
t_zoom = (t_zoom * t_factor,) if t_zoom is not None else ()
17101708

17111709
return xyz_zooms + t_zoom
17121710

0 commit comments

Comments
 (0)