File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 41
41
_get_cs_contents ,
42
42
_get_extent ,
43
43
_maybe_set_colors ,
44
+ _multiscale_to_image ,
44
45
_prepare_cmap_norm ,
45
46
_prepare_params_plot ,
46
47
_set_outline ,
@@ -504,6 +505,9 @@ def show(
504
505
if len (render_cmds .keys ()) == 0 :
505
506
raise TypeError ("Please specify what to plot using the 'render_*' functions before calling 'imshow()." )
506
507
508
+ # Simplicstic solution: If the images are multiscale, just use the first
509
+ sdata = _multiscale_to_image (sdata )
510
+
507
511
# transform all elements
508
512
for cmd , _ in render_cmds .items ():
509
513
if cmd == "render_images" or cmd == "render_channels" :
Original file line number Diff line number Diff line change @@ -347,7 +347,7 @@ class LabelsRenderParams:
347
347
layer : str | None = None
348
348
palette : Palette_t = None
349
349
outline_alpha : float = 1.0
350
- fill_alpha : float = 0.3
350
+ fill_alpha : float = 0.4
351
351
352
352
353
353
def _render_labels (
Original file line number Diff line number Diff line change 10
10
from typing import Any , Literal , Optional , Union
11
11
12
12
import matplotlib .pyplot as plt
13
+ import multiscale_spatial_image as msi
13
14
import numpy as np
14
15
import pandas as pd
15
16
import spatialdata as sd
36
37
from skimage .util import map_array
37
38
from spatialdata ._logging import logger as logging
38
39
from spatialdata ._types import ArrayLike
40
+ from spatialdata .models import (
41
+ Image2DModel ,
42
+ )
39
43
40
44
from spatialdata_plot .pp .utils import _get_coordinate_system_mapping
41
45
@@ -903,3 +907,14 @@ def _get_cs_element_map(
903
907
# model = get_model(element_map["blobs_labels"])
904
908
# if model in [Image2DModel, Image3DModel, Labels2DModel, Labels3DModel]
905
909
return d
910
+
911
+
912
+ def _multiscale_to_image (sdata : sd .SpatialData ) -> sd .SpatialData :
913
+ if sdata .images is None :
914
+ raise ValueError ("No images found in the SpatialData object." )
915
+
916
+ for k , v in sdata .images .items ():
917
+ if isinstance (v , msi .multiscale_spatial_image .MultiscaleSpatialImage ):
918
+ sdata .images [k ] = Image2DModel .parse (v ["scale0" ].ds .to_array ().squeeze (axis = 0 ))
919
+
920
+ return sdata
You can’t perform that action at this time.
0 commit comments