-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp_differencewave.py
107 lines (73 loc) · 3.05 KB
/
temp_differencewave.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 2 18:11:48 2023
@author: fm02
"""
import pandas as pd
import numpy as np
import mne
import seaborn as sns
import matplotlib.pyplot as plt
import sys
import os
from os import path
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
import mne
os.chdir("/home/fm02/MEG_NEOS/NEOS")
import NEOS_config as config
from my_eyeCA import apply_ica
from sklearn.preprocessing import OneHotEncoder
import h5py
sbj_id =2
meta = pd.read_csv('/imaging/hauk/users/fm02/MEG_NEOS/stim/meg_metadata.csv', header=0)
def ovr_sub(ovr):
if ovr in ['nover', 'novr', 'novrw']:
ovr = ''
elif ovr in ['ovrw', 'ovr', 'over', 'overw']:
ovr = '_ovrw'
elif ovr in ['ovrwonset', 'ovrons', 'overonset']:
ovr = '_ovrwonset'
return ovr
subject = str(sbj_id)
sbj_path = path.join(config.data_path, config.map_subjects[sbj_id][0])
bad_eeg = config.bad_channels_all[sbj_id]['eeg']
ovr = config.ovr_procedure[sbj_id]
ovr = ovr_sub(ovr)
raw = mne.io.read_raw(path.join(sbj_path, "block1_sss_raw.fif"))
raw.resample(250)
raw.pick_types(meg=True, eeg=True)
info = raw.info
a = pd.read_csv(f"/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/effect_{sbj_id}_pred.csv")
target = a[['channel', 'Predictability','yhat', 'time']][a['basisname']=='targ']
fix = a[['channel', 'Predictability','yhat', 'time']][a['basisname']=='fix']
eeg_P = [fix['yhat'][(fix['Predictability']=='Predictable') & (fix['channel']==ch)] for ch in range(1,65)]
meg_P = [fix['yhat'][(fix['Predictability']=='Predictable') & (fix['channel']==ch)] for ch in range(65,371)]
eeg_P = np.array(eeg_P)
meg_P = np.array(meg_P)
data_P = np.concatenate(([eeg_P, meg_P]))
evoked_P = mne.EvokedArray(data_P, info, tmin=-0.15)
eeg_U = [fix['yhat'][(fix['Predictability']=='Unpredictable') & (fix['channel']==ch)] for ch in range(1,65)]
meg_U = [fix['yhat'][(fix['Predictability']=='Unpredictable') & (fix['channel']==ch)] for ch in range(65,371)]
eeg_U = np.array(eeg_U)
meg_U = np.array(meg_U)
data_U = np.concatenate(([eeg_U, meg_U]))
evoked_U = mne.EvokedArray(data_U, info, tmin=-0.15)
contrast = mne.combine_evoked([evoked_P, evoked_U], weights=[1, -1])
contrast.plot_joint()
eeg_P = [target['yhat'][(target['Predictability']=='Predictable') & (target['channel']==ch)] for ch in range(1,65)]
meg_P = [target['yhat'][(target['Predictability']=='Predictable') & (target['channel']==ch)] for ch in range(65,371)]
eeg_P = np.array(eeg_P)
meg_P = np.array(meg_P)
data_P = np.concatenate(([eeg_P, meg_P]))
evoked_P = mne.EvokedArray(data_P, info, tmin=-0.15)
eeg_U = [target['yhat'][(target['Predictability']=='Unpredictable') & (target['channel']==ch)] for ch in range(1,65)]
meg_U = [target['yhat'][(target['Predictability']=='Unpredictable') & (target['channel']==ch)] for ch in range(65,371)]
eeg_U = np.array(eeg_U)
meg_U = np.array(meg_U)
data_U = np.concatenate(([eeg_U, meg_U]))
evoked_U = mne.EvokedArray(data_U, info, tmin=-0.15)
contrast = mne.combine_evoked([evoked_P, evoked_U], weights=[1, -1])
contrast.plot_joint()