def run_subject(name): loader = DataManager(name, parameters=parameters_meg) loader.load_epochs(recompute=True) print(f'Done {name}.')
bands = dict(raw=(0.1, 13), delta=(0.1, 3), theta=(3.5, 7.5), alpha=(7.5, 13), lower=(0.1, 7.5)) n_jobs = 48 # %% for name in [ 'MEG_S01', 'MEG_S02', 'MEG_S03', 'MEG_S04', 'MEG_S05', 'MEG_S06', 'MEG_S07', 'MEG_S08', 'MEG_S09', 'MEG_S10' ]: # Load MEG data # name = 'MEG_S02' dm = DataManager(name) dm.load_epochs(recompute=False) # Init cross validation cv = CV_split(dm) cv.reset() # MVPA parameters n_components = 6 # Cross validation # y_pred and y_true will be stored in [labels] labels = [] while cv.is_valid(): # Recursive
parameters_meg = dict( picks='eeg', stim_channel='from_annotations', l_freq=0.1, h_freq=15.0, tmin=-0.2, tmax=1.2, decim=10, detrend=1, reject=dict( eeg=150e-6, # 150 $mu$V ), baseline=None) # %% name = 'EEG_S02' loader = DataManager(name) loader.load_raws() print('Done') # %% raw = loader.raws[0] raw # %% mne.find_events(raw) # %% mne.events_from_annotations(raw) # %%
bands = dict(raw=(0.1, 13), delta=(0.1, 3), theta=(3.5, 7.5), alpha=(7.5, 13), lower=(0.1, 7.5)) n_jobs = 48 # %% for subject in [ 'S01', 'S02', 'S03', 'S04', 'S05', 'S06', 'S07', 'S08', 'S09', 'S10' ]: name_eeg = f'EEG_{subject}' name_meg = f'MEG_{subject}' # Load data dm_eeg = DataManager(name_eeg) dm_eeg.load_epochs(recompute=False) dm_meg = DataManager(name_meg) dm_meg.load_epochs(recompute=False) # Init cross validation cv_eeg = CV_split(dm_eeg) cv_eeg.reset() cv_meg = CV_split(dm_meg) cv_meg.reset() # MVPA parameters n_components = 6 # Cross validation # y_pred and y_true will be stored in [labels]
from sklearn import manifold from tools.data_manager import DataManager from tools.epochs_tools import epochs_get_MVPA_data from tools.figure_toolbox import Drawer # %% drawer = Drawer() events_ID = ['1', '2', '4'] n_components = 6 n_jobs = 48 # %% for name in ['MEG_S02', 'EEG_S02']: # ----------------------------------------------- # Init data manager dm = DataManager(name) # Load epochs dm.load_epochs(recompute=False) # ----------------------------------------------- # Separate epochs epochs_1, epochs_2 = dm.leave_one_session_out(includes=[1, 3, 5], excludes=[2, 4, 6]) # Xdawn enhancemen xdawn = mne.preprocessing.Xdawn(n_components=n_components) # Fit xdawn.fit(epochs_1) # Baseline correction
# %% name = 'MEG_S02' parameters_meg = dict( picks='mag', stim_channel='UPPT001', l_freq=0.1, h_freq=20, # 7, tmin=-0.2, tmax=1.2, decim=12, detrend=1, reject=dict(mag=4e-12, ), baseline=None) dm = DataManager(name, parameters=parameters_meg) dm.load_epochs(recompute=True) # %% epochs_1, epochs_2 = dm.leave_one_session_out(includes=[1, 3, 5], excludes=[2, 4, 6]) def relabel(_epochs): # Relabel _epochs events from 4 to 2 _epochs.events[_epochs.events[:, -1] == 4, -1] = 2 # Remove 4 in event_id pool _epochs.event_id.pop('4') relabel(epochs_1)
plotly.offline.init_notebook_mode(connected=True) plt.style.use('tableau-colorblind10') # %% drawer = Drawer() events_ID = ['1', '2', '4'] n_jobs = 48 # %% name = 'MEG_S02' # for name in [f'MEG_S{j+1:02d}' for j in range(2, 3)]: # ----------------------------------------------- # Init data manager dm = DataManager(name) # Load epochs dm.load_epochs(recompute=False) # ----------------------------------------------- # Separate epochs epochs, epochs_2 = dm.leave_one_session_out(includes=[1, 2, 3, 4, 5, 6, 7], excludes=[0]) epochs = epochs[events_ID] # Xdawn enhancemen xdawn = mne.preprocessing.Xdawn(n_components=12) # Fit xdawn.fit(epochs) # Baseline correction