Created
November 12, 2015 08:52
-
-
Save pravsripad/35c660f5205341745286 to your computer and use it in GitHub Desktop.
Source space observations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Load a surface and visualize it using Mayavi. | |
''' | |
import mne | |
from mayavi import mlab | |
# The surfaces are usually located in $SUBJECTS_DIR/$SUBJECT/surf/* | |
# plot the inflated surface | |
# the read_surface returns points and triangle surfaces | |
inflated_points, inflated_tri = mne.read_surface('./surf/lh.inflated') | |
f = mlab.figure(figure='Inflated', bgcolor=(.05, 0, .1), size=(600, 600)) | |
mlab.clf() | |
inflated_surf = mlab.triangular_mesh(inflated_points[:, 0], | |
inflated_points[:, 1], inflated_points[:, 2], | |
inflated_tri, color=(0.7,) * 3, opacity=1.) | |
# plot the white matter surface | |
white_points, white_tri = mne.read_surface('./surf/lh.white') | |
f = mlab.figure(figure='White', bgcolor=(.05, 0, .1), size=(600, 600)) | |
mlab.clf() | |
white_surf = mlab.triangular_mesh(white_points[:, 0], white_points[:, 1], | |
white_points[:, 2], white_tri, color=(0.7,) * 3, opacity=1.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Function to plot the source space on a glass brain. | |
''' | |
import numpy as np | |
import mne | |
# load the source space | |
# usually located in $SUBJECTS_DIR/$SUBJECT/bem/*-src.fif | |
src = mne.read_source_spaces('/data/megraid21/sripad/ldaep01_resting_state_analysis/205726/bem/205726-ico-4-src.fif') | |
# Show 3D visualization of the source space | |
# read the coordinates of the points | |
lh_points = src[0]['rr'] | |
rh_points = src[1]['rr'] | |
points = np.r_[lh_points, rh_points] | |
# coordinats of normals (for later field calculations) | |
# not used here | |
lh_normals = src[0]['nn'] | |
rh_normals = src[1]['nn'] | |
normals = np.r_[lh_normals, rh_normals] | |
# read the triangular meshes | |
use_lh_faces = src[0]['tris'] | |
use_rh_faces = src[1]['tris'] | |
use_faces = np.r_[use_lh_faces, lh_points.shape[0] + use_rh_faces] | |
points *= 170 | |
from mayavi import mlab | |
f = mlab.figure(figure='source_space', bgcolor=(.05, 0, .1), size=(600, 600)) | |
mlab.clf() | |
# the opacity can be changed accordingly | |
import warnings | |
with warnings.catch_warnings(record=True): | |
surface = mlab.triangular_mesh(points[:, 0], points[:, 1], points[:, 2], | |
use_faces, color=(0.7,) * 3, opacity=1.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment