saeyslab / napari-sparrow

Other
17 stars 0 forks source link

View SpatialData object in napari-spatialdata #179

Closed ArneDefauw closed 5 months ago

ArneDefauw commented 5 months ago

This pull request https://github.com/saeyslab/napari-sparrow/pull/178 fixes issue where we could not visualize instances from sdata.table associated with elements from sdata.labels via napari-spatialdata plugin. @Lucas-Maciel

see below for example:

Screenshot 2024-02-26 at 13 34 21
ArneDefauw commented 5 months ago

fixed by https://github.com/saeyslab/napari-sparrow/pull/178

ArneDefauw commented 5 months ago

@berombau @julienmortier It is now also possible to view intensity values or other properties (sdata.table.obs) calculated for certain masks added to sdata.table via e.g:

#optional
sdata = sp.im.align_labels_layers(
    sdata,
    labels_layer_1="masks_nuclear",
    labels_layer_2="masks_whole",
    output_labels_layer="masks_nuclear_aligned",
    output_shapes_layer=None,
    overwrite=True,
    chunks=256,
    depth=100,
)

sdata = sp.tb.allocate_intensity(
    sdata, img_layer="raw_image", labels_layer="masks_whole", chunks=100
)

#optional
sdata = sp.tb.allocate_intensity(
    sdata, img_layer="raw_image", labels_layer="masks_nuclear_aligned", chunks=100, append=True
)

sdata=sp.tb.add_regionprop_features( sdata, labels_layer="masks_whole" )

#optional
sdata=sp.tb.add_regionprop_features( sdata, labels_layer="masks_nuclear_aligned" )

and then in napari:

Screenshot 2024-02-27 at 11 07 10

When there is a new release for spatialdata for multiple tables, we will need to do some code changes