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] Camera settings not applied when rendering scene #360

Closed heike-s closed 3 months ago

heike-s commented 3 months ago

Describe the bug I want to create screenshots using consistent camera settings. I have a number of sets of points I would like to plot onto the mouse Nucleus Accumbens, and to make the images comparable would like to use the same camera settings to take a screenshot for each point set.

I use Shift-C to display the camera settings after adjusting to the angle that I would like to use. I then close the window, set the camera, and render the scene again. However, the brain is not displayed in the angle and orientation that I previously set up, and when checking the coordinates again using Shift-C, it returns coordinates that do not correspond to those that I set up, specifically pos, focal_point, viewup and clipping_range.

To Reproduce `import brainrender as br import vedo, os vedo.settings.default_backend= 'vtk'

br.settings.SHOW_AXES = False br.settings.ROOT_ALPHA = 0

popup_scene = br.Scene(atlas_name='allen_mouse_50um', title='Cluster 0')

front_camera = dict( pos=(-25916.9, 6755.20, 8425.36), focal_point=(6754.35, 5532.25, -5444.33), viewup=(4.47401e-3, -0.995148, 0.0982831), roll=174.709, distance=35514.4, clipping_range=(18770.4, 56677.3), )

popup_scene.add_brain_region('ACB', alpha = 0.1, color = 'grey') popup_scene.render(camera = front_camera, zoom = 5) `

Returned coordinates from Shift-C: ###################################################

Template python code to position this camera:

cam = dict( position=(-26114.1, 5270.48, 8090.03), focal_point=(6587.84, 3849.09, -5688.16), viewup=(-8.83828e-4, -0.994932, 0.100542), roll=174.703, distance=35514.4, clipping_range=(18744.5, 56710.0), ) show(mymeshes, camera=cam) ###################################################

Expected behaviour The camera settings in the camera dictionary should be applied when rendering the scene.

Screenshots Expected plot:

Screenshot 2024-05-29 at 4 20 29 PM

Plot received:

Screenshot 2024-05-29 at 4 20 10 PM

Computer used:

Additional context I have set the following settings at the beginning of my script: br.settings.SHOW_AXES = False br.settings.ROOT_ALPHA = 0 The behavior persists even when not setting these variables. I also tried plotting a single hemisphere, and the behavior persists. It also persists whether I add my points or not, so for simplicity I shared the code without adding the points / points density. It also happens whether or not I use a notebook.

adamltyson commented 3 months ago

Thanks for reporting this @heike-s. It should now be fixed. You can install from github with pip install git+https://github.com/brainglobe/brainrender, but a new version of brainrender should be released with this fix by the end of the week.