def test_utils(epochs): """ Test merge and split """ ep_hyper = utils.merge(epochs.epo1, epochs.epo2) assert type(ep_hyper) == mne.epochs.EpochsArray # check channels number assert len( ep_hyper.info['ch_names']) == 2 * len(epochs.epo1.info['ch_names']) # check EOG channels number # check data for S2 or 1 correspond in the ep_hyper, on channel n and # epoch n, randomnly assigned random.seed(10) nch = random.randrange(0, len(epochs.epo1.info['ch_names'])) ne = random.randrange(0, len(epochs.epo1)) ch_name = epochs.epo1.info['ch_names'][nch] liste = ep_hyper.info['ch_names'] ch_index1 = liste.index(ch_name + '_S1') ch_index2 = liste.index(ch_name + '_S2') ep_hyper_data = ep_hyper.get_data() epo1_data = epochs.epo1.get_data() epo2_data = epochs.epo2.get_data() for i in range(0, len(ep_hyper_data[ne][ch_index1])): assert ep_hyper_data[ne][ch_index1][i] == epo1_data[ne][nch][i] assert ep_hyper_data[ne][ch_index2][i] == epo2_data[ne][nch][i]
def epochs(): """ Loading data files & extracting sensor infos """ epo1 = mne.read_epochs(os.path.join("data", "subject1-epo.fif"), preload=True) epo2 = mne.read_epochs(os.path.join("data", "subject2-epo.fif"), preload=True) mne.epochs.equalize_epoch_counts([epo1, epo2]) epoch_merge = utils.merge(epo1, epo2) epochsTuple = namedtuple('epochs', ['epo1', 'epo2', 'epoch_merge']) return epochsTuple(epo1=epo1, epo2=epo2, epoch_merge=epoch_merge)
return simulation # Load data montage = mne.channels.read_custom_montage( '../syncpipeline/FINS_data/enobio32.locs') info = mne.create_info(ch_names=montage.ch_names, sfreq=500, ch_types='eeg') epo1 = mne.EpochsArray(data=np.empty((36, 32, 501)), info=info) epo1.set_montage(montage) epo2 = epo1.copy() mne.epochs.equalize_epoch_counts([epo1, epo2]) sampling_rate = epo1.info['sfreq'] #Hz # concatenate two datasets epo_real = utils.merge(epoch_S1=epo1, epoch_S2=epo2) # setting up parameters n_chan = len(epo_real.ch_names) # get channel locations con, _ = find_ch_connectivity(epo1.info, 'eeg') con = con.toarray() N = int(n_chan / 2) A11 = 1 * np.ones((N, N)) A12 = 0 * np.ones((N, N)) A21 = 0 * np.ones((N, N)) A22 = 1 * np.ones((N, N)) # A11 = con # A22 = con