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
import mne | |
data_path = mne.datasets.sample.data_path() | |
sample_data_raw_file = data_path / "MEG" / "sample" / "sample_audvis_raw.fif" | |
subjects_dir = data_path / "subjects" | |
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False).crop(tmax=60) | |
events = mne.find_events(raw, stim_channel="STI 014") | |
epochs = mne.Epochs(raw, events, event_id = {"auditory/left": 1}, tmin=-0.3, tmax=0.7)[:10] | |
inverse_operator_file = data_path / "MEG" / "sample" / "sample_audvis-meg-oct-6-meg-inv.fif" | |
inv_operator = mne.minimum_norm.read_inverse_operator(inverse_operator_file) | |
stcs = mne.minimum_norm.apply_inverse_epochs(epochs, inv_operator, lambda2=1/3, pick_ori=None) |
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
"""BIDSify and trim the KIT phantom data.""" | |
from pathlib import Path | |
import numpy as np | |
from scipy.signal import find_peaks | |
import matplotlib.pyplot as plt | |
import mne | |
import mne_bids | |
from mne.io.constants import FIFF |
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
"""Attempt to build a mne.viz.Brain-like GUI using magicgui.""" | |
from magicgui import widgets, use_app | |
import numpy as np | |
import re | |
import mne | |
from matplotlib.figure import Figure | |
import pyvista | |
import pyvista.plotting |
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
# Check 1-tailed t-test bias when selecting ROIs using different methods | |
import numpy as np | |
from scipy.stats import ttest_ind | |
rng = np.random.default_rng(0) | |
n_subjects = 20 # number of subjects to simulate | |
n_sensors = 100 # number of "sensors" (could be source points, etc.) | |
n_run = 5000 # number of times to simulate (n_subjects, n_sensors) values | |
prop_false = np.zeros((n_run, 3, 2)) # proportion of false alarms |
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
import numpy as np | |
from datetime import datetime | |
from tqdm.auto import tqdm | |
from pytz import timezone | |
from peloton import PelotonWorkout | |
my_tz = timezone('US/Eastern') | |
print('Getting workout list...') | |
workouts = PelotonWorkout.list() |
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
# Minimal script to test the iEEG GUI | |
import os.path as op | |
import numpy as np | |
import nibabel as nib | |
import mne | |
misc_path = mne.datasets.misc.data_path(verbose=True) | |
raw = mne.io.read_raw(op.join(misc_path, 'seeg', 'sample_seeg_ieeg.fif')) | |
subj_trans = mne.coreg.estimate_head_mri_t( | |
'sample_seeg', op.join(misc_path, 'seeg')) |
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
from ctypes import CDLL, c_int, byref | |
import faulthandler | |
import vtk as _vtk | |
faulthandler.enable() | |
renderWindow = _vtk.vtkRenderWindow() | |
logger = _vtk.vtkLogger | |
logger.Init() | |
logger.SetStderrVerbosity(_vtk.vtkLogger.VERBOSITY_MAX) | |
renderWindow.DebugOn() | |
renderWindow.SetOffScreenRendering(True) |
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
import numpy as np | |
from dipy.align import affine_registration, center_of_mass, translation, rigid | |
from dipy.align.imaffine import MutualInformationMetric | |
from dipy.align.transforms import RigidTransform3D | |
import nibabel as nib | |
moving = nib.load('sub-12_CT.nii.gz') | |
static = nib.load('sub-12_T1.mgz') | |
reg_kwargs = dict( |
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
import pyglet | |
player = pyglet.media.Player() | |
source = pyglet.media.StreamingSource() | |
media = pyglet.media.load('example-video.mp4') | |
player.queue(media) | |
player.play() | |
window = pyglet.window.Window() | |
while player.source and player.source.video_format: | |
pyglet.clock.tick(poll=True) | |
window.clear() |
NewerOlder