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

[BUG] Cell density (still) not working properly #293

Closed GuillaumeLeGoc closed 9 months ago

GuillaumeLeGoc commented 9 months ago

Describe the bug PointsDensity does not display the density at the right place.

To Reproduce Add non-symmetrical cells to a scene, then display the density with PointsDensity. The density mesh is off.

Expected behaviour Density is shown at the proper place, that is, where the cells are.

Screenshots With my data : Capture2

With the provided cell_density example : Capture

Computer used (please complete the following information):

Additional context Hey, First I wanted to congratulate you for the mega-fix patch which looked like a pain but you manage and it seems to work (mostly). I freshly installed it in a new environment with Python 3.11 and it installed without complaining. But it seems that the weird/black-magic/ununderstood bug in the coordinates with vedo's PointsDensity is still here (although better than before). I added cells to a scene (allen_mouse_10um) and a density with the following :

from brainrender import Scene
from brainrender.actors import Points, PointsDensity

scene = Scene()
scene.add(Points(coordinates, name="Boutons", colors="green", alpha=0.2, radius=5))
scene.add(PointsDensity(coordinates, dims=10))

Cells are displayed properly but the density seems to be mirrored in the left/right direction (see first screenshot above).

Then I tried the provided cell_density.py example, and that one seemed to work. But I noticed that randomly-generated cells are symmetrical, so I tried removing cells from one side :

condition = coordinates[:, 2] < 5066
coordinates = coordinates[~condition]

scene.add(Points(coordinates, name="CELLS", colors="salmon"))
scene.add(PointsDensity(coordinates))

Again, the density is off, it seems mirrored in some way -- see second screenshot above. I know it is a known bug that was not well understood and that you/we hoped to have fixed with latest vedo. But it seems there is still something weird hapenning with the coordinates in PointsDensity. Notice that now, the density is not completely off, eg. it's in the brain but still has a problem... See : https://github.com/brainglobe/brainrender/issues/261, https://github.com/brainglobe/brainrender/issues/243, https://github.com/brainglobe/brainrender/issues/217

alessandrofelder commented 9 months ago

Thanks a lot for this detailed description @GuillaumeLeGoc - It may well help to figure out the deeper problem :crossed_fingers: I'll have a look.

GuillaumeLeGoc commented 9 months ago

You're very welcome. Let me know if I can help.

GuillaumeLeGoc commented 9 months ago

Hey, Just wanted to confirm that the fix #296 works for me 😄