brainglobe / brainglobe-heatmap

Rendering anatomical heatmaps with brainrender and matplotlib
https://brainglobe.info
MIT License
34 stars 10 forks source link

KeyError: 'notebookBackend' #7

Closed NataliaFavila closed 2 years ago

NataliaFavila commented 2 years ago

When running the example from heatmap_2D.py: import bgheatmaps as bgh

""" This example shows how to use visualize a heatmap in 2D """

values = dict( # scalar values for each region TH=1, RSP=0.2, AI=0.4, SS=-3, MO=2.6, PVZ=-4, LZ=-3, VIS=2, AUD=0.3, RHP=-0.2, STR=0.5, CB=0.5, FRP=-1.7, HIP=3, PA=-4, )

f = bgh.heatmap( values, position=5000, # when using a named orientation you can pass a single value! orientation="frontal", # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z) title="horizontal view", vmin=-5, vmax=3, format="2D", ).show()

I get the following Error:

File ~/opt/anaconda3/envs/py3.8/lib/python3.8/site-packages/vedo/utils.py:238, in dotdict.getattr(self, k) 237 def getattr(self, k): --> 238 return self[k]

KeyError: 'notebookBackend'

marcomusy commented 2 years ago

The latest vedo version is no more permissive when trying to access a non-existing key in a dotdict (dotted dictionary). You may need to temporarily downgrade to pip install vedo==2022.0.1 unitl it's fixed in brainrender or bg-heatmaps.

FedeClaudi commented 2 years ago

Yes please try that, thank you Marco. The latest vedo is not yet supported on brainglobe

marcomusy commented 2 years ago

A related issue is that you most probably don't want to make any requirements about vtk (let vedo deal with it!):

https://github.com/brainglobe/brainrender/blob/ae92a40c2769f249d8ae7a040a64d43fad949ba0/setup.py#L42

instead you should constrain the vedo version to the one that's tested and works with brainrender, eg:

"vedo>=2021.0.5,<2022.1.0"

in

https://github.com/brainglobe/brainrender/blob/ae92a40c2769f249d8ae7a040a64d43fad949ba0/setup.py#L30

In my case I could not even install brainrender because I have vtk 9.0.3, which should be perfectly fine.. and had pip silently installing an older brainrender and getting the closePlotter() error... and was not obvious to me to figure out why..

FedeClaudi commented 2 years ago

As Marco suggests, the solution is downgrade vedo with pip install vedo==2021.0.5.

Brainrender will only support that version of vedo for the time being.


@marcomusy

I was going to make brainrender compatible with the newest vedo, but I noticed a number of changes. The camera orientation and position was different, the direction corresponding to the normal of planes changed, the position and orientation of the axes changed, how notebooks are handled changed... What's causing all these changes?

In the end I've decided that since I'm not planning to develop brainrender any further I will simply pin it to the last working version of vedo so that there should be these kind of issues in the future. Beyond brainrender vedo is currently not used much by the neuroscientific community (unfortunately) so this shouldn't create problems for users. Thank you for your help!

FedeClaudi commented 2 years ago

And please NataliaFavila let meknow if this helps and how you're getting on with using bg-heatmaps!

marcomusy commented 2 years ago

@FedeClaudi sorry for having caused you troubles :)

I was going to make brainrender compatible with the newest vedo, but I noticed a number of changes. The camera orientation and position was different,

the direction corresponding to the normal of planes changed, the position and orientation of the axes changed,

This is quite strange, I cannot think right now of a good reason why that should have changed..

how notebooks are handled changed...

Yes! indeed that has changed ... but the transition should be reasonably smooth.... if not at all backward compatible..

I will have a go looking at the code, as soon as i can, to see if I understand any of the differences you observe. Thanks for your feedback and patience!

FedeClaudi commented 2 years ago

That's okay! Vedo is amazing and its impressive how much it keeps growing!

If I needed to continue adding new features/developing brainrender I would happily keep up, but since it's fairly complete as a project I'm happy to just pin it to a working version.

For reference, I had to change the sign of the viewup vectors and the position of the cameras, otherwise everyhing was upside/down. I didn't look closely into this so not sure if the camera was off, the origin or if somehow the meshes were shown in some weird orientation. Might be useful for you to figure out but its not a problem at all for brainrender since I'll be using the older vedo.

Once again, thank you so much for all your help. Brainrender wouldn't exist without you! Wish you all the best and great success with vedo

NataliaFavila commented 2 years ago

It worked! thank you very much! :) I created a coda env with python 3.8 and the specified version of vedo and it is running correctly now.

FedeClaudi commented 2 years ago

happy days!