Find and analyse TEP peaks
This function finds peaks within a time window defined by user for either ROI or GMFA analyses. Either positive or negative peaks are detected. Peaks are defined as a data point which is larger/smaller than +/- x data points (default = 5, however this can be defined by user). If multiple peaks are found within the window, either the largest peak or the peak closest to the defined latency are returned (as specified by the user). Results are saved in EEG structure under (either EEG.ROI or EEG.GMFA). If no peak is found in the defined window, the amplitude at the defined latency is returned, and a NaN is returned in latency. The analysis is run on all existing outputs from tesa_tepextract (e.g. ROIs or GMFA), unless the user opts to run the analysis on one specific ROI or GMFA.
Note that following peak detection, results can be plotted using tesa_plot.
Peak analysis results plotted using tesa_plot. Three positive peaks were identified (P45, P80 and P280) and three negative peaks (N20, N65 and N100). One positive peak was not found (P200; plotted in red). The windows for peak search are plotted with dotted boxes.

EEGLAB user interface

1. Select which input analysis to run the analysis on.
2. Select the direction of the peak for detection. If both positive and negative peaks require detecting, run the analysis a second time.
3. [Required]. Define the peaks that require detecting. See the window for examples.
4. [Required]. Define the time windows for the peak search. For each peak, two values must be given - the start and end of the search window in ms (e.g. 15,45). For multiple peaks, time window pairs need to be separated by a ; (e.g. 15,45; 46,75). The number of time window pairs must match the number of peaks.
5. Select which method to use for selecting a peak if multiple peaks are detect within one window. Largest: the peak with the largest amplitude will be returned. Centre: the peak with the latency closest to the value in 3 will be returned.
6. Define the number of samples for determining a peak. Peaks are defined as a data point which is greater than (positive) or less than (negative) +/- the number of samples defined in this window.


Base function

EEG = tesa_peakanalysis( EEG, input, direction, peak, peakWin ); Default use.
EEG = tesa_peakanalysis( EEG, input, direction, peak, peakWin, 'key1', value1... ); Custom inputs.

Pop function

EEG = pop_tesa_peakanalysis( EEG ); Pop up window.
EEG = pop_tesa_peakanalysis( EEG, input, direction, peak, peakWin ); Default use.
EEG = pop_tesa_peakanalysis( EEG, input, direction, peak, peakWin, 'key1', value1... ); Custom inputs.

Required inputs

EEGLAB EEG structure
String defining whether 'ROI' or 'GMFA' input is used.
String defining whether peaks are 'positive' or 'negative'. Use 'positive' for GMFA analysis.
Vector defining the peak of interest.
25 (one peak); [25, 60, ...] (multiple peaks)
Matrix defining the time windows to search for above peaks. Minimum and maximum values for time window are defined as 15,35 and peak definitions separated by ; Note that the number of peak windows defined should equal the number of peaks. For example if peak = [25,60,180]; peakWin = [15,35; 40,80; 160,200]
[15,35; 40,80; 160,200]

Optional inputs (key/value pairs)

Input value
'largest' or 'centre'
If multiple peaks are detected in a window, largest will search for the largest peak within the time window. Centre will search for the peak closest to the latency defined in peak.
Integer defining the number of samples either side of a peak that defines the peak. Peaks are defined as data point which is larger/smaller than +/- Integer data points
String is a name of a specific ROI/GMFA to perform the analysis on. If this is left blank, all ROI/GMFAs defined by tesa_tepextract are analysed.
[ ]


EEGLAB EEG structure


EEG = pop_tesa_peakanalysis( EEG, 'ROI', 'negative', 100, [80,120] ); Find a negative peak in all ROI analyses at 100 ms searching between 80 and 120 ms.
EEG = pop_tesa_peakanalysis( EEG, 'GMFA', 'positive', [30,60,180],[20,40;50,70;170,190] ); Find 3 positive peaks in the GMFA analysis at 30 ms (between 20-40ms), 60 ms (between 50-70 ms), and 180 ms (between 170-190 ms).
EEG = pop_tesa_peakanalysis( EEG, 'ROI', 'positive', [25,70], [15,35;60,80], 'method', 'centre', 'samples', 5, 'tepName', 'motor'); Find 2 positive peaks at 25 ms (15-35 ms), and 70 ms (60-80 ms) using the peak closest to the central peak (i.e. 25 ms or 70 ms), defining a peak as a data point that is larger than all data points +/- 5 samples and only for the ROI analysis named 'motor'.
Last modified 1yr ago