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
# License: simplified BSD (3 clause) | |
# Author: Denis-Alexander Engemann <denis.engemann@gmail.com> | |
class MNERunRime(object): | |
def __init__(self, config, paths, subjects, run_id=None): | |
"""Initialize the MNE environment for running scripts | |
Parameters | |
---------- |
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
# Author: denis.engemann@gmail.com | |
# License: simplified BSD (3 clause) | |
# Note: code is based on scipy.stats.pearsonr | |
from scipy import stats | |
def compute_corr(x, y): | |
x = np.asarray(x) | |
y = np.asarray(y) | |
mx = x.mean(axis=-1) | |
my = y.mean(axis=-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 | |
# License: simplified BSD (3 clause) | |
# Author: Denis A. Engemann <denis.engemann@gmail.com> | |
""" | |
Simple wrapper around GNU parallel | |
---------------------------------- | |
Use this script to dispatch distributed processes and | |
Take care of n_jobs for child process. |
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
""" | |
======================================================== | |
Extract epochs, average and save evoked response to disk | |
======================================================== | |
This script shows how to read the epochs from a raw file given | |
a list of events. The epochs are averaged to produce evoked | |
data and then saved to disk. | |
""" |
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 | |
import mne | |
from mne.decoding import GeneralizationAcrossTime as GAT | |
from sklearn.metrics import roc_auc_score | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.svm import SVC | |
from sklearn.pipeline import make_pipeline | |
from sklearn.cross_validation import StratifiedKFold | |
from meeg_preprocessing.utils import setup_provenance |
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
# Authors: Denis A. Engemann <denis.engemann@gmail.com> | |
# | |
# License: simplified BSD 3 clause | |
from sklearn.cross_validation import StratifiedKFold | |
def repeated_folds(y, n_folds, n_repeats, seeds): | |
use_seeds = seeds[:n_repeats] | |
cv = [list( # resample |
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 mne.report import Report | |
from mne.datasets import sample | |
from mne import read_evokeds | |
report = Report(verbose=True) | |
path = sample.data_path() | |
fname = path + '/MEG/sample/sample_audvis-ave.fif' | |
evoked = read_evokeds(fname, condition='Left Auditory', baseline=(None, 0), | |
verbose=True) | |
fig = evoked.plot() |
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
# Authors: Denis Engemann <denis.engemann@gmail.com> | |
# | |
# License: Simplified BSD | |
def _apply_inverse_epochs_morph(epochs, inverse_operator, lambda2, method, | |
subjects_dir, morph_params, pick_ori, | |
subject_to): | |
"""Helper to compute stc and morph them to another subject""" | |
stcs = apply_inverse_epochs( |
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
# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> | |
# Denis Engemann <denis.engemann@gmail.com> | |
# | |
# License: BSD (3-clause) | |
import os.path as op | |
from nose.tools import assert_true, assert_equal | |
from numpy.testing import assert_array_almost_equal, assert_array_equal | |
from nose.tools import assert_raises |
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 scipy.stats import zscore | |
import mne | |
from mne.fixes import nanmean | |
from mne.utils import logger | |
def detect_bad_channels(raw, picks=None, thresh=3): | |
"""Detect bad channels | |
""" |