@@ -1626,6 +1626,38 @@ def set_xyzt_units(self, xyz=None, t=None):
1626
1626
t_code = unit_codes [t ]
1627
1627
self .structarr ['xyzt_units' ] = xyz_code + t_code
1628
1628
1629
+ def get_norm_zooms (self , raise_unknown = False ):
1630
+ raw_zooms = self .get_zooms ()
1631
+ xyz_zooms = raw_zooms [:3 ]
1632
+ t_zoom = raw_zooms [3 ] if len (raw_zooms ) > 3 else None
1633
+
1634
+ xyz_code , t_code = self .get_xyzt_units ()
1635
+ xyz_msg = t_msg = ''
1636
+ if xyz_code == 'unknown' :
1637
+ xyz_msg = 'Unknown spatial units'
1638
+ xyz_code = 'mm'
1639
+ if t_code == 'unknown' and t_zoom is not None :
1640
+ t_msg = 'Unknown time units'
1641
+ t_code = 'sec'
1642
+ if raise_unknown and (xyz_msg , t_msg ) != ('' , '' ):
1643
+ if xyz_msg and t_msg :
1644
+ msg = 'Unknown spatial and time units'
1645
+ else :
1646
+ msg = xyz_msg or t_msg
1647
+ raise ValueError ("Error: {}" .format (msg ))
1648
+ if xyz_msg :
1649
+ warnings .warn ('{} - assuming mm' .format (xyz_msg ))
1650
+ if t_msg :
1651
+ warnings .warn ('{} - assuming sec' .format (t_msg ))
1652
+
1653
+ xyz_factor = {'meter' : 0.001 , 'mm' : 1 , 'usec' : 1000 }[xyz_code ]
1654
+ t_factor = {'sec' : 1 , 'msec' : 1000 , 'usec' : 1000000 }[t_code ]
1655
+
1656
+ xyz_zooms = tuple (np .array (xyz_zooms ) / xyz_factor )
1657
+ t_zoom = (t_zoom / t_factor ,) if t_zoom is not None else ()
1658
+
1659
+ return xyz_zooms + t_zoom
1660
+
1629
1661
def _clean_after_mapping (self ):
1630
1662
''' Set format-specific stuff after converting header from mapping
1631
1663
0 commit comments