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
def loop(X, func, n_jobs=-1, *args, **kwargs): | |
""""will apply func(x, *args) for x in X in parallel""" | |
from joblib import Parallel, delayed, cpu_count | |
max_jobs = cpu_count() | |
n_jobs = max_jobs if n_jobs==-1 else n_jobs | |
n_jobs = max_jobs if n_jobs>max_jobs else n_jobs | |
n_jobs = min(n_jobs, len(X)) | |
parallel = Parallel(n_jobs=n_jobs) | |
p_func = delayed(_loop) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 mayavi import mlab | |
import numpy as np | |
import mne | |
from mne.datasets import sample | |
from mne.minimum_norm import make_inverse_operator, apply_inverse | |
mne.set_log_level(False) | |
data_path = sample.data_path() | |
subjects_dir = data_path + '/subjects' | |
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif' | |
raw = mne.io.read_raw_fif(raw_fname) # already has an average reference |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.pipeline import make_pipeline | |
from sklearn.model_selection import StratifiedKFold | |
from mne.decoding import SlidingEstimator | |
# Generate random, fake MEG data |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
%matplotlib inline | |
import mne | |
import matplotlib.pyplot as plt # library for plotting | |
import numpy as np # library for matrix operations | |
# Generate random, fake MEG data | |
n_trials, n_channels, n_times, sfreq = 100, 32, 50, 500. | |
conditions = np.random.randint(0, 2, n_trials) | |
info = mne.create_info(n_channels, sfreq) | |
data = np.random.randn(n_trials, n_channels, n_times) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.