@@ -61,13 +61,13 @@ def steinbock(
61
61
"They will be ignored."
62
62
)
63
63
for sample in samples :
64
- images [sample ] = _get_images (
64
+ images [f" { sample } _image" ] = _get_images (
65
65
path ,
66
66
sample ,
67
67
imread_kwargs ,
68
68
image_models_kwargs ,
69
69
)
70
- labels [sample ] = _get_labels (
70
+ labels [f" { sample } _labels" ] = _get_labels (
71
71
path ,
72
72
sample ,
73
73
labels_kind ,
@@ -78,10 +78,11 @@ def steinbock(
78
78
adata = ad .read (path / SteinbockKeys .CELLS_FILE )
79
79
idx = adata .obs .index .str .split (" " ).map (lambda x : int (x [1 ]))
80
80
regions = adata .obs .image .str .replace (".tiff" , "" , regex = False )
81
- regions = regions .apply (lambda x : f"/labels/ { x } " )
81
+ regions = regions .apply (lambda x : f"{ x } _labels " )
82
82
adata .obs ["cell_id" ] = idx
83
83
adata .obs ["region" ] = regions
84
- if len ({f"/labels/{ s } " for s in samples }.difference (set (regions .unique ()))):
84
+ adata .obsm ["spatial" ] = adata .obs [["centroid-0" , "centroid-1" ]].to_numpy ()
85
+ if len ({f"{ s } _labels" for s in samples }.difference (set (regions .unique ()))):
85
86
raise ValueError ("Samples in table and images are inconsistent, please check." )
86
87
table = TableModel .parse (adata , region = regions .unique ().tolist (), region_key = "region" , instance_key = "cell_id" )
87
88
@@ -95,7 +96,7 @@ def _get_images(
95
96
image_models_kwargs : Mapping [str , Any ] = MappingProxyType ({}),
96
97
) -> Union [SpatialImage , MultiscaleSpatialImage ]:
97
98
image = imread (path / SteinbockKeys .IMAGES_DIR / f"{ sample } { SteinbockKeys .IMAGE_SUFFIX } " , ** imread_kwargs )
98
- return Image2DModel .parse (image , transformations = {sample : Identity ()}, ** image_models_kwargs )
99
+ return Image2DModel .parse (data = image , transformations = {sample : Identity ()}, ** image_models_kwargs )
99
100
100
101
101
102
def _get_labels (
@@ -106,4 +107,4 @@ def _get_labels(
106
107
image_models_kwargs : Mapping [str , Any ] = MappingProxyType ({}),
107
108
) -> Union [SpatialImage , MultiscaleSpatialImage ]:
108
109
image = imread (path / labels_kind / f"{ sample } { SteinbockKeys .LABEL_SUFFIX } " , ** imread_kwargs ).squeeze ()
109
- return Labels2DModel .parse (image , transformations = {sample : Identity ()}, ** image_models_kwargs )
110
+ return Labels2DModel .parse (data = image , transformations = {sample : Identity ()}, ** image_models_kwargs )
0 commit comments