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

Added mip convenience function

parent 06a67847
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,9 @@ class GenericImageDataAccessor(ABC):
def get_zi(self, zi: int):
"""
Return a new accessor of a specific z-coordinate
"""
return self._derived_accessor(
self.data.take(
indices=[zi],
......@@ -58,6 +61,12 @@ class GenericImageDataAccessor(ABC):
)
)
def get_mip(self):
"""
Return a new accessor of maximum intensity projection (MIP) along z-axis
"""
return self.apply(lambda x: x.max(axis=self._ga('Z'), keepdims=True))
def get_mono(self, channel: int, mip: bool = False, squeeze=False):
return self.get_channels([channel], mip=mip)
......
......@@ -73,6 +73,17 @@ class TestCziImageFileAccess(unittest.TestCase):
self.assertTrue(np.all(sz.data[:, :, :, 0] == cf.data[:, :, :, zi]))
def test_get_mip(self):
w = 256
h = 512
nc = 4
nz = 11
zi = 5
cf = InMemoryDataAccessor(_random_int(h, w, nc, nz))
sm = cf.get_mip()
self.assertEqual(sm.shape_dict['Z'], 1)
self.assertTrue(np.all(cf.data.max(axis=-1, keepdims=True) == sm.data))
def test_crop_yx(self):
w = 256
h = 512
......
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