diff --git a/model_server/extensions/chaeo/accessors.py b/model_server/extensions/chaeo/accessors.py index ee9bfd07b6e1dcfadc4c1f0f31ba0d3fbd6081b4..45eee67b63847ba4df80814fd2d6a1fc0f154550 100644 --- a/model_server/extensions/chaeo/accessors.py +++ b/model_server/extensions/chaeo/accessors.py @@ -127,11 +127,18 @@ class PatchStack(InMemoryDataAccessor): @property def pyxcz(self): - return self._data + return self.data @property + def pczyx(self): + return np.moveaxis( + self.data, + [0, 3, 4, 1, 2], + [0, 1, 2, 3, 4] + ) + @property def shape(self): - return self._data.shape + return self.data.shape @property def shape_dict(self): diff --git a/model_server/extensions/chaeo/tests/test_accessors.py b/model_server/extensions/chaeo/tests/test_accessors.py index 086b405c148c5a179172f5dea19f28c3d37e360f..0aa364c794de074524ecc231ee602208a8c99b4a 100644 --- a/model_server/extensions/chaeo/tests/test_accessors.py +++ b/model_server/extensions/chaeo/tests/test_accessors.py @@ -61,4 +61,15 @@ class TestMultipositionCziImageFileAccess(unittest.TestCase): self.assertEqual(acc.hw, (h, 2 * w)) self.assertEqual(acc.chroma, c) self.assertEqual(acc.iat(0).shape, (h, 2 * w, c, nz)) - self.assertEqual(acc.iat_yxcz(0).shape, (h, 2 * w, c, nz)) \ No newline at end of file + self.assertEqual(acc.iat_yxcz(0).shape, (h, 2 * w, c, nz)) + + def test_pczyx(self): + w = 256 + h = 512 + n = 4 + nz = 15 + nc = 2 + acc = PatchStack(np.random.rand(n, h, w, nc, nz)) + self.assertEqual(acc.count, n) + self.assertEqual(acc.pczyx.shape, (n, nc, nz, h, w)) + self.assertEqual(acc.hw, (h, w))