From 2958fa629cfcdff78d846c3bec443d0637f44b0b Mon Sep 17 00:00:00 2001 From: Christopher Rhodes <christopher.rhodes@embl.de> Date: Wed, 27 Sep 2023 15:46:46 +0200 Subject: [PATCH] Updated test data for zmask --- extensions/chaeo/conf/testing.py | 12 ++++++------ extensions/chaeo/test_zstack.py | 2 ++ model_server/accessors.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/extensions/chaeo/conf/testing.py b/extensions/chaeo/conf/testing.py index 13b5ea89..7a6b6953 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 1f9fcf96..78baa64c 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 d2b4da24..a2a28aaa 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, -- GitLab