Some issues when using pysurfer wrapper in mne and some additional questions

Hi all!

  • MNE-Python version: 0.23.0
  • operating system: MacOS Sierra 10.12.6

Iā€™m carrying over discussion from this github issue. In that discussion you can find the envrionment.yml I used to set up MNE and its included pysurfer dependency.

I would ideally like to learn how to re-create some of the classic pysurfer examples which I have found myself using quite frequently. Iā€™m on a new machine and the machine didnā€™t like playing with pysurfer on its own, but responded much better when using the pyvista backend through mne (which made me so happy!).

My questions are the following:

(1) Iā€™m having colorbar placement issues when using mne to plot surface data.

Code is below where L and R are np.arrays of length 40962. Surf = ā€˜5_infaltedā€™ is a custom inflation of the fsaverage6 brain that I have placed in the freesurfer directory where we would find the pial and the other inflations.

Brain = mne.viz.get_brain_class()
brain = Brain('fsaverage6', hemi='split', surf='5_inflated',
              subjects_dir=subjects_dir, size=(800, 800),views=['lat', 'med'],background='white',show_toolbar=True)

brain.add_data(L ,fmin=L_min, fmax=L_max, thresh=None, colormap='hot', alpha=1, 
               time=None, colorbar=True, hemi='lh',  fmid=None, center=None, transparent=False, verbose=None)

brain.add_data(R ,fmin=R_min, fmax=R_max, thresh=None,colormap='hot', alpha=1, 
               time=None, colorbar=True, hemi='rh',  fmid=None, center=None, transparent=False, 
               verbose=None,vector_alpha=1,vertices=R_verts)

Picture below:

As you can tell the colorbars arenā€™t aligning properly. If you notice I also set show_toolbar = True but I donā€™t see a toolbar in the pyvista window.

(2) I would like to be able to plot MNI coordinates into any inflated brain (not just necessarily a pial brain).

I find it useful to map MNI coordinates from other papers and visualize them on my inflated brain to find similarities in activation that are harder to imagine when we are working with a volume or a much more folded brain like pial.

For example, I would have expected the pysurfer wrapper for brain.add_foci to work as it does in this example.

But when I use:

seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface=None, hemi='lh')

I get this:

Out of curiosity, would it be possible to create a text label that hovers right above a foci?

(3) I would also like to be able to use custom RGB values on a surface brain as is possible in this example.

Thank you so much in advance!

Also, is there a work-around to using threshold such that I donā€™t have to use the fmin argument which ultimately affects the colormap displayed? I guess the easiest way would be to choose which vertices to plot with vertices = thresholded_verts

[edit], easiest work-around is actually just setting things to nan after some threshold like L[L<threshold_value] = np.nan

Hello @rmasiso and welcome to the forum!

Iā€™m tagging @GuillaumeFavelier who might have some ideas here!