mne-tools / mne-gsoc2018-3d

Sandbox for GSoC 2018 3D Viz
BSD 3-Clause "New" or "Revised" License
9 stars 4 forks source link

Brain Mesh #1

Closed OlehKSS closed 6 years ago

OlehKSS commented 6 years ago

Create function for plotting brain mesh. Create example of usage in Jupyter. Use MNE sample data.

Use GSOC-wiki examples as a reference.

OlehKSS commented 6 years ago

@agramfort , @larsoner In the example two helper functions from PuSurfer are used: .utils.mesh_edges and .utils.smoothing_matrix. What should I do about this functions? Should I implement similar functions or should I add PySurfer as mne_g3d dependency? I, personally, don't want to rely on PySurfer, since it will create chain PySurfer -> mayavi -> VTK.

larsoner commented 6 years ago

This functionality also exists in mne, the first by the name mesh_edges, the second as compute_morph_matrix (though you can also use stc.morph if you want, albeit a little bit slower).

This gist should have all the functions you need to get mesh triangulation + color information for each vertex:

https://gist.github.com/larsoner/25fa656c6d6e0b02b56c40a571bfb77c

OlehKSS commented 6 years ago

@larsoner Thanks, mesh_edges is exactly the same, but compute_morph_matrix is a little bit different, one seam to read data as well, unlike PySurfer.utils.smoothing_matrix. By the way, from example data that I have I see that surface of the brain is stored as two hemispheres, is it always the case? Should I create a unified mesh out of two halves or user will provide unified mesh?

larsoner commented 6 years ago

You should be able to use compute_morph_matrix from MNE to avoid the PySurfer dependency.

I wouldn't unify the meshes at all, but instead create two mesh objects in the viz library. They are usually provided separately, have separate vertices, etc.

choldgraf commented 6 years ago

My 2 cents here: I don't know that we need to perfectly recreate the way that pysurfer creates mesh objects etc under the hood. From my perspective the two most important things are:

  1. Is the user-facing API similar enough that it can be unified with the pysurfer API
  2. Is the end-product the same or better than using Mayavi
OlehKSS commented 6 years ago

Ok, as far as I understand compute_morph_matrix will not be required to create a basic mesh

larsoner commented 6 years ago

Correct, to create a basic mesh compute_morph_matrix is not needed.

I am pretty sure we will eventually need a sparse matrix multiplication in JavaScript to upsample low-resolution meshes to the high resolution surface to make data transfer times manageable. This is what compute_morph_matrix provides in Python.