Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot all masks types in napari #95

Open
1 of 4 tasks
berombau opened this issue Nov 24, 2022 · 4 comments
Open
1 of 4 tasks

Plot all masks types in napari #95

berombau opened this issue Nov 24, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@berombau
Copy link
Member

berombau commented Nov 24, 2022

Currently, a lot of different cell annotation masks are generated and visualized in the notebooks using matplotlib or sq.pl.spatial_segment:

  1. instance mask from the cellpose segmentation step (every cell a unique ID)
  • from which we calculate GeoPandas polygons, do some filtering and can again rasterize to a filtered instance mask
  1. filtered instance mask (every cell a unique ID)
  2. filtered semantic mask annotated by cell cluster after allocation step and clustering (every cell a cluster ID)
  3. filtered semantic mask annotated by a cell type after annotation step (every cell a cell type annotation)

The colors for instance masks and cell clusters should be random using the default colors.
The colors for the cell annotation should come from an upfront defined colormap, so each cell type has a stable color.

napari-spatialdata currently supports visualization of a categorical observation for each cell, but using a colored Points layer.

A napari Labels layer should be created for each mask type and with the correct face_color:

  • instance mask
  • filtered instance mask
  • filtered semantic cluster mask
  • filtered semantic annotation mask
@berombau berombau added the enhancement New feature or request label Nov 24, 2022
@berombau
Copy link
Member Author

fyi, current Points layer in napari-spatialdata, which does show a 'legend' on top using the Points layer. The Labels layer should show a name of the cell cluster or annotation type when hovering using the features or property functionality.

Screenshot 2022-11-24 at 14 20 39

@lopollar
Copy link
Contributor

lopollar commented Dec 1, 2022

To switch fro mask to shapes that you can plot in napari:

coords_for_napari=[]
for i in adatap.obsm['polygons'].geometry.exterior:
if i:
i=i.simplify(tolerance=2)
coords_for_napari.append(np.array(i.coords)[:,[1,0]])

@SilverViking SilverViking self-assigned this Dec 1, 2022
@lopollar
Copy link
Contributor

lopollar commented Dec 1, 2022

viewer = napari.view_image(I, rgb=False)
viewer.add_shapes(coords_for_napari,name='voronoi',shape_type='polygon')

@lopollar
Copy link
Contributor

This issue is resolved for non-spatial data plotting, and can be asked for by Lotte, it will still need some adaptation to work with spatialData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants