예제 #1
0
def for_firas_398(crop_start=None, file_name=None):
    edf = 'C:\\UCLA\\P398_overnightData.edf'
    raw = mne.io.read_raw_edf(edf)
    channels_list_original = [
        'SEEG R'
        'A1-REF', 'SEEG RA2-REF', 'SEEG REC1-REF', 'SEEG REC2-REF',
        'SEEG RAH1-REF', 'SEEG RAH2-REF', 'SEEG LA1-REF', 'SEEG LA2-REF',
        'SEEG LAH1-REF', 'SEEG LAH2-REF'
    ]
    channels_list_bipolar_original = [
        x[:-5] + str(int(x[-5]) + 1) + '-REF' for x in channels_list_original
    ]

    channels_list = [
        x.replace('SEEG ', '').replace('-REF', '')
        for x in channels_list_original
    ]
    channels_list_bipolar = [
        x.replace('SEEG ', '').replace('-REF', '')
        for x in channels_list_bipolar_original
    ]

    raw.pick_channels(
        list(
            set(channels_list_original) | set(channels_list_bipolar_original)))
    channels_mapping = {
        x: x.replace('SEEG ', '').replace('-REF', '')
        for x in raw.ch_names
    }
    raw.rename_channels(channels_mapping)
    if crop_start is not None:
        raw.crop(tmin=crop_start * 60, tmax=crop_start * 60 + 16 * 60)
        raw.resample(250)
    raw.load_data()

    raw_bi = mne.set_bipolar_reference(raw,
                                       anode=channels_list,
                                       cathode=channels_list_bipolar,
                                       drop_refs=False)
    # raw_bi.plot()

    write_edf('398_bipolar.edf' if file_name is None else file_name, raw_bi)
예제 #2
0
def save_as_fif():
    raw = mne.io.read_raw_edf(
        '/Users/rotemfalach/projects/epileptic_activity/results/D036/D036_15_01_21a.edf'
    )
    write_edf(mne_raw=raw, fname='example2.edf', overwrite=True)