Esempio n. 1
0
def get_epochs_and_cov(X, y, window=500):
    """return epochs from array."""
    raw_train = toMNE(X, y)
    picks = range(len(getChannelNames()))

    events = list()
    events_id = dict()
    for j, eid in enumerate(getEventNames()):
        tmp = find_events(raw_train, stim_channel=eid, verbose=False)
        tmp[:, -1] = j + 1
        events.append(tmp)
        events_id[eid] = j + 1

    # concatenate and sort events
    events = np.concatenate(events, axis=0)
    order_ev = np.argsort(events[:, 0])
    events = events[order_ev]

    epochs = Epochs(raw_train,
                    events,
                    events_id,
                    tmin=-(window / 500.0) + 1 / 500.0 + 0.150,
                    tmax=0.150,
                    proj=False,
                    picks=picks,
                    baseline=None,
                    preload=True,
                    add_eeg_ref=False,
                    verbose=False)

    cov_signal = compute_raw_data_covariance(raw_train, verbose=False)
    return epochs, cov_signal
def get_epochs_and_cov(X, y, window=500):
    """return epochs from array."""
    raw_train = toMNE(X, y)
    picks = range(len(getChannelNames()))

    events = list()
    events_id = dict()
    for j, eid in enumerate(getEventNames()):
        tmp = find_events(raw_train, stim_channel=eid, verbose=False)
        tmp[:, -1] = j + 1
        events.append(tmp)
        events_id[eid] = j + 1

    # concatenate and sort events
    events = np.concatenate(events, axis=0)
    order_ev = np.argsort(events[:, 0])
    events = events[order_ev]

    epochs = Epochs(raw_train, events, events_id,
                    tmin=-(window / 500.0) + 1 / 500.0 + 0.150,
                    tmax=0.150, proj=False, picks=picks, baseline=None,
                    preload=True, add_eeg_ref=False, verbose=False)

    cov_signal = compute_raw_data_covariance(raw_train, verbose=False)
    return epochs, cov_signal
Esempio n. 3
0
def toMNE(X, y=None):
    """Tranform array into MNE for epoching."""
    ch_names = deepcopy(getChannelNames())
    montage = read_montage('standard_1005', ch_names)
    ch_type = ['eeg']*len(ch_names)
    data = X.T
    if y is not None:
        y = y.transpose()
        ch_type.extend(['stim']*N_EVENTS)
        event_names = getEventNames()
        ch_names.extend(event_names)
        # concatenate event file and data
        data = np.concatenate((data, y))
    info = create_info(ch_names, sfreq=128.0, ch_types=ch_type,
                       montage=montage)
    raw = RawArray(data, info, verbose=False)
    return raw
def toMNE(X, y=None):
    """Tranform array into MNE for epoching."""
    ch_names = getChannelNames()
    montage = read_montage('standard_1005', ch_names)
    ch_type = ['eeg']*len(ch_names)
    data = X.T
    if y is not None:
        y = y.transpose()
        ch_type.extend(['stim']*6)
        event_names = getEventNames()
        ch_names.extend(event_names)
        # concatenate event file and data
        data = np.concatenate((data, y))
    info = create_info(ch_names, sfreq=500.0, ch_types=ch_type,
                       montage=montage)
    raw = RawArray(data, info, verbose=False)
    return raw