Beispiel #1
0
        callbacks=([checkpointer] if checkpointer is not None else []))


### script start
# _compX, _compY = separateXY(readall_comp_epochs('data/competition/epoched/ica'))
_compX, _compY = epoch_comp(prep_comp(load_comp(True),
                                      comp_channel_map3,
                                      GOODS,
                                      l_freq=LO_FREQ,
                                      h_freq=HI_FREQ),
                            CLASSES,
                            resample=RESAMPLE,
                            trange=T_RANGE)
# _pilotX, _pilotY = epoch_pilot(loadall_pilot(True), CLASSES, GOODS, resample=RESAMPLE, trange=T_RANGE, l_freq=LO_FREQ, h_freq=HI_FREQ)
_pilotX, _pilotY = epoch_pilot(
    load_pilot('data/rivet/raw/pilot2/BCI_imaginedmoves_3class_7-4-21.vhdr'),
    CLASSES,
    GOODS,
    resample=RESAMPLE,
    trange=T_RANGE,
    l_freq=LO_FREQ,
    h_freq=HI_FREQ)

_compX, _compY = stratify(_compX, _compY, FOLDS)

print(_compX.shape)
print(_pilotX.shape)
if (_compX.shape[2] > _pilotX.shape[2]):
    _compX = _compX[:, :, :_pilotX.shape[2]]
elif (_compX.shape[2] < _pilotX.shape[2]):
    _pilotX = _pilotX[:, :, :_compX.shape[2]]
Beispiel #2
0
import numpy as np
from threading import Thread
from time import sleep
from mne import create_info
from mne.io import RawArray
from integration import game_connect, game_disconnect, lsl_connect, lsl_disconnect, get_model, CHANNELS, LO_FREQ, HI_FREQ, GOODS
from preparation import filter_channels
import PySimpleGUI as sg
from tkinter.filedialog import askopenfilenames
from collections import deque

#############################################################
### START debug stuff
from preparation import load_pilot, loadall_pilot
from mne import Epochs, events_from_annotations, pick_types
debug_pilot = load_pilot('data/rivet/raw/jordan/pilot1.vhdr')
# debug_pilot = load_pilot('data/rivet/raw/pilot3/BCITEST29-4.vhdr')
events, event_id = events_from_annotations(debug_pilot,
                                           event_id={
                                               'Stimulus/left': 0,
                                               'Stimulus/right': 1,
                                               'Stimulus/feet': 2
                                           })
picks = pick_types(debug_pilot.info,
                   meg=False,
                   eeg=True,
                   stim=False,
                   eog=False)
epochs = Epochs(debug_pilot,
                events,
                event_id,
Beispiel #3
0

## local functions
def train(model, train, validation, weight_file=None, epochs=300):
  checkpointer = ModelCheckpoint(filepath=weight_file, verbose=1, save_best_only=True) if weight_file is not None else None

  return model.fit(train['x'], train['y'], batch_size=32, epochs=epochs, verbose=0, 
                   validation_data=(validation['x'], validation['y']), callbacks=([checkpointer] if checkpointer is not None else []))

def prepare_and_test(model, data, targets):
  pass


### script start
# _compX, _compY = epoch_comp(prep_comp(load_comp(True), comp_channel_map3, l_freq=LO_FREQ, h_freq=HI_FREQ), CLASSES, GOODS, resample=RESAMPLE, trange=T_RANGE)
_pilotX1, _pilotY1 = epoch_pilot(load_pilot('data/rivet/raw/rory_pilot/RIVET_BCI_PILOT1.vhdr'), CLASSES, GOODS, resample=RESAMPLE, trange=T_RANGE, l_freq=LO_FREQ, h_freq=HI_FREQ)
_pilotX2, _pilotY2 = epoch_pilot(load_pilot('data/rivet/raw/rory_pilot/RIVET_BCI_PILOT1.vhdr'), CLASSES, GOODS, resample=None, trange=[-1.5, 2.5], l_freq=None, h_freq=None)

# """
# rory data - dicard first 50 epochs because noisy
# """
# _pilotX = _pilotX[200:]
# _pilotY = _pilotY[200:]
# _compX, _compY = stratify(_compX, _compY, FOLDS)

# print(_compX.shape)
# print(_pilotX.shape)
# if (_compX.shape[2] > _pilotX.shape[2]):
#   _compX = _compX[:,:,:_pilotX.shape[2]]
# elif (_compX.shape[2] < _pilotX.shape[2]):
#   _pilotX = _pilotX[:,:,:_compX.shape[2]]
Beispiel #4
0
REPEATS = 10
GOODS = ['FC3','C3','CP3','Fz','Cz','POz','FC4','C4','CP4']
T_RANGE = [0.5, 2.5]
RESAMPLE = 125
KERNELS = 1
EPOCHS = 200
TRANSFER_EPOCHS = 300
LO_FREQ = 2.
HI_FREQ = 32.
WEIGHT_PATH = f"weights"
CONFIDENCE = 0.66


### script start
# _compX, _compY = epoch_comp(prep_comp(load_comp(True), comp_channel_map3, GOODS, l_freq=LO_FREQ, h_freq=HI_FREQ), CLASSES, resample=RESAMPLE, trange=T_RANGE)
_pilotX, _pilotY = epoch_pilot(load_pilot('data/rivet/raw/pilot2/BCI_imaginedmoves_3class_7-4-21.vhdr'), CLASSES, GOODS, resample=RESAMPLE, trange=T_RANGE, l_freq=LO_FREQ, h_freq=HI_FREQ)

from mne import pick_types, Epochs, events_from_annotations, create_info
from mne.io import RawArray
from integration import stream_channels, GOODS
debug_pilot = load_pilot('data/rivet/raw/pilot2/BCI_imaginedmoves_3class_7-4-21.vhdr')
events, event_id = events_from_annotations(debug_pilot, event_id={'Stimulus/left': 0, 'Stimulus/right': 1, 'Stimulus/feet': 2})
picks = pick_types(debug_pilot.info, meg=False, eeg=True, stim=False, eog=False)
epochs = Epochs(debug_pilot, events, event_id, proj=False, picks=picks, baseline=None, preload=True, verbose=False, tmin=-1.5, tmax=2.5)
debug_data = epochs.get_data()
debug_data = debug_data[:,:,:-1]

# print(_pilotX[0].shape)
# print(debug_data[0].shape)
# print(debug_data[0])
# print()
Beispiel #5
0
        filepath=weight_file, verbose=1,
        save_best_only=True) if weight_file is not None else None

    return model.fit(
        train['x'],
        train['y'],
        batch_size=32,
        epochs=epochs,
        verbose=0,
        validation_data=(validation['x'], validation['y']),
        callbacks=([checkpointer] if checkpointer is not None else []))


### script start
# _compX, _compY = epoch_comp(prep_comp(load_comp(True), comp_channel_map3, l_freq=LO_FREQ, h_freq=HI_FREQ), CLASSES, GOODS, resample=RESAMPLE, trange=T_RANGE)
_pilotX, _pilotY = epoch_pilot(load_pilot('data/rivet/raw/jordan/pilot1.vhdr'),
                               CLASSES,
                               GOODS,
                               resample=RESAMPLE,
                               trange=T_RANGE,
                               l_freq=LO_FREQ,
                               h_freq=HI_FREQ)

# """
# rory data - dicard first 50 epochs because noisy
# """
# _pilotX = _pilotX[200:]
# _pilotY = _pilotY[200:]
# _compX, _compY = stratify(_compX, _compY, FOLDS)

# print(_compX.shape)