Skip to content
Snippets Groups Projects
Commit d962a3de authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Merged in pixel scale property

parent 97703855
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ class GenericImageDataAccessor(ABC):
@property
def pixel_scale_in_micrometers(self):
return None
return {}
@property
def dtype(self):
......@@ -176,15 +176,12 @@ class CziImageFileAccessor(GenericImageFileAccessor):
@property
def pixel_scale_in_micrometers(self):
meta_sc_str = self.czifile.metadata(raw=False)['ImageDocument']['Metadata']['ImageScaling']['ImagePixelSize']
meta_mags = self.czifile.metadata(raw=False)['ImageDocument']['Metadata']['ImageScaling']['ScalingComponent']
sc_xy = list(map(
float,
meta_sc_str.split(',')
))
assert sc_xy[0] == sc_xy[1]
mags = [float(m['Magnification']) for m in meta_mags]
return sc_xy[0] / np.product(mags)
scale_meta = self.czifile.metadata(raw=False)['ImageDocument']['Metadata']['Scaling']['Items']['Distance']
sc = {}
for m in scale_meta:
if m['DefaultUnitFormat'].encode() == b'\xc2\xb5m' and m['Id'] in self.shape_dict.keys(): # literal mu-m
sc[m['Id']] = m['Value'] * 1e6
return sc
def write_accessor_data_to_file(fpath: Path, accessor: GenericImageDataAccessor, mkdir=True) -> bool:
......
......@@ -114,4 +114,5 @@ class TestCziImageFileAccess(unittest.TestCase):
def test_read_in_pixel_scale_from_czi(self):
cf = CziImageFileAccessor(czifile['path'])
self.assertAlmostEqual(cf.pixel_scale_in_micrometers, czifile['um_per_pixel'], places=3)
\ No newline at end of file
pxs = cf.pixel_scale_in_micrometers
self.assertAlmostEqual(pxs['X'], czifile['um_per_pixel'], places=3)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment