nipy / PySurfer

Cortical neuroimaging visualization in Python
https://pysurfer.github.io/
BSD 3-Clause "New" or "Revised" License
241 stars 97 forks source link

Using add_overlay on Brain object with both hemispheres #278

Closed mattvan83 closed 4 years ago

mattvan83 commented 4 years ago

Hi,

I would like to use the add_overlay methodology on Brain object with hemi="both" when visualizing both hemispheres in the same time. Specifically, I would like to apply the example below for visualization on both hemispheres:

https://pysurfer.github.io/auto_examples/plot_fmri_conjunction.html#sphx-glr-auto-examples-plot-fmri-conjunction-py

However, I got this error when trying to do so:

Traceback (most recent call last):
  File "./Python/PrepareDataAV45.py", line 1697, in <module>
    main()
  File "./Python/PrepareDataAV45.py", line 1646, in main
    brain.overlays["sig_fdg_lh"].pos_bar.lut_mode = "Blues"
  File "/homes_unix/mvanhoutte/Soft/anaconda3/envs/av45/lib/python3.7/site-packages/surfer/viz.py", line 739, in overlays
    return self._get_one_brain(self.overlays_dict, 'overlays')
  File "/homes_unix/mvanhoutte/Soft/anaconda3/envs/av45/lib/python3.7/site-packages/surfer/viz.py", line 728, in _get_one_brain
    'or brain.brains.' % name)
ValueError: Cannot access brain.overlays when more than one view is plotted. Use brain.brain_matrix or brain.brains.

How could I deal with brain.brain_matrix or brain.brains in order to plot conjunction maps on both hemispheres?

Best, Matthieu

larsoner commented 4 years ago

Can you try using add_data instead? It is probably more robust and flexible.

Perhaps we should deprecate add_overlay, or at least add a note pointing to add_data instead.

mattvan83 commented 4 years ago

Thanks for pointing me to use add_data instead of add_overlay.

However, how could I access with add_data the following attributes as used in conjunction maps with add_overlay:

brain.overlays["sig1"].pos_bar.lut_mode = "Reds"
brain.overlays["sig1"].pos_bar.visible = False
mwaskom commented 4 years ago

You can get related attributes, but you don't need to. One of the ways that add_data is more flexible is that you can specify the color map you want to use and the visibility of the color bar when you call the function, rather than messing around with the mayavi object attributes after using pysurfer.

Actually, even if we don't deprecate add_overlay (there are reasons to keep it around, such that you can point it directly at an image filename), it's probably worth rewriting the conjunction example to use add_data, which would very much be the right way to do it at this point.

mattvan83 commented 4 years ago

Thanks, however I didn't manage to find an equivalent option of add_overlay in add_data:

max : float
    saturation point for overlay display

How could I manage the saturation point in add_data ?

mwaskom commented 4 years ago

add_data also has a max= argument that does the exact same thing, so I may not understand your question.

mattvan83 commented 4 years ago

The max argument doesn't react in the same way in both functions. When fixing a high maximum to 30, output with add_overlay shows deep blue, red or purple colors whereas output with add_data are white (different colorbar).

mwaskom commented 4 years ago

I'm not sure what you mean, can you share the code you're using and the image you're seeing?