Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ba17bc0
mvp
timtreis Sep 13, 2025
06be11c
mvp
timtreis Sep 13, 2025
9ef97fd
for notebook
timtreis Sep 14, 2025
affeff3
added small plotting func
timtreis Sep 14, 2025
db9f34a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 14, 2025
6d36a8e
Merge branch 'main' into bugfix/issue1034-function-to-qc-he-images
timtreis Oct 27, 2025
70c70d0
Merge branch 'main' into bugfix/issue1034-function-to-qc-he-images
timtreis Oct 27, 2025
f06e89a
refactor
timtreis Oct 29, 2025
71bc297
added images from runner
timtreis Oct 29, 2025
80ea59e
made logging robust to different loggers
timtreis Oct 29, 2025
e609d06
restored logging
timtreis Oct 29, 2025
78d6549
restored logging
timtreis Oct 29, 2025
df21e40
removed dead code
timtreis Oct 29, 2025
5c72645
edge cases that caused scverse CI to fail
timtreis Oct 29, 2025
5eebcf2
Merge branch 'main' into bugfix/issue1034-function-to-qc-he-images
timtreis Oct 29, 2025
d6f2ed4
bump
timtreis Oct 29, 2025
6a9fb54
make_tile_grid function
timtreis Oct 29, 2025
5da7432
mvp
timtreis Oct 30, 2025
88047d7
tiling functions
timtreis Nov 24, 2025
8f23aac
Merge branch 'main' into feature/hne_tiling_from_qc_base
timtreis Nov 24, 2025
aebb1c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2025
cdcfeed
mypy fixes
timtreis Nov 24, 2025
9d4a1d5
bugfix
timtreis Nov 24, 2025
ce2da2b
updated tests for correct plot
timtreis Nov 24, 2025
89b18b9
images from runner
timtreis Nov 24, 2025
5005157
bugfix + more tests
timtreis Nov 24, 2025
09fdcb0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2025
ffd5760
images from runner
timtreis Nov 24, 2025
1009068
updated test
timtreis Nov 24, 2025
d8552ad
cleaned up
timtreis Nov 24, 2025
992b3b7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2025
47715be
updated docstrings
timtreis Nov 24, 2025
fb68599
Merge branch 'main' into feature/hne_tiling_from_qc_base
selmanozleyen Nov 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/squidpy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
from multiprocessing import Manager, cpu_count
from queue import Queue
from threading import Thread
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

import joblib as jl
import numba
import numpy as np
import xarray as xr
from spatialdata.models import Image2DModel, Labels2DModel

__all__ = ["singledispatchmethod", "Signal", "SigQueue", "NDArray", "NDArrayA"]
Expand Down Expand Up @@ -372,3 +373,17 @@ def _yx_from_shape(shape: tuple[int, ...]) -> tuple[int, int]:
return shape[1], shape[2]

raise ValueError(f"Unsupported shape {shape}. Expected (y, x) or (c, y, x).")


def _ensure_dim_order(img_da: xr.DataArray, order: Literal["cyx", "yxc"] = "yxc") -> xr.DataArray:
"""
Ensure dims are in the requested order and that a 'c' dim exists.
Only supports images with dims subset of {'y','x','c'}.
"""
dims = list(img_da.dims)
if "y" not in dims or "x" not in dims:
raise ValueError(f'Expected dims to include "y" and "x". Found dims={dims}')
if "c" not in dims:
img_da = img_da.expand_dims({"c": [0]})
# After possible expand, just transpose to target
return img_da.transpose(*tuple(order))
5 changes: 2 additions & 3 deletions src/squidpy/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from __future__ import annotations

from . import im
from .im._detect_tissue import detect_tissue
from . import im, pl

__all__ = ["detect_tissue", "im"]
__all__ = ["im", "pl"]
9 changes: 8 additions & 1 deletion src/squidpy/experimental/im/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
FelzenszwalbParams,
detect_tissue,
)
from ._make_tiles import make_tiles, make_tiles_from_spots

__all__ = ["detect_tissue", "BackgroundDetectionParams", "FelzenszwalbParams"]
__all__ = [
"BackgroundDetectionParams",
"FelzenszwalbParams",
"detect_tissue",
"make_tiles",
"make_tiles_from_spots",
]
8 changes: 5 additions & 3 deletions src/squidpy/experimental/im/_detect_tissue.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from spatialdata.models import Labels2DModel
from spatialdata.transformations import get_transformation

from squidpy._utils import _get_scale_factors, _yx_from_shape
from squidpy._utils import _ensure_dim_order, _get_scale_factors, _yx_from_shape

from ._utils import _flatten_channels, _get_image_data
from ._utils import _flatten_channels, _get_element_data


class DETECT_TISSUE_METHOD(enum.Enum):
Expand Down Expand Up @@ -170,7 +170,9 @@ def detect_tissue(
manual_scale = scale.lower() != "auto"

# Load smallest available or explicit scale
img_src = _get_image_data(sdata, image_key, scale=scale if manual_scale else "auto")
img_node = sdata.images[image_key]
img_da = _get_element_data(img_node, scale if manual_scale else "auto", "image", image_key)
img_src = _ensure_dim_order(img_da, "yxc")
src_h, src_w = _yx_from_shape(img_src.shape)
n_src_px = src_h * src_w

Expand Down
Loading