From 49ad86a659b263437303b8da8ffd503c70cca32c Mon Sep 17 00:00:00 2001 From: Gabor Kovacs Date: Sun, 2 Jun 2024 18:37:45 -0700 Subject: [PATCH] Add scipy as dependency and fix read_tile_sizes. --- pyproject.toml | 1 + .../qc/tile_transformations.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 999498c..f51a9c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ dependencies = [ 'pydantic', 'psutil', 'matplotlib', + 'scipy', 'aind-data-schema', 'aind-codeocean-api==0.3.0', 'aind-ng-link>=1.0.15', diff --git a/src/aind_exaspim_pipeline_utils/qc/tile_transformations.py b/src/aind_exaspim_pipeline_utils/qc/tile_transformations.py index 795754c..5787f0c 100644 --- a/src/aind_exaspim_pipeline_utils/qc/tile_transformations.py +++ b/src/aind_exaspim_pipeline_utils/qc/tile_transformations.py @@ -111,7 +111,7 @@ def get_tile_xyz_size(zgpath: str, level: int): # pragma: no cover def read_tile_sizes(xml_ViewSetups: OrderedDict) -> dict[int, np.ndarray]: # pragma: no cover - """Iterate over the 15 tile ids and read their sizes from the ViewSetup section of the xml file. + """Read all the tile sizes defined in the given xml section. Parameters ---------- @@ -125,15 +125,16 @@ def read_tile_sizes(xml_ViewSetups: OrderedDict) -> dict[int, np.ndarray]: # pr as defined in the xml file, i.e. x,y,z. """ tile_sizes = {} - for x in range(15): - for xml_vSetup in xml_ViewSetups["ViewSetup"]: - if xml_vSetup["id"]: - break - else: - raise KeyError("setupId {} was not found".format(x)) - + vsl = xml_ViewSetups["ViewSetup"] + if not isinstance(vsl, list): + # One entry case + vsl = [ + vsl, + ] + for xml_vSetup in vsl: + x = int(xml_vSetup["id"]) xml_sizes = xml_vSetup["size"] - tile_sizes[x] = np.array([int(x) for x in xml_sizes.strip().split()], dtype=int) + tile_sizes[x] = np.array([int(y) for y in xml_sizes.strip().split()], dtype=int) return tile_sizes