This file contains hidden or 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 hidden or 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() |
This file contains hidden or 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 os.path as op | |
import mne | |
from mne import setup_volume_source_space | |
# preamble | |
data_path = mne.datasets.sample.data_path() | |
info = mne.io.read_info(data_path + '/MEG/sample/sample_audvis_raw.fif') | |
subjects_dir = data_path + '/subjects' | |
# copy-pasted code snippets | |
subject = 'fsaverage' | |
volume_label = [ 'Brain-Stem','ctx-lh-superiortemporal','ctx-rh-superiortemporal' ] |
This file contains hidden or 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
"""Hotelling T2 example. | |
Following the notation in | |
https://en.wikipedia.org/wiki/Hotelling%27s_T-squared_distribution#Two-sample_statistic | |
""" | |
import numpy as np | |
from scipy import stats | |
import matplotlib.pyplot as plt |
This file contains hidden or 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 scipy import stats | |
import matplotlib.pyplot as plt | |
rng = np.random.RandomState(0) | |
M, n_sensors = 100, 1000 | |
# Make "Fourier coefficients" here | |
data = rng.randn(M, n_sensors) + rng.randn(M, n_sensors) * 1j | |
data += 0. # can be non-zero to test that it actually works for some signal | |
mean = np.mean(data, axis=0) |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import faulthandler | |
import os.path as op | |
import numpy as np | |
from scipy.signal import welch, coherence, unit_impulse | |
from matplotlib import pyplot as plt | |
import mne | |
from mne.simulation import simulate_raw, add_noise | |
from mne.datasets import sample |
This file contains hidden or 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
# 1. Replicate test | |
# 2. Expand to left and right hemi | |
# 3. Switch to oct-6 | |
import os.path as op | |
import numpy as np | |
from numpy.testing import assert_allclose, assert_array_less | |
import mne | |
from mne.beamformer import make_lcmv, apply_lcmv | |
from mne.io.constants import FIFF |
This file contains hidden or 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
#!/bin/csh -ef | |
# Do recon-all and get flash5 and flash30 files to nii/*.nii: | |
# mcverter --format nifti -ndo . ${THIS_DIR}/DICOM/ | |
# INRAGE=`find . -name "*MEMPRAGE*.nii"` | |
# IN5=`find . -name "*FLASH5*.nii"` | |
# IN30=`find . -name "*FLASH30*.nii"` | |
# OUTNAME="${PWD##*/}" | |
# SUBJ_DIR="$SUBJECTS_DIR/$OUTNAME" | |
# mkdir -p $SUBJ_DIR |
This file contains hidden or 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 time | |
import mne | |
import numpy as np | |
import matplotlib.pyplot as plt | |
raw = mne.io.read_raw_fif( | |
mne.datasets.sample.data_path() + '/MEG/sample/sample_audvis_raw.fif') | |
data, times = raw[:, :] | |
n_points = 1000 | |
norms = np.std(data, axis=-1, keepdims=True) |
This file contains hidden or 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
# Following https://m-clark.github.io/docs/mixedModels/anovamixed.html | |
import numpy as np | |
from scipy import stats | |
from pandas import DataFrame | |
import statsmodels.api as sm | |
from statsmodels.stats import anova | |
import statsmodels.formula.api as smf | |
import pingouin |