Skip to content

Instantly share code, notes, and snippets.

View GuillaumeFavelier's full-sized avatar

Guillaume Favelier GuillaumeFavelier

View GitHub Profile
@GuillaumeFavelier
GuillaumeFavelier / mne_get_all_data.py
Created May 31, 2022 09:40
Download or update the necessary MNE-Python datasets
# from: https://github.com/mne-tools/mne-python/blob/main/tools/circleci_download.sh
import mne
print(mne.datasets.sample.data_path(update_path=True))
print(mne.datasets.fetch_fsaverage(verbose=True))
print(mne.datasets.spm_face.data_path(update_path=True))
print(mne.datasets.somato.data_path(update_path=True))
print(mne.datasets.eegbci.load_data(1, [3, 6, 10, 14], update_path=True))
print(mne.datasets.eegbci.load_data(2, [3], update_path=True))
print(mne.datasets.eegbci.load_data(3, [3], update_path=True))
print(mne.datasets.eegbci.load_data(4, [3], update_path=True))
@GuillaumeFavelier
GuillaumeFavelier / vtk_check_extension.py
Last active February 9, 2022 17:36
Check OpenGL extension support with VTK
import vtk as _vtk
renderWindow = _vtk.vtkRenderWindow()
renderWindow.SetOffScreenRendering(True)
renderWindow.Render()
extension_name = "_ES3"
if renderWindow.SupportsOpenGL():
caps = renderWindow.ReportCapabilities()
@GuillaumeFavelier
GuillaumeFavelier / pyopengl_check_es3.py
Created February 4, 2022 14:45
Check OpenGL_ES3 support with PyOpenGL
from OpenGL.GL import (glGetIntegerv, glGetStringi, GL_NUM_EXTENSIONS,
GL_EXTENSIONS)
from OpenGL.GLUT import glutInit, glutCreateWindow
glutInit()
wind = glutCreateWindow("Check OpenGL ES3")
num_extensions = glGetIntegerv(GL_NUM_EXTENSIONS, 0)
extensions = list()
for i in range(num_extensions.value):
@GuillaumeFavelier
GuillaumeFavelier / pyvista_raster_demo.py
Last active May 17, 2021 15:29
PyVista demo of rasterization
import numpy as np
import pyvista as pv
from matplotlib.colors import ListedColormap
def add_vertex(plotter, point):
vertex = pv.Sphere(center=point)
plotter.add_mesh(
mesh=vertex,
color='white',
@GuillaumeFavelier
GuillaumeFavelier / pyvista_brain_demo.py
Last active May 17, 2021 13:59
PyVista demo using MNE hemis - "mosaic" effect
import pyvista as pv
import numpy as np
from matplotlib.colors import ListedColormap
plotter = pv.Plotter(
point_smoothing=True,
line_smoothing=True,
polygon_smoothing=True,
)
@GuillaumeFavelier
GuillaumeFavelier / mne_ipyvtk_demo.ipynb
Last active November 23, 2021 13:33
Little tour of MNE features with the ipyvtk backend
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GuillaumeFavelier
GuillaumeFavelier / pyvista_overlay_gpu_compositing.py
Created December 3, 2020 13:53
Demonstration of N overlays on a surface (standard GPU method)
import numpy as np
import pyvista
from pyvista import examples
from matplotlib.colors import ListedColormap
# BEGIN: Inspired by Vispy
# https://github.com/vispy/vispy
_rgb2xyz_norm = np.array([[0.43395276, 0.212671, 0.01775791],
[0.37621941, 0.71516, 0.10947652],
@GuillaumeFavelier
GuillaumeFavelier / example_plot_vector_source_estimates.py
Last active March 26, 2020 16:43
Quick example for plot_vector_source_estimates in mne-python
"""
.. _tut_viz_stcs:
Visualize source time courses
=============================
This tutorial focuses on visualization of stcs.
.. contents:: Table of Contents
:local:
@GuillaumeFavelier
GuillaumeFavelier / pyvista_checkbox_dragon.py
Created January 10, 2020 13:57
Demonstration of PyVista with checkbox button
import pyvista as pv
import numpy as np
from pyvista import examples
mesh = examples.download_dragon()
p = pv.BackgroundPlotter()
# describe the movement
class Animate(object):
@GuillaumeFavelier
GuillaumeFavelier / slider.py
Created January 9, 2020 15:56
Hack for vtkSliderWidget with multiple handles
import pyvista as pv
import vtk
def foo(bar):
pass
def disable_tube(slider):
tr = slider.GetEventTranslator()