def _convert_to_raw(self, data, s): fs = 500 ch_names = [ 'Fp1', 'F5', 'F3', 'F1', 'Fz', 'FC5', 'FC3', 'FC1', 'FCz', 'C5', 'C3', 'C1', 'Cz', 'CP5', 'CP3', 'CP1', 'CPz', 'P5', 'P3', 'P1', 'Pz' ] ch_types = ['eeg'] * 21 info = create_info(ch_names, fs, ch_types) info['description'] = 'PGHealthy' x = data['Signals'] * 1e-6 raw = RawArray(x, info) epoch_start = np.array(data['Epoch_start']).T N = len(epoch_start) events = np.c_[epoch_start, np.zeros(N), np.ones(N) * (s + 1)] events = events.astype(np.int) raw.set_montage('standard_1005') mapping = {v: k for k, v in self.event_id.items()} onsets = events[:, 0] / raw.info['sfreq'] durations = np.zeros_like(onsets) # assumes instantaneous events descriptions = [mapping[ev_id] for ev_id in events[:, 2]] annot_from_events = Annotations(onset=onsets, duration=durations, description=descriptions) raw.notch_filter(50, verbose=False) return raw.set_annotations(annot_from_events)
trange=T_RANGE, l_freq=LO_FREQ, h_freq=HI_FREQ) from mne.io import RawArray from mne import create_info from integration import stream_channels raw = RawArray(data=debug_data[0], info=create_info(stream_channels, 500, 'eeg')) raw = raw.filter(LO_FREQ, HI_FREQ, method='fir', fir_design='firwin', phase='zero') raw = raw.notch_filter(50) # raw = raw.drop_channels([ch for ch in raw.ch_names if ch not in GOODS]) # print(raw.ch_names) # raw = raw.reorder_channels(sorted(raw.ch_names)) # print(raw.ch_names) raw = raw.crop(tmin=11.) raw = raw.resample(125) # raw = raw.reorder_channels(sorted(raw.ch_names)) # print(raw.ch_names) realtime = raw.get_data(picks=sorted(GOODS)) * 1000 raw = raw.reorder_channels(sorted(raw.ch_names)) # print(raw.ch_names) ordered = raw.get_data(picks=GOODS) * 1000 # print(realtime[0])