Hi, I am analyzing some EEG data, and find a wonderful paper sharing some easily operate tutorial for new MNE-er, including how to export the epoch data into the csv data (in scripts file named “measure ERPs”). I attached the link in there, thanks so much to @aaronjnewman .
tutorial on batch processing using MNE, including export the epoch data to csv file
I copy the core code line in there. All code from aaronjnewman.
df_list = []
for subj in subjects:
for cond in conditions:
for roi, chans in rois.items():
for comp_name, comp_params in components.items():
win_start, win_stop = np.searchsorted(epochs[subj][cond].times, comp_params['tw'])
df_list.append(pd.concat([pd.DataFrame({'Subject': subj,
'Component':comp_name,
'Trial Time':np.repeat(epochs[subj][cond].events[:,0], len(chans)),
'Condition':cond,
'ROI':roi,
'Channel':np.tile(chans, epochs[subj][cond].selection.shape),
}),
pd.DataFrame(epochs[subj][cond].get_data(picks=chans)[:, :, win_start:win_stop].mean(axis=-1).flatten() * 10e5,
columns=['MeanAmpl']),
],
axis=1))
df = pd.concat(df_list)
df[['Target', 'Level']] = df['Condition'].str.split('/', expand=True)
df[['Laterality', 'AntPost']] = df['ROI'].str.split('_', expand=True)
df.to_csv('../ERP.csv', index=False)