nipy / PySurfer

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

Missing example files for split brain view #227

Closed jamalw closed 4 years ago

jamalw commented 6 years ago

I'm trying to use pysurfer to plot brain activations on inflated surfaces. So far, I've been able to get left and right hemisphere plots separately as well as animations. However, whenever I try to plot multiple hemispheres (using Brain(fsaverage, "split",...) as opposed to "lh" or "rh") simultaneously I get the following error:

mri_vol2surf: could not read surface /Applications/freesurfer/subjects/fsaverage/surf/split.white

I've looked everywhere for this file can't seem to find it.

Any help would be greatly apprecaited.

Thanks!

agramfort commented 6 years ago

what version of pysurfer are you using?

it should work with latest version

jamalw commented 6 years ago

I'm using version 0.8.0. What's the latest version and do I just do something like "pip install -U pysurfer" to upgrade?

agramfort commented 6 years ago

see the code of 0.8 if option was already there. Sorry I don't have time to investigate

mwaskom commented 6 years ago

0.8 is the latest version and hemi="split" has been possible since version 0.4.

However there is something strange about the bug report. Calling the Brain constructor should not result in the execution of the mri_vol2surf binary. So I suspect the error is being caused when you are doing something that you are not telling us about.

Can you please provide a complete, reproducible example that causes the error?

jamalw commented 6 years ago

Below is the code I'm using. The line where best_k = ... (this line) is where the error is coming from. The traceback is below the code.

from mayavi import mlab from surfer import Brain, project_volume_data import scipy import matplotlib.pyplot as plt import nibabel as nib

""" Bring up the visualization window. """ mlab.options.backend = 'envisage' view = "lateral" brain = Brain("fsaverage", "split", "inflated", cortex='low_contrast',views=['lat','med'])

""" Get a path to the overlay file. """ reg_file = '/Applications/freesurfer/average/mni152.register.dat' overlay_file = "/Users/jamalw/Desktop/PNI/music_event_structures/best_k_map.nii.gz"

best_k = project_volume_data('best_k_map.nii.gz', 'split', reg_file)


Traceback (most recent call last): File "pysurfer_plot.py", line 25, in best_k = project_volume_data('avg_real_k9_across_songs.nii.gz', 'split', reg_file) File "/Users/jamalw/anaconda3/envs/pysurfer/lib/python2.7/site-packages/surfer/utils.py", line 384, in dec return function(*args, **kwargs) File "/Users/jamalw/anaconda3/envs/pysurfer/lib/python2.7/site-packages/surfer/io.py", line 238, in project_volume_data "with output: \n\n{}".format(stderr))) RuntimeError: mri_vol2surf command failed with output:

MRISread(/Applications/freesurfer/subjects/fsaverage/surf/split.white): could not open file No such file or directory mri_vol2surf: could not read surface /Applications/freesurfer/subjects/fsaverage/surf/split.white No such file or directory

mwaskom commented 6 years ago

project_volume_data doesn't accept "split" as a hemisphere value. What it's doing is calling out to Freesurfer to turn a volumetric image into a vector you can plot in PySurfer. Freesurfer is pretty fundamentally oriented around doing things with one hemisphere at a time.

If you have a split brain visualization, you'll need to iterate over hemispheres for the volume-to-surface conversion.

It sounds like you'll basically want to follow the example here: https://pysurfer.github.io/auto_examples/plot_resting_correlations.html

jamalw commented 6 years ago

Awesome tip! This actually does allow for all 4 views to be plotted. However, it plots them in 4 separate tabs in the mayavi gui. How do I get all four views in a single plot/tab?

Thanks for the help so far!

larsoner commented 4 years ago

However, it plots them in 4 separate tabs in the mayavi gui. How do I get all four views in a single plot/tab?

It sounds like you iterated creating a new Brain object inside the loop. Create a single Brain instance at the beginning with hemi='split', and iterate over calls to add the vol-to-surf data to this single instance.