Skip to content

Commit

Permalink
FIX: Various unit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Dec 21, 2017
1 parent 1efc5e2 commit 9b8a7fa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nibabel/nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,6 @@ def set_xyzt_units(self, xyz=None, t=None):
xyz = 0
if t is None:
t = 0
xyz_code = self.structarr['xyzt_units'] % 8
t_code = self.structarr['xyzt_units'] - xyz_code
xyz_code = unit_codes[xyz]
t_code = unit_codes[t]
self.structarr['xyzt_units'] = xyz_code + t_code
Expand Down Expand Up @@ -1651,11 +1649,11 @@ def get_norm_zooms(self, raise_unknown=False):
if t_msg:
warnings.warn('{} - assuming sec'.format(t_msg))

xyz_factor = {'meter': 0.001, 'mm': 1, 'usec': 1000}[xyz_code]
t_factor = {'sec': 1, 'msec': 1000, 'usec': 1000000}[t_code]
xyz_factor = {'meter': 1000, 'mm': 1, 'micron': 0.001}[xyz_code]
t_factor = {'sec': 1, 'msec': 0.001, 'usec': 0.000001}[t_code]

xyz_zooms = tuple(np.array(xyz_zooms) / xyz_factor)
t_zoom = (t_zoom / t_factor,) if t_zoom is not None else ()
xyz_zooms = tuple(np.array(xyz_zooms) * xyz_factor)
t_zoom = (t_zoom * t_factor,) if t_zoom is not None else ()

return xyz_zooms + t_zoom

Expand Down

0 comments on commit 9b8a7fa

Please sign in to comment.