From cf89bb7051ef61dc75037a46e3d545f777a373e6 Mon Sep 17 00:00:00 2001 From: Felix Scheffler Date: Sat, 27 Jul 2024 02:21:49 +0200 Subject: [PATCH 1/3] fix: consider only dimensions with size >1 for plane-coordinate --- pylibCZIrw/czi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 7d7517c..5b5514f 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -644,6 +644,8 @@ def _create_roi( def _create_default_plane_coords(self) -> Dict[str, int]: """Generates a default plane coordinates dictionary with all indexes to 0. + This default plane coordinate contains all dimensions reported being used by + the CZI-document, but includes only dimensions for which the size is >1. Returns ------- @@ -653,7 +655,7 @@ def _create_default_plane_coords(self) -> Dict[str, int]: return { dim: 0 for dim, dim_index in self.CZI_DIMS.items() - if self._czi_reader.GetDimensionSize(_pylibCZIrw.DimensionIndex(dim_index)) > 0 + if self._czi_reader.GetDimensionSize(_pylibCZIrw.DimensionIndex(dim_index)) > 1 } def _create_plane_coords( From 855ad614383662549f35021e9b73d8ccb7f3a31b Mon Sep 17 00:00:00 2001 From: Felix Scheffler Date: Sat, 27 Jul 2024 08:27:51 +0200 Subject: [PATCH 2/3] refactor: Remove trailing whitespace --- pylibCZIrw/czi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 5b5514f..761936c 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -644,7 +644,7 @@ def _create_roi( def _create_default_plane_coords(self) -> Dict[str, int]: """Generates a default plane coordinates dictionary with all indexes to 0. - This default plane coordinate contains all dimensions reported being used by + This default plane coordinate contains all dimensions reported being used by the CZI-document, but includes only dimensions for which the size is >1. Returns From eb1343cb4fa47f769d731a4c6773117c295d3d12 Mon Sep 17 00:00:00 2001 From: "Soyer, Sebastian" Date: Tue, 6 Aug 2024 10:26:03 +0200 Subject: [PATCH 3/3] Update test references --- pylibCZIrw/tests/unit/test_czi_reader.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pylibCZIrw/tests/unit/test_czi_reader.py b/pylibCZIrw/tests/unit/test_czi_reader.py index 2dcefd4..c9d1d1b 100644 --- a/pylibCZIrw/tests/unit/test_czi_reader.py +++ b/pylibCZIrw/tests/unit/test_czi_reader.py @@ -444,14 +444,14 @@ def test_create_roi_raises_error_on_incorrect_scene() -> None: @pytest.mark.parametrize( "GetDimensionSize, expected", [ - (dimension_sizes_test1, {"C": 0}), + (dimension_sizes_test1, {}), ( dimension_sizes_test2, - {"C": 0, "I": 0, "R": 0, "V": 0}, + {"C": 0, "R": 0, "V": 0}, ), ( dimension_sizes_test3, - {"Z": 0, "C": 0, "T": 0, "R": 0, "I": 0, "H": 0, "V": 0, "B": 0}, + {"Z": 0, "C": 0, "T": 0, "R": 0, "I": 0, "V": 0, "B": 0}, ), ], ) @@ -469,17 +469,17 @@ def test_create_default_plane_coords( @pytest.mark.parametrize( "plane, GetDimensionSize, expected", [ - (None, dimension_sizes_test1, {"C": 0}), - ({"C": 1, "Z": 3, "T": 4}, dimension_sizes_test1, {"C": 1}), + (None, dimension_sizes_test1, {}), + ({"C": 1, "Z": 3, "T": 4}, dimension_sizes_test1, {}), ( {"C": 5, "Z": 3, "T": 4, "B": 12}, dimension_sizes_test2, - {"C": 5, "I": 0, "R": 0, "V": 0}, + {"C": 5, "R": 0, "V": 0}, ), ( None, dimension_sizes_test3, - {"Z": 0, "C": 0, "T": 0, "R": 0, "I": 0, "H": 0, "V": 0, "B": 0}, + {"Z": 0, "C": 0, "T": 0, "R": 0, "I": 0, "V": 0, "B": 0}, ), ], )