brainglobe / brainrender

a python based software for visualization of neuroanatomical and morphological data.
https://brainglobe.info/documentation/brainrender/index.html
BSD 3-Clause "New" or "Revised" License
538 stars 75 forks source link

[Feature] Allow user to specify the colormap in cell density #323

Closed GuillaumeLeGoc closed 7 months ago

GuillaumeLeGoc commented 7 months ago

Is your feature request related to a problem? Please describe. The colormap used in cell density is set to "Dark2" : https://github.com/brainglobe/brainrender/blob/980a76fee9796595561f99e760083cafea09f62d/brainrender/actors/points.py#L143

Describe the solution you'd like The PointsDensity class could accept a kwarg cmap=colormap in its constructor. Now, kwargs are passed to vedo's Points.density.

Describe alternatives you've considered PointsDensity returns a vedo Volume, so I tried setting its color after its creation, mimicking what is done in PointsDensity : https://github.com/brainglobe/brainrender/blob/980a76fee9796595561f99e760083cafea09f62d/brainrender/actors/points.py#L140-L145

scene = Scene()
voldensity = PointsDensity(coordinates).cmap("viridis").alpha([0, 0.9]).mode(1)
scene.add(voldensity)

This results in a weird box being plotted next to my brain : vedobox

Modifying the local actors/points.py file with the colormap I want yields the good result.

I don't know if you plan to retire brainrender in favor of the napari plugin in the near future (but the latter don't have the cell density feature out of the box -- yet ? πŸ˜„) but specifying the colormap would be nice. Cheers !

alessandrofelder commented 7 months ago

Interesting :laughing: ! Thanks for your detailed issue description... I'd be happy with adding this feature. Is this something you could/would like to contribute @GuillaumeLeGoc (it sounds like you're almost there anyway)?

I don't know if you plan to retire brainrender in favor of the napari plugin in the near future (but the latter don't have the cell density feature out of the box -- yet ? πŸ˜„)

I am hoping (and it's in our roadmap) that brainrender-napari would match the features of brainrender by this summer, but I presume we'd keep maintaining brainrender for a while after that (Some of the codebase might even be shared in the future and they would exist as alternative frontends for the same thing).

GuillaumeLeGoc commented 7 months ago

I drafted up a PR, navigating in highly unknown waters (tests, pre-commit, ...?). I hope that's ok πŸ˜