Exemplo n.º 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)
Exemplo n.º 2
0
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
box = mnehelp.custom_box_layout(pick_perhead_hip_names, 3)
plot_pick_perhead_hip = range(len(pick_perhead_hip))

runfile(
    'M:/Vyzkum/AV/FGU/IntracranialElectrodes/iEEG-python/tfr_perhead_unity.py',
Exemplo n.º 3
0
pd_events = mneprep.load_preprocessed_events(file_paths)
mne_events, events_mapp = mneprep.pd_to_mne_events(pd_events,
                                                   eeg.info['sfreq'])

# Preprocessing
eeg.notch_filter(50)

# Epoching
epochs = mne.Epochs(eeg, mne_events, event_id=events_mapp, tmin=-3, tmax=3)
epochs['onsets_500_1500'].plot(scalings=scalings, n_epochs=6, n_channels=15)

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

# Playing
eeg.plot(scalings=scalings)
eeg.plot_psd(fmax=100, picks=pick_hip, average=False)

# TIME FREQ
freqs = np.arange(2, 12, 0.5)
n_cycles = 6

events = [
    'onsets_500_1500', 'stops_500_1500', 'pointingStarted_Ego',
    'pointingEnded_Ego', 'pointingStarted_Allo', 'pointingEnded_Allo'
]
morlet = mneanalysis.morlet_all_events(epochs,
Exemplo n.º 4
0
                                   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)
bad_epochs_perhead = [
    14, 15, 28, 41, 42, 45, 49, 50, 57, 58, 67, 87, 89, 90, 91, 95, 98, 99,
    104, 109, 110, 113, 123, 124, 125, 126, 127, 128, 129, 131, 135, 141
]
epochs_perhead_bva.drop(bad_epochs_perhead)
#epochs_perhead_bva.plot(block = True, scalings = 'auto', picks=pick_perhead_hip)
#print(mnehelp.get_dropped_epoch_indices(epochs_perhead_bva.drop_log))
Exemplo n.º 5
0
mne_events, events_mapp = mneprep.pd_to_mne_events(pd_events,
                                                   eeg.info['sfreq'])

# 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]]