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

Accessor convenience property for either data_yx or data_yxz depending on dimensionality

parent ac9eeffd
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,13 @@ class GenericImageDataAccessor(ABC):
else:
return self.data[:, :, 0, :]
@property
def data_mono(self) -> np.ndarray:
if self.nz > 1:
return self.data_yxz
else:
return self.data_yx
def _gc(self, channels):
return self.get_channels(list(channels))
......
......@@ -105,6 +105,15 @@ class TestCziImageFileAccess(unittest.TestCase):
self.assertEqual(sm.shape_dict['Z'], 1)
self.assertTrue(np.all(cf.data.max(axis=-1, keepdims=True) == sm.data))
def test_get_mono(self):
w = 256
h = 512
nc = 4
nz = 11
zi = 5
acc = InMemoryDataAccessor(_random_int(h, w, nc, nz))
self.assertEqual(acc.get_mono(0).data_mono.shape, (h, w, nz))
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