nipy / PySurfer

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

ENH: Flatmaps #214

Closed larsoner closed 6 years ago

larsoner commented 6 years ago

I'm interested in doing flatmaps with PySurfer. Has anyone tried this?

A very naive approach did not work:

>>> brain = surfer.Brain('fsaverage', 'lh', 'cortex.patch.flat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/larsoner/custombuilds/PySurfer/surfer/viz.py", line 451, in __init__
    geo.load_geometry()
  File "/home/larsoner/custombuilds/PySurfer/surfer/utils.py", line 126, in load_geometry
    coords, faces = nib.freesurfer.read_geometry(surf_path)
  File "/home/larsoner/miniconda3/envs/mne/lib/python3.6/site-packages/nibabel/freesurfer/io.py", line 128, in read_geometry
    quads = quads.reshape(nquad, 4)
ValueError: cannot reshape array of size 0 into shape (4665600,4)
mwaskom commented 6 years ago

Patch files are a completely different format.

I have a notebook where I got part of the way: https://gist.github.com/mwaskom/fab1970208a5c458869b3d8831fb7788

In general I'd think plotting on flat maps would be better handled by matplotlib than mayavi.

larsoner commented 6 years ago

Patch files are a completely different format.

I'm guessing there is no simple mapping to vertices, then :(

In general I'd think plotting on flat maps would be better handled by matplotlib than mavavi.

Yeah that's true. And then Mayavi wouldn't be a blocker. PySurfer does a ton of stuff (add_data, time steps, videos, etc.) that would be nice to have in both cases. We could consider using a matplotlib backend when using the flat maps, but that would be quite a big degree of added difficulty :)

I probably won't dig into it now, then, since it's not so simple.