예제 #1
0
import mne

from functions import mne_prepping as mneprep
from functions import mne_helpers as mnehelp
from functions import mne_loading as loader
from functions import paths

base_path = 'E:/OneDrive/FGU/iEEG/Data'
participant = 'p136'
scalings = {'seeg': 1e2, 'ecg': 1e2, 'misc': 1e2}

file_paths = paths.prep_unity_alloego_files(base_path, participant)
eeg, montage = loader.load_eeg(file_paths, 'perElectrode')

pd_events = mneprep.load_preprocessed_events(file_paths)
mne_events, events_mapp = mneprep.pd_to_mne_events(pd_events,
                                                   eeg.info['sfreq'])

# Epoching
epochs = mne.Epochs(eeg, mne_events, event_id=events_mapp, tmin=-3, tmax=3)
epochs.plot(scalings=scalings)

# PICKS
pick_hip = mnehelp.picks_all_localised(eeg, montage, 'Hi')
pick_perhead_all = mnehelp.picks_all(eeg, montage)
pick_perhead_hip_names = mne.pick_info(eeg.info, pick_hip)['ch_names']

# Playing
eeg.plot(scalings=scalings)
eeg.plot_psd(fmax=100, picks=pick_hip, average=False)
예제 #2
0
base_path = "U:\\OneDrive\\FGU\\iEEG\\p126\\"

path_original_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_250.mat"
path_perhead_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_perHeadbox_250.mat"
path_bip_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_bipolar_250.mat"
path_unity_events = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p126_unity.csv"
path_onset_events = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p126_onsets.csv"
path_montage = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p126_montage.csv"
path_montage_referenced = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p126_montage_referenced.csv"

FREQUENCY = 250
runfile('M:/Vyzkum/AV/FGU/IntracranialElectrodes/iEEG-python/base_setup.py',
        wdir='M:/Vyzkum/AV/FGU/IntracranialElectrodes/iEEG-python')

# PICKS
pick_perhead_hip = mnehelp.picks_all_localised(raw_perhead_vr,
                                               pd_montage_referenced, 'Hi')
pick_perhead_hip_names = mne.pick_info(raw_perhead_vr.info,
                                       pick_perhead_hip)['ch_names']
pick_perhead_ins = mnehelp.picks_all_localised(raw_perhead_vr,
                                               pd_montage_referenced, 'Ins')
pick_perhead_all = mnehelp.picks_all(epochs_perhead_vr)

# BAD EPOCHS
# epochs_perhead_vr.plot(block = True, scalings = 'auto')
# mnehelp.get_dropped_epoch_indices(epochs_perhead_vr.drop_log)
bad_epochs = []
epochs_perhead_vr.drop(bad_epochs)

# TIME FREQ
freqs = np.arange(1, 11, 1)
n_cycles = 6
예제 #3
0
base_path = "U:\\OneDrive\\FGU\\iEEG\\p142\\"

path_original_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_250.mat"
path_perhead_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_perHeadbox_250.mat"
path_perelectrode_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_perElectrode_250.mat"
path_bipolar_vr = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\prep_bipolar_250.mat"
path_unity_events = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p142_unity.csv"
path_onset_events = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p142_onsets.csv"
path_montage = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p142_montage.csv"
path_montage_referenced = base_path + "UnityAlloEgo\\EEG\\Preprocessed\\p142_montage_referenced.csv"

FREQUENCY = 250
runfile('M:/Vyzkum/AV/FGU/IntracranialElectrodes/iEEG-python/base_setup.py', wdir='M:/Vyzkum/AV/FGU/IntracranialElectrodes/iEEG-python')

# PICKS
pick_perhead_hip = mnehelp.picks_all_localised(raw_perhead_vr, pd_montage_referenced, 'Hi')
pick_perhead_hip_names = mne.pick_info(raw_perhead_vr.info, pick_perhead_hip)['ch_names']
pick_perhead_ent = mnehelp.picks_all_localised(raw_perhead_vr, pd_montage_referenced, 'Ent')
pick_perhead_ent_names = mne.pick_info(raw_perhead_vr.info, pick_perhead_ent)['ch_names']
pick_perhead_all = mnehelp.picks_all(raw_perhead_vr)

# BAD EPOCHS
#epochs_perhead_vr.plot(scalings = 'auto')

#epochs_perhead_vr.plot(block = True, scalings = 'auto', picks=pick_perhead_hip)
#epochs_perhead_vr.plot(block = True, scalings = 'auto')
#mnehelp.get_dropped_epoch_indices(epochs_perhead_vr.drop_log)
bad_epochs = [0, 1, 6, 8, 9, 10, 11, 12, 13, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 70, 71, 72, 73, 74, 76, 77, 78, 82, 83, 88, 89, 90, 91, 92, 93, 104, 105, 106, 107, 108, 109, 110, 117, 118, 119, 120, 121, 122, 123, 124, 127, 128, 129, 130, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 159, 160, 161, 162, 163, 164, 169, 170, 171, 172, 173, 174, 177, 178, 179, 180, 181, 182, 185, 186, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 233, 234, 236, 237, 238, 239, 240, 244, 245, 246, 247, 248, 249, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 287, 288, 289, 290, 291, 295, 296, 297, 298, 299, 300, 301, 302, 307, 308, 309, 310, 311, 315, 327, 328, 329, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346]
epochs_perhead_vr.drop(bad_epochs)

# TFR ANALYSIS ---------------
예제 #4
0
FREQUENCY = 250

pd_montage = readeegr.read_montage(path_montage)
pd_montage_referenced = readeegr.read_montage(path_montage_referenced)

# loading BVA data
#raw_original_bva = mneprep.load_raw(path_original_bva, FREQUENCY)
raw_perhead_bva = mneprep.load_raw(path_perhead_bva,
                                   FREQUENCY,
                                   montage=pd_montage_referenced)

pd_events = mneprep.load_matlab_events(path_events_bva)
mne_events_bva, mapp_bva = mneprep.pd_to_mne_events(pd_events, FREQUENCY)

## PICKS
pick_perhead_hip = mnehelp.picks_all_localised(raw_perhead_bva,
                                               pd_montage_referenced, 'Hip')
pick_perhead_hip_names = mne.pick_info(raw_perhead_bva.info,
                                       pick_perhead_hip)['ch_names']
pick_perhead_phg = mnehelp.picks_all_localised(raw_perhead_bva,
                                               pd_montage_referenced, 'PHG')
pick_perhead_phg_names = mne.pick_info(raw_perhead_bva.info,
                                       pick_perhead_phg)['ch_names']
pick_perhead_all = mnehelp.picks_all(raw_perhead_bva)

## Epoching
epochs_perhead_bva = mne.Epochs(raw_perhead_bva,
                                mne_events_bva,
                                event_id=mapp_bva,
                                tmin=-3,
                                tmax=3,
                                detrend=1)
예제 #5
0
# Needs to give it long tails because of the
# low frequnecies later in the convolution
epochs = mne.Epochs(eeg, mne_events, event_id=events_mapp, tmin=-5, tmax=5)

bad_epochs = mneprep.read_bad_epochs(file_paths, append='-perElectrode')
epochs.drop(bad_epochs)

# %% Analysis
morlet = mneprep.load_tfr_epochs(file_paths, append='-bohbot-perElectrode')
montage = loader.load_montage(file_paths, EEG_TYPE)

# %% PICKS
pick_all = mnehelp.picks_all(morlet, montage)
pick_all_names = mne.pick_info(morlet.info, pick_all)['ch_names']
pick_hip = mnehelp.picks_all_localised(morlet, montage, 'Hi')
pick_hip_names = mne.pick_info(morlet.info, pick_hip)['ch_names']

# %% Not important
avg = morlet['onsets_500_1500'].average()
box = mne.channels.layout.make_grid_layout(avg.info, picks=pick_all)
avg.plot_topo(layout=box, picks=pick_all, baseline=BASELINE_TIME,
              mode='zscore', title='Average power')

# %% Processing
# These power values were binned into delta (1–4 Hz), theta(4–8 Hz) and
# alpha (8–12 Hz) frequency bands. Power values were also subsequently
# log transformed and then z-transformed.
lfo_bands = [[1, 4], [4, 8], [8, 13]]
morlet_bands = mneanalysis.band_power(morlet.copy(), lfo_bands)