diff --git a/extensions/chaeo/conf/testing.py b/extensions/chaeo/conf/testing.py index 13b5ea89513e3a18bfadfcd9a46ef9b44ed2f283..7a6b6953b8877c621b65e8e4ac54d375fe7cb9fe 100644 --- a/extensions/chaeo/conf/testing.py +++ b/extensions/chaeo/conf/testing.py @@ -2,12 +2,12 @@ from pathlib import Path root = Path.home() / 'model-server' -czi_multichannel_zstack = { - 'path': root / 'testing' / 'proj0004-exp0038-SelectionA10-01.czi', - 'w': 2048, - 'h': 2048, - 'c': 5, - 'z': 21, +multichannel_zstack = { + 'path': root / 'testing' / 'zmask-test-stack.tif', + 'w': 512, + 'h': 512, + 'c': 2, + 'z': 7, } pixel_classifier = { diff --git a/extensions/chaeo/test_zstack.py b/extensions/chaeo/test_zstack.py index 1f9fcf9600327e31571768bb12545ed169b5807b..78baa64c50f6a5ef167c261f63064199e6840fb9 100644 --- a/extensions/chaeo/test_zstack.py +++ b/extensions/chaeo/test_zstack.py @@ -1,5 +1,6 @@ import unittest +from extensions.chaeo.conf.testing import multichannel_zstack, pixel_classifier from extensions.chaeo.zstack import build_stack_mask from model_server.accessors import InMemoryDataAccessor @@ -7,6 +8,7 @@ class TestZStackDerivedDataProducts(unittest.TestCase): def setUp(self) -> None: # need test data incl obj map + self.zstack = self.obmap = None self.stack = None diff --git a/model_server/accessors.py b/model_server/accessors.py index d2b4da2482f2ab80445d17a871616042b8190002..a2a28aaafa5f4dac07f400956495e75aa4e75076 100644 --- a/model_server/accessors.py +++ b/model_server/accessors.py @@ -67,6 +67,18 @@ class GenericImageFileAccessor(GenericImageDataAccessor): # image data is loaded raise FileAccessorError(f'Could not find file at {fpath}') self.fpath = fpath +class ImageJTiffFileAccessor(GenericImageFileAccessor): + def __init__(self, fpath: Path): + super().__init__(fpath) + + try: + tf = tifffile.TiffFile(fpath) + self.tf = tf + except Exception: + FileAccessorError(f'Unable to access data in {fpath}') + + self._data = tf.asarray() + class CziImageFileAccessor(GenericImageFileAccessor): """ Image that is stored in a Zeiss .CZI file; may be multi-channel, and/or a z-stack,