diff --git a/extensions/chaeo/accessors.py b/extensions/chaeo/accessors.py index 5d2987faabe5d341b9c23193d0ce32b2f4fa56d0..2b23318beda15924ee613a23f74d03a6a0f0c806 100644 --- a/extensions/chaeo/accessors.py +++ b/extensions/chaeo/accessors.py @@ -44,6 +44,9 @@ class MonoPatchStack(InMemoryDataAccessor): def iat(self, i): return self.data[:, :, 0, i] + def iat_yxcz(self, i): + return np.expand_dims(self.iat(i), (2, 3)) + def get_list(self): n = self.nz return [self.data[:, :, 0, zi] for zi in range(0, n)] diff --git a/extensions/chaeo/tests/test_accessors.py b/extensions/chaeo/tests/test_accessors.py index 4019257566e3b731e25595d6ef5b59f010b746e1..c74fdd86ca19c90ab7ed5fb602fa50220eac314f 100644 --- a/extensions/chaeo/tests/test_accessors.py +++ b/extensions/chaeo/tests/test_accessors.py @@ -43,4 +43,11 @@ class TestCziImageFileAccess(unittest.TestCase): def test_raises_filenotfound(self): from extensions.chaeo.accessors import FileNotFoundError with self.assertRaises(FileNotFoundError): - acc = MonoPatchStackFromFile('c:/fake/file/name.tif') \ No newline at end of file + acc = MonoPatchStackFromFile('c:/fake/file/name.tif') + + def test_patch_as_yxcz_array(self): + w = 256 + h = 512 + n = 4 + acc = MonoPatchStack([np.random.rand(h, w) for _ in range(0, 4)]) + self.assertEqual(acc.iat_yxcz(0).shape, (h, w, 1, 1)) \ No newline at end of file