brainglobe / brainrender-napari

A napari plugin to render BrainGlobe atlases and associated data as layers.
BSD 3-Clause "New" or "Revised" License
19 stars 1 forks source link

Ideas for the integration of BrainGlobe atlases within napari #1

Open adamltyson opened 1 year ago

adamltyson commented 1 year ago

Currently BrainGlobe atlases are used by napari plugins (e.g. brainreg, brainreg-segment), but these are not accessible by napari plugins directly (only by using bg-atlasapi in the plugin code). It would be useful to be able to load, visualise and manipulate these atlases for many reasons, e.g.:

As a first pass, my idea is to create a napari plugin that will include some of the functionality of the brainglobe atlas API and CLI, including:

bg-atlasapi represents atlases as an abstract object. It would also be useful to do the same within napari. i.e. represent all the information within an atlas object as a "thing". It won't be a new layer type, but as close to this as possible (layer group?).

A sketch of my idea: brainglobe-napari-sketch

cc @alessandrofelder @dstansby

alessandrofelder commented 1 year ago

What should this napari plugin be called? BrainGlobe-Atlas-Viewer? BrainGlobe-Atlas-Manager?

adamltyson commented 1 year ago

I like BrainGlobe-Atlas-Viewer. It could live in this repo though, and pip install brainglobe-napari would install a number of related plugins.

alessandrofelder commented 1 year ago

The Layer group PR to Napari has not been merged yet. LayerList cannot fulfil the functionality we need (it's not a Layer, and therefore we can't have nested LayerLists).

A possible temporary approach would be to encapsulate the conversion from BG atlas api Atlases to our napari atlas type in just one place, so we can easily change how this is done later? For now, this would just add appropriate layers for each of the images and meshes to napari?

adamltyson commented 1 year ago

A possible temporary approach would be to encapsulate the conversion from BG atlas api Atlases to our napari atlas type in just one place, so we can easily change how this is done later? For now, this would just add appropriate layers for each of the images and meshes to napari?

Yeah I think so, unless there's something we can do to help push the layer group PR forwards.

adamltyson commented 1 year ago

FYI for loading meshes into napari - https://github.com/GenevieveBuckley/napari-meshio

alessandrofelder commented 1 year ago

@adamltyson what are your thoughts on when/how users can add meshes as napari surface layers? Naive possibilities are:

  1. add all meshes as layers by default (but that can be slow and lots of layers can be unwieldy in napari (although having nested layers would help a bit)! Initial experiments suggest even slower if we want to colour the meshes by their level in the hierarchy)
  2. only add the root mesh, and have some widgets (a drop down? maybe a search field?) that allow you to add specific meshes you care about?
  3. have a slider with the level of granularity you want to add meshes for. I.e. if the slider is on 3, you add all meshes that are grandchildren of the root mesh (either via the add to viewer button or a separate add meshes button)?
adamltyson commented 1 year ago

I'm leaning towards 2. It could be a tree like structure with checkboxes. I think this is what the brainrender GUI uses.

adamltyson commented 1 year ago

I'm also not sure 3. would be much use to people. I can see instances when it might be helpful to visualise a sub-sub division of area A along with the whole of area B.