Skip to content
Merged
Changes from all commits
Commits
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
16 changes: 12 additions & 4 deletions src/spatialdata_io/readers/visium_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def visium_hd(
path
Path to directory containing the *10x Genomics* Visium HD output.
dataset_id
Unique identifier of the dataset, used to name the elements of the `SpatialData` object. If `None`, it tries to
infer it from the file name of the feature slice file.
Unique identifier of the dataset, used to name the elements of the `SpatialData` object. If `None`, it is
inferred from the file name of the feature slice file.
filtered_counts_file
It sets the value of `counts_file` to ``{vx.FILTERED_COUNTS_FILE!r}`` (when `True`) or to
``{vx.RAW_COUNTS_FILE!r}`` (when `False`).
Expand Down Expand Up @@ -105,6 +105,9 @@ def visium_hd(
Keyword arguments for :func:`imageio.imread`.
image_models_kwargs
Keyword arguments for :class:`spatialdata.models.Image2DModel`.
The ``scale_factors`` key, when provided, overrides the scale factors used to downscale the full-resolution
image (default: ``[2, 2, 2, 2]``). The low-resolution images (i.e. "lowres", "hires", and "CytAssist")
ignore ``scale_factors`` and are always stored as single-scale images (:class:`xarray.DataArray`).
anndata_kwargs
Keyword arguments for :func:`anndata.io.read_h5ad`.

Expand All @@ -118,6 +121,9 @@ def visium_hd(
shapes = {}
images: dict[str, Any] = {}
labels: dict[str, Any] = {}
DEFAULT_FULLRES_SCALEFACTORS = [2, 2, 2, 2]
_scale_factors_override: list[int] | None = image_models_kwargs.get("scale_factors", None)
_image_models_kwargs = {k: v for k, v in image_models_kwargs.items() if k != "scale_factors"}

# Deprecation warning for load_segmentations_only default value
if load_segmentations_only is None:
Expand Down Expand Up @@ -167,7 +173,7 @@ def load_image(path: Path, suffix: str, scale_factors: list[int] | None = None)
suffix=suffix,
dataset_id=dataset_id,
imread_kwargs=imread_kwargs,
image_models_kwargs=image_models_kwargs,
image_models_kwargs=_image_models_kwargs,
scale_factors=scale_factors,
)

Expand Down Expand Up @@ -427,7 +433,9 @@ def _get_bins(path_bins: Path) -> list[str]:
load_image(
path=Path(fullres_image_file),
suffix="_full_image",
scale_factors=[2, 2, 2, 2],
scale_factors=_scale_factors_override
if _scale_factors_override is not None
else DEFAULT_FULLRES_SCALEFACTORS,
)
else:
warnings.warn(
Expand Down
Loading