Skip to content

Commit 69d77f2

Browse files
authored
Merge branch 'main' into fix/warning
2 parents c9ea9c3 + 19b6cbf commit 69d77f2

8 files changed

Lines changed: 32 additions & 22 deletions

File tree

.github/workflows/prepare_test_data.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Prepare test data
22

33
on:
4+
schedule:
5+
- cron: "0 0 1 * *" # run once a month to prevent artifact expiration
46
workflow_dispatch:
57
# uncomment and adjust the branch name if you need to add new datasets to the artifact
68
# push:
@@ -44,7 +46,7 @@ jobs:
4446
done
4547
4648
- name: Upload artifacts
47-
uses: actions/upload-artifact@v3
49+
uses: actions/upload-artifact@v4
4850
with:
4951
name: data
5052
path: ./data

.github/workflows/test.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,12 @@ jobs:
5353
5454
- name: Download artifact of test data
5555
if: matrix.python == '3.12'
56-
uses: dawidd6/action-download-artifact@v2
56+
uses: dawidd6/action-download-artifact@v9
5757
with:
5858
workflow: prepare_test_data.yaml
5959
name: data
6060
path: ./data
6161

62-
- name: List the data directory
63-
if: matrix.python == '3.12'
64-
run: |
65-
ls -l ./data
66-
pwd
67-
6862
- name: Test
6963
env:
7064
MPLBACKEND: agg

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
[![Tests][badge-tests]][link-tests]
66
[![Documentation][badge-docs]][link-docs]
77
[![DOI](https://zenodo.org/badge/544045123.svg)](https://zenodo.org/badge/latestdoi/544045123)
8+
[![Documentation][badge-pypi]][link-pypi]
9+
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/spatialdata-io/badges/version.svg)](https://anaconda.org/conda-forge/spatialdata-io)
810

911
[badge-tests]: https://github.com/scverse/spatialdata-io/actions/workflows/test.yaml/badge.svg
1012
[link-tests]: https://github.com/scverse/spatialdata-io/actions/workflows/test.yaml
1113
[badge-docs]: https://img.shields.io/readthedocs/spatialdata-io
14+
[badge-pypi]: https://badge.fury.io/py/spatialdata-io.svg
15+
[link-pypi]: https://pypi.org/project/spatialdata-io/
1216

1317
This package contains reader functions to load common spatial omics formats into SpatialData. Currently, we provide support for:
1418

@@ -107,10 +111,10 @@ Marconato, L., Palla, G., Yamauchi, K.A. et al. SpatialData: an open and univers
107111

108112
[scverse-discourse]: https://discourse.scverse.org/
109113
[issue-tracker]: https://github.com/scverse/spatialdata-io/issues
110-
[changelog]: https://spatialdata.scverse.org/projects/io/en/latest/changelog.html
111-
[link-docs]: https://spatialdata.scverse.org/projects/io/en/latest/
112-
[link-api]: https://spatialdata.scverse.org/projects/io/en/latest/api.html
113-
[link-cli]: https://spatialdata.scverse.org/projects/io/en/latest/cli.html
114+
[changelog]: https://spatialdata.scverse.org/projects/io/en/stable/changelog.html
115+
[link-docs]: https://spatialdata.scverse.org/projects/io/en/stable/
116+
[link-api]: https://spatialdata.scverse.org/projects/io/en/stable/api.html
117+
[link-cli]: https://spatialdata.scverse.org/projects/io/en/stable/cli.html
114118
[//]: # "numfocus-fiscal-sponsor-attribution"
115119

116120
spatialdata-io is part of the scverse® project ([website](https://scverse.org), [governance](https://scverse.org/about/roles)) and is fiscally sponsored by [NumFOCUS](https://numfocus.org/).

src/spatialdata_io/__main__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ def macsima_wrapper(
620620
@click.option("--name", "-n", type=str, help="name of the element to be stored")
621621
@click.option(
622622
"--data-axes",
623-
type=click.Choice(["cyx", "czyx"], case_sensitive=False),
624-
help="Axes of the data for image files. Valid values are 'cyx' and 'czyx'.",
623+
type=str,
624+
help="Axes of the data for image files. Valid values are permutations of 'cyx' and 'czyx'.",
625625
)
626626
@click.option(
627627
"--coordinate-system",
@@ -636,7 +636,9 @@ def read_generic_wrapper(
636636
data_axes: str | None = None,
637637
coordinate_system: str | None = None,
638638
) -> None:
639-
"""Read generic data to SpatialData."""
639+
"""Read generic data to SpatialData"""
640+
if data_axes is not None and "".join(sorted(data_axes)) not in ["cxy", "cxyz"]:
641+
raise ValueError("data_axes must be a permutation of 'cyx' or 'czyx'.")
640642
generic_to_zarr(input=input, output=output, name=name, data_axes=data_axes, coordinate_system=coordinate_system)
641643

642644

src/spatialdata_io/converters/generic_to_zarr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ def generic_to_zarr(
6868
)
6969

7070
if output.exists():
71-
sdata = SpatialData.read_zarr(output)
71+
sdata = SpatialData.read(output)
7272
if name in sdata:
7373
raise ValueError(
7474
f"Name {name} already exists in {output}; please provide a different name or delete the "
7575
f"existing element."
7676
)
7777
sdata[name] = element
78-
sdata.write_element(name, element_name=name)
78+
sdata.write_element(element_name=name)
7979
print(f"Element {name} written to {output}")
8080
else:
8181
sdata = SpatialData.init_from_elements(elements={name: element})

src/spatialdata_io/readers/generic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def generic(
5252
-------
5353
Parsed spatial element.
5454
"""
55+
if isinstance(input, str):
56+
input = Path(input)
5557
if coordinate_system is None:
5658
coordinate_system = DEFAULT_COORDINATE_SYSTEM
5759
if input.suffix in VALID_SHAPE_TYPES:

src/spatialdata_io/readers/visium_hd.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def _get_bins(path_bins: Path) -> list[str]:
381381
affine = Affine(affine_matrix, input_axes=("x", "y"), output_axes=("x", "y"))
382382

383383
# determine the size of the transformed image
384-
bounding_box = get_extent(image)
384+
bounding_box = get_extent(image, coordinate_system=dataset_id)
385385
x0, x1 = bounding_box["x"]
386386
y0, y1 = bounding_box["y"]
387387
x1 -= 1
@@ -412,7 +412,7 @@ def _get_bins(path_bins: Path) -> list[str]:
412412
numpy_data, ProjectiveTransform(projective_shift).inverse, output_shape=transformed_shape, order=1
413413
)
414414
warped = np.round(warped * 255).astype(np.uint8)
415-
warped = Image2DModel.parse(warped, dims=("y", "x", "c"), transformations={"global": affine}, rgb=True)
415+
warped = Image2DModel.parse(warped, dims=("y", "x", "c"), transformations={dataset_id: affine}, rgb=True)
416416

417417
# we replace the cytassist image with the warped image
418418
images[dataset_id + "_cytassist_image"] = warped
@@ -466,7 +466,7 @@ def _load_image(
466466
) -> None:
467467
if path.exists():
468468
if path.suffix != ".btf":
469-
data = imread(path, **imread_kwargs)
469+
data = imread(path)
470470
if len(data.shape) == 4:
471471
# this happens for the cytassist, hires and lowres images; the umi image doesn't need processing
472472
data = data.squeeze()
@@ -486,7 +486,13 @@ def _load_image(
486486
)
487487

488488
image = DataArray(data, dims=("c", "y", "x"))
489-
parsed = Image2DModel.parse(image, scale_factors=scale_factors, rgb=None, **image_models_kwargs)
489+
parsed = Image2DModel.parse(
490+
image,
491+
scale_factors=scale_factors,
492+
rgb=None,
493+
transformations={dataset_id: Identity()},
494+
**image_models_kwargs,
495+
)
490496
images[dataset_id + suffix] = parsed
491497
else:
492498
warnings.warn(f"File {path} does not exist, skipping it.", UserWarning, stacklevel=2)

tests/test_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_cli_read_generic_image_invalid_data_axes(runner: CliRunner) -> None:
8787
],
8888
)
8989
assert result.exit_code != 0, result.output
90-
assert "'invalid_axes' is not one of 'cyx', 'czyx'." in result.output
90+
assert "data_axes must be a permutation of 'cyx' or 'czyx'." in result.exc_info[1].args[0]
9191

9292

9393
@pytest.mark.parametrize("cli", [True, False])

0 commit comments

Comments
 (0)