Hello
I have epoched EEG data from -0.2 to 3 sec and I want the data to be exported in to excel, whereby the data points get averaged for each second, resulting in three rows (1. row 0 to 1 sec, 2. row 1 to 2 sec, 3. row 2 to 3 sec). My baseline is supposed to be from -0.2 to 0 seconds. My problem is, that when I export the data, the data regarding the first row, not only contain the data points from 0 to 1 sec, but also include the baseline period which makes no sense. I cant cut my tmin to 0 insted of -0.2, because I need this period for the baseline correction. Any ideas? Can I tell python to start the export by 0 not -0.2?
session = 'ses-Expo'
data_path = 'C:\\Users\\Admin\\Desktop\\Projekt_Franziska\Studie 3\\Analyse\\EEG\\BIDS_ScriptNew'
file_name_CSplusRemembered = data_path + '/' + subject + '/' + session + '/' + 'eeg/' + subject + '_' + session + '_run01_' + 'tfr_data_CS+_remembered_slow.fif'
data_CSplusRemembered_path = op.join(data_path,file_name_CSplusRemembered)
data_CSplusRemembered= mne.time_frequency.read_tfrs(data_CSplusRemembered_path)
data_CSplusRemembered=data_CSplusRemembered[0]
data_CSplusRemembered.pick_channels(ch_names=['Fp1', 'Fp2', 'F7', 'F3', 'Fz', 'F4', 'F8', 'FC5', 'FC1', 'FC2', 'FC6'])
data_alpha_CSplusRemembered=data_CSplusRemembered.crop(tmin=-0.2, tmax=3,fmin=8, fmax=10, include_tmax=True)
data_alpha_CSplusRemembered=data_alpha_CSplusRemembered.apply_baseline(baseline=(-0.2, 0), mode='zlogratio', verbose=None)
alpha=np.mean(data_alpha_CSplusRemembered.data, axis=1)
alpha=np.mean(alpha.data, axis=0)
timeS=data_alpha_CSplusRemembered.times[0:]
data = np.dstack((timeS,alpha))
data = data.reshape(801, 2)
index=data_alpha_CSplusRemembered.times[0:]
columns=['time','value']
df_data_CSplusR = pd.DataFrame(data=data , # values
index=index,
columns=columns) # 1st row as the column names
df_data_CSplusR['pptID'] = subject
df_data_CSplusR['condition'] = 'CPR'
df_data_CSplusR['shock'] = 'P'
df_data_CSplusR['memory'] = 'R'
baseline_CPR = baseline_CPR.append(pd.DataFrame(data = df_data_CSplusR), ignore_index=True)
del data_CSplusRemembered, data_alpha_CSplusRemembered, alpha, df_data_CSplusR
#Averages values to 1 value each sec
baseline_CPR=baseline_CPR[baseline_CPR['time']!=0]
baseline_CPR['Sec']= baseline_CPR['time'].apply(np.ceil)
baseline_CPR_summary=pd.pivot_table(baseline_CPR,values='value',index=['pptID'],columns=['Sec'],aggfunc=np.mean)
Thank you
Franzi