ERP Analysis
Event related potentials (ERPs) measure electrical activity in response to specific events and are thought to reflect the sum of post-synaptic potentials produced when several pyramidal cortical neurons fire in synchrony while processing information. We show how to construct ERPs by averaging across all waveforms
Figure 1: ERP results from my thesis.
ERP are averaged electrical potentials in response to certain events. The idea is that over 10s to 100s of repeated instances, the averaged waveform will represent event locked information far more than external noise, which allows us to make sense fo the data. To start you want to load the CENA toolbox from the following link: ERPLAB. Remember to cite:
Lopez-Calderon, J., & Luck, S. J. (2014). ERPLAB: An open-source toolbox for the analysis of event-related potentials. Frontiers in human neuroscience, 8, 213.
in any analysis that you do to give the creators of the toolbox credit.
To install it Add the unzipped folder to your EEGLAB folder and place it in there. (eg. (e.g. ~/Documents/MATLAB/eeglab13_6_4b/plugins/erplab6.1.3/)
Following this you can open matlab and type EEGlab into the the command window you should see the ERPlab function.
Before we can start doing any ERPlab processing, we need to epoch the data. First you decide what your range is - we have selected 500 ms prior to the event as a baseline and 1000 ms after to follow.
EEG = pop_epochbin( EEG , [-500 1000], 'pre'); EEG.setname = [subjname '_epoched.set']; if (save_everything) EEG = pop_saveset( EEG, 'filename', EEG.setname,'filepath', stepsPath); end eeglab redraw;
After you epoch the ERPs you need to use ERPlab to create different bins based on the conditions of interest. Code to do this is outlined below, although it can also be done in the GUI. Information on how to set up the bin operator file can be found in the following link: https://github.com/lucklab/erplab/wiki/Assigning-Events-to-Bins-with-BINLISTER:-Tutorial
parentfolder = '/where_ERPs_are_located/'; outputfolder = 'where_to_save_updated_files/'; fileList = dir(fullfile(parentfolder, '*.erp')); for s=11:numsubjects subject = fileList(s).name; subjname = char(extractBefore(subject, '.')); ERP = pop_loaderp( 'filename', subject, 'filepath', parentfolder); savefilename = [subjname '_new.erp']; ERP = pop_binoperator( ERP, 'where_binoperatorfile_is_saved'); ERP = pop_savemyerp(ERP, 'erpname', subjname, 'filename', savefilename, 'filepath', outputfolder, 'Warning', 'on'); end
Once you have the correct bins you can go into the GUI and start plotting the results through that or you can do it it manually in matlab using the ERP output. For the code to do it manually you can contact me. Alternatively you can do it in ERPlab through the GUI.
Once you have visualized the results it may be helpful to see if there are any statistical difference between peaks or latencies of different groups. ERPlab has a function to calculate the peak latency and information can be found here: https://github.com/lucklab/erplab/wiki/Measuring-amplitudes-and-latencies-with-the-ERP-Measurement-Tool:-Tutorial
ERPlist = 'list_of_all_files.txt'; for el = 1:256 % n600 savepathn600 = ['/wheretosaveamp/' 'elec' num2str(el) 'a600.txt']; ALLERP = pop_geterpvalues( ERPlist, [500 700], 8:13, el , 'Baseline', 'pre', 'Binlabel', 'on', 'FileFormat', 'wide', 'Filename', savepathn600, 'Fracreplace', 'NaN', 'InterpFactor', 1, 'Measure', 'ninteg', 'PeakOnset', 1, 'Resolution', 3 ); % p600 savepathp600 = ['/wheretosaveamp/' 'elec' num2str(el) 'a600.txt']; ALLERP = pop_geterpvalues( ERPlist, [500 700], 8:13, el , 'Baseline', 'pre', 'Binlabel', 'on', 'FileFormat', 'wide', 'Filename', savepathn600, 'Fracreplace', 'NaN', 'InterpFactor', 1, 'Measure', 'pinteg', 'PeakOnset', 1, 'Resolution', 3 ); end
The code above will export the peak amplitudes of each ERP component. As an example we show n600 and p600, corresponding to a negative and positive peak, however you should really select a-priori which components and time frames you would like to look at. Ideally don’t investigate too many or you will definitely get a false positive.
From here I have created some python code that can identify which electrodes the comparisons are significant for. In order to get the jupyter notebook for this please send me an email!
Contact me.
hyder.amna [at] gmail.com