Skip to content

Commit 1b314d8

Browse files
Merge pull request #278 from scverse/coord-system-names
Include dataset id in visium HD reader
2 parents 47c1e1d + abe3d64 commit 1b314d8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/spatialdata_io/readers/visium_hd.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def _get_bins(path_bins: Path) -> list[str]:
242242
shapes_name = dataset_id + "_" + bin_size_str
243243
radius = scalefactors[VisiumHDKeys.SCALEFACTORS_SPOT_DIAMETER_FULLRES] / 2.0
244244
transformations = {
245-
"global": transform_original,
246-
"downscaled_hires": transform_hires,
247-
"downscaled_lowres": transform_lowres,
245+
dataset_id: transform_original,
246+
f"{dataset_id}_downscaled_hires": transform_hires,
247+
f"{dataset_id}_downscaled_lowres": transform_lowres,
248248
}
249249
circles = ShapesModel.parse(
250250
adata.obsm["spatial"],
@@ -322,7 +322,10 @@ def _get_bins(path_bins: Path) -> list[str]:
322322
)
323323
set_transformation(
324324
images[dataset_id + "_hires_image"],
325-
{"downscaled_hires": Identity(), "global": transform_hires.inverse()},
325+
{
326+
f"{dataset_id}_downscaled_hires": Identity(),
327+
dataset_id: transform_hires.inverse(),
328+
},
326329
set_all=True,
327330
)
328331

@@ -340,7 +343,10 @@ def _get_bins(path_bins: Path) -> list[str]:
340343
)
341344
set_transformation(
342345
images[dataset_id + "_lowres_image"],
343-
{"downscaled_lowres": Identity(), "global": transform_lowres.inverse()},
346+
{
347+
f"{dataset_id}_downscaled_lowres": Identity(),
348+
dataset_id: transform_lowres.inverse(),
349+
},
344350
set_all=True,
345351
)
346352

@@ -365,7 +371,7 @@ def _get_bins(path_bins: Path) -> list[str]:
365371
projective /= projective[2, 2]
366372
if _projective_matrix_is_affine(projective):
367373
affine = Affine(projective, input_axes=("x", "y"), output_axes=("x", "y"))
368-
set_transformation(image, affine, "global")
374+
set_transformation(image, affine, dataset_id)
369375
else:
370376
# the projective matrix is not affine, we will separate the affine part and the projective shift, and apply
371377
# the projective shift to the image
@@ -413,7 +419,6 @@ def _get_bins(path_bins: Path) -> list[str]:
413419

414420
if annotate_table_by_labels:
415421
for bin_size_str in bin_sizes:
416-
417422
shapes_name = dataset_id + "_" + bin_size_str
418423

419424
# add labels layer (rasterized bins).

0 commit comments

Comments
 (0)