Skip to content

Commit f9823d5

Browse files
authored
Merge pull request #303 from scverse/fix/visium_hd_cs
fix visium hd wrong global coordinate system
2 parents 1fba5a6 + 12e1c0b commit f9823d5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/spatialdata_io/readers/visium_hd.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def _get_bins(path_bins: Path) -> list[str]:
379379
affine = Affine(affine_matrix, input_axes=("x", "y"), output_axes=("x", "y"))
380380

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

415415
# we replace the cytassist image with the warped image
416416
images[dataset_id + "_cytassist_image"] = warped
@@ -484,7 +484,13 @@ def _load_image(
484484
), "When the image is not in RGB, the first dimension should be the number of channels."
485485

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

0 commit comments

Comments
 (0)