TNTLFreiburg / braindecode

Outdated, see new https://github.com/braindecode/braindecode
BSD 3-Clause "New" or "Revised" License
322 stars 155 forks source link

How to test cross-subject cropped decoding for multiple subjects. #25

Closed syedumaramin closed 6 years ago

syedumaramin commented 6 years ago

Hi, In the notebook examples given, how can we test cross-subject cropped decoding for multiple subjects when we set 'cuda= True'. Only Train/Validation code is given. Can we get code to test as given for one example subject in cropped decoding like this:

test_set = SignalAndTarget(X[70:], y=y[70:])

model.evaluate(test_set.X, test_set.y)

model.predict(test_set.X)
robintibor commented 6 years ago

No, you should do some code that extracts different subjects for test, for example:

import numpy as np

# 56-65 as test subjects
physionet_paths_test = [mne.datasets.eegbci.load_data(sub_id,[4,8,12,]) for sub_id in range(56,66)]
physionet_paths_test = np.concatenate(physionet_paths_test)
parts_test = [mne.io.read_raw_edf(path, preload=True,stim_channel='auto')
         for path in physionet_paths_test]
raw_test = concatenate_raws(parts_test)

picks_test = mne.pick_types(raw_test.info, meg=False, eeg=True, stim=False, eog=False,
                   exclude='bads')

events_test = mne.find_events(raw_test, shortest_event=0, stim_channel='STI 014')

# Read epochs (train will be done only between 1 and 2s)
# Testing will be done with a running classifier
epoched_test = mne.Epochs(raw_test, events_test, dict(hands=2, feet=3), tmin=1, tmax=4.1, proj=False, picks=picks_test,
                baseline=None, preload=True)