Skip to content

Instantly share code, notes, and snippets.

View larsoner's full-sized avatar

Eric Larson larsoner

View GitHub Profile
# -*- coding: utf-8 -*-
import numpy as np
from numpy.testing import assert_allclose
from scipy import linalg
from scipy.stats import ortho_group
def _multi_corr(x, y, rescale=True):
"""Compute correlations between terms in a rotation-invariant way."""
# -*- coding: utf-8 -*-
"""
Simulate the sample dataset
===========================
Here we use :func:`mne.simulation.simulate_raw` to simulate the sample dataset
and then do source localization on the result.
"""
import os.path as op
# From mne/doc directory:
# make clean; rm -f ~/Desktop/prof.prof && python -m cProfile -o ~/Desktop/prof.prof ~/Desktop/doc.py && snakeviz ~/Desktop/prof.prof # noqa
import os
import sys
os.environ['BUILD_DEV_HTML'] = '1'
os.chdir('/home/larsoner/python/mne-python/doc')
sys.argv = ['sphinx-build', '-D', 'plot_gallery=0', '-b', 'html', '-nWT',
'--keep-going', '-d', '_build/doctrees', '.', '_build/html']
from sphinx import __main__ # noqa
import io
import json
import numpy as np
from expyfun.io import read_hdf5
from expyfun.analyze import decimals_to_binary
# make the blank trigger pulses
fs = 44100.
trig_on_dur = 10e-3
trig_pause_dur = 10e-3
import os
import mne
from mne.datasets import sample
from mne.minimum_norm import apply_inverse, read_inverse_operator
import numpy as np
sample_dir_raw = sample.data_path()
sample_dir = os.path.join(sample_dir_raw, 'MEG', 'sample')
subjects_dir = os.path.join(sample_dir_raw, 'subjects')
fname_evoked = os.path.join(sample_dir, 'sample_audvis-ave.fif')
import mne
from mne.utils import object_diff
from mne.forward.forward import is_fixed_orient, convert_forward_solution
from mne.datasets import sample
data_path = sample.data_path()
fname_fwd = data_path + '/MEG/sample/sample_audvis-meg-oct-6-fwd.fif'
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
fwd = mne.read_forward_solution(fname_fwd)
inv = mne.minimum_norm.read_inverse_operator(fname_inv)
@larsoner
larsoner / sample_mri_pos.py
Created October 7, 2019 14:26
sample_mri_pos.py
# Create a DigMontage for sample in MRI coordinates
import os.path as op
import numpy as np
import nibabel
import mne
from mne.transforms import apply_trans
from mne.io.constants import FIFF
from mne.channels import make_dig_montage, read_custom_montage
@larsoner
larsoner / head.py
Last active November 18, 2019 17:59
import os
import numpy as np
import matplotlib.pyplot as plt
import mne
data_path = mne.datasets.sample.data_path()
# Closes #3987, #4880, #5190, #5472, #6304
# Places where we use _auto/_find_topomap_coords that probably need checking:
#
@larsoner
larsoner / pb.py
Last active December 21, 2019 00:27
import os
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
import mne
from mne.datasets import sample
from mne.decoding import GeneralizingEstimator
# Need cluster_level, time_delaying_ridge
import numpy as np
import matplotlib.pyplot as plt
import mne
data_path = mne.datasets.testing.data_path()
subjects_dir = data_path + '/subjects'
evoked = mne.read_evokeds(
data_path + '/MEG/sample/sample_audvis-ave.fif')[0]
evoked.apply_baseline((None, 0))