From 53981ac98ce1b09e9dacbffc014ed32bd229cf5b Mon Sep 17 00:00:00 2001 From: Lukas Hatscher Date: Thu, 27 Jun 2024 12:21:29 +0000 Subject: [PATCH 1/3] adjusted docstrings in steinbock reader py file --- src/spatialdata_io/readers/steinbock.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/spatialdata_io/readers/steinbock.py b/src/spatialdata_io/readers/steinbock.py index 69cd5e40..848d97b6 100644 --- a/src/spatialdata_io/readers/steinbock.py +++ b/src/spatialdata_io/readers/steinbock.py @@ -33,6 +33,24 @@ def steinbock( - `Steinbock pipeline `_. + Current mandatory outputs of the Steinbock toolkit + ---------- + - one comprehensive anndata object labeled as 'cells.h5ad' in the main working directory + - an 'ome' folder containing the steinbock ome.tiff exported tiff images + - masks directory labeled as either 'masks_deepcell' or 'masks_ilastik' + + Users have to carefully construct the andata object with steinbock using the images.csv table. + Constructing the anndata object without the images.csv table will leave the anndata without + 'adata.obs.images' which will subsequently result in an error (see line 99) + Therefore, currently users are adviced to start their steinbock analyses from .mcd files. + A possible workaround for this would be to handcraft the images.csv table according to steinbock format + if users want to start from tiff images in steinbock + (https://bodenmillergroup.github.io/steinbock/latest/cli/preprocessing/) + + The andata tables, masks and ome.tiffs have to be named accordingly so the + spatialdata.io steinbock reader correctly assigns all instances. + + Parameters ---------- path From 7811298627f31ca253444b66a58b6c46dc9eb772 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:32:42 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/spatialdata_io/readers/steinbock.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spatialdata_io/readers/steinbock.py b/src/spatialdata_io/readers/steinbock.py index 848d97b6..adb9770b 100644 --- a/src/spatialdata_io/readers/steinbock.py +++ b/src/spatialdata_io/readers/steinbock.py @@ -39,15 +39,15 @@ def steinbock( - an 'ome' folder containing the steinbock ome.tiff exported tiff images - masks directory labeled as either 'masks_deepcell' or 'masks_ilastik' - Users have to carefully construct the andata object with steinbock using the images.csv table. - Constructing the anndata object without the images.csv table will leave the anndata without - 'adata.obs.images' which will subsequently result in an error (see line 99) - Therefore, currently users are adviced to start their steinbock analyses from .mcd files. - A possible workaround for this would be to handcraft the images.csv table according to steinbock format - if users want to start from tiff images in steinbock + Users have to carefully construct the andata object with steinbock using the images.csv table. + Constructing the anndata object without the images.csv table will leave the anndata without + 'adata.obs.images' which will subsequently result in an error (see line 99) + Therefore, currently users are adviced to start their steinbock analyses from .mcd files. + A possible workaround for this would be to handcraft the images.csv table according to steinbock format + if users want to start from tiff images in steinbock (https://bodenmillergroup.github.io/steinbock/latest/cli/preprocessing/) - The andata tables, masks and ome.tiffs have to be named accordingly so the + The andata tables, masks and ome.tiffs have to be named accordingly so the spatialdata.io steinbock reader correctly assigns all instances. From 51bb98331061fe0a086c92363bf84e701d3194dd Mon Sep 17 00:00:00 2001 From: Luca Marconato Date: Thu, 30 Apr 2026 14:30:28 +0200 Subject: [PATCH 3/3] fix: improve steinbock docstring accuracy and RST formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move notes into a proper NumPy `Notes` section (fixes RST render) - Fix typos: andata→anndata, adviced→advised - Correct adata.obs.images→adata.obs.image (verified from source) - Replace plain URL with RST hyperlink syntax - Clarify that only one masks dir is used at a time (controlled by labels_kind) - Specify *.ome.tiff image format (from SteinbockKeys.IMAGE_SUFFIX) - Explain the images.csv/--info mechanism with required columns and correct link to file types docs instead of preprocessing docs Co-Authored-By: Claude Sonnet 4.6 --- .gitignore | 2 ++ src/spatialdata_io/readers/steinbock.py | 41 ++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 32771d1c..2bb78e5b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,8 @@ __pycache__/ _version.py node_modules/ .code-workspace +.asv/ +uv.lock # test datasets (e.g. Xenium ones) data/ diff --git a/src/spatialdata_io/readers/steinbock.py b/src/spatialdata_io/readers/steinbock.py index adb9770b..eae2c99f 100644 --- a/src/spatialdata_io/readers/steinbock.py +++ b/src/spatialdata_io/readers/steinbock.py @@ -33,24 +33,6 @@ def steinbock( - `Steinbock pipeline `_. - Current mandatory outputs of the Steinbock toolkit - ---------- - - one comprehensive anndata object labeled as 'cells.h5ad' in the main working directory - - an 'ome' folder containing the steinbock ome.tiff exported tiff images - - masks directory labeled as either 'masks_deepcell' or 'masks_ilastik' - - Users have to carefully construct the andata object with steinbock using the images.csv table. - Constructing the anndata object without the images.csv table will leave the anndata without - 'adata.obs.images' which will subsequently result in an error (see line 99) - Therefore, currently users are adviced to start their steinbock analyses from .mcd files. - A possible workaround for this would be to handcraft the images.csv table according to steinbock format - if users want to start from tiff images in steinbock - (https://bodenmillergroup.github.io/steinbock/latest/cli/preprocessing/) - - The andata tables, masks and ome.tiffs have to be named accordingly so the - spatialdata.io steinbock reader correctly assigns all instances. - - Parameters ---------- path @@ -65,6 +47,29 @@ def steinbock( Returns ------- :class:`spatialdata.SpatialData` + + Notes + ----- + Mandatory outputs of the Steinbock pipeline required by this reader: + + - ``cells.h5ad``: the AnnData object in the main working directory + - ``ome/``: directory containing the steinbock OME-TIFF images (``*.ome.tiff``) + - ``masks_deepcell/`` or ``masks_ilastik/``: the masks directory, selected via the + ``labels_kind`` parameter (only one is used at a time) + + When exporting to AnnData with ``steinbock export anndata``, the ``--info`` option + (default: ``images.csv``) controls whether image metadata is embedded. When present, + steinbock copies the ``image`` column from ``images.csv`` into ``adata.obs.image`` for + every cell; this reader requires that column to map cells to their source image. Without + it, ``adata.obs.image`` will not exist and the reader will fail. ``images.csv`` is + generated automatically by ``steinbock preprocess imc images`` when starting from + ``.mcd`` files. Users who start from TIFF images must hand-craft ``images.csv`` with at + least the columns ``image``, ``width_px``, ``height_px``, and ``num_channels`` as + described in the + `Steinbock file types documentation `_. + + All AnnData tables, masks, and OME-TIFFs must follow the steinbock naming conventions so + that the reader can correctly match all instances. """ path = Path(path)