Last active
December 21, 2019 00:27
-
-
Save larsoner/c56b2521925273094208f33aa1e5cff1 to your computer and use it in GitHub Desktop.
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 | |
| 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 | |
| # All the functions that currently use ProgressBar | |
| try: | |
| os.remove('/tmp/null.part') | |
| except Exception: | |
| pass | |
| # mne.utils._fetch_file('https://github.com/mne-tools/mne-python/archive/v0.19.1.zip', '/tmp/null', verbose=True) | |
| data_path = sample.data_path() | |
| raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif' | |
| events_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif' | |
| raw = mne.io.read_raw_fif(raw_fname, preload=True) | |
| mne.preprocessing.mark_flat(raw, verbose=True) | |
| picks = mne.pick_types(raw.info, meg=True, exclude='bads') # Pick MEG channels | |
| events = mne.read_events(events_fname) | |
| event_id = {'Auditory/Left': 1, 'Auditory/Right': 2, | |
| 'Visual/Left': 3, 'Visual/Right': 4} | |
| epochs = mne.Epochs(raw, events, event_id, picks=picks, preload=True) | |
| clf = make_pipeline(StandardScaler(), LogisticRegression(solver='lbfgs')) | |
| time_gen = GeneralizingEstimator(clf, scoring='roc_auc', n_jobs=2, | |
| verbose=True) | |
| time_gen.fit(X=epochs['Left'].get_data(), | |
| y=epochs['Left'].events[:, 2] > 2) | |
| scores = time_gen.score(X=epochs['Right'].get_data(), | |
| y=epochs['Right'].events[:, 2] > 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment