Find TMS pulses (alternative)
This function is an alternative to tesa_findpulse. The function differs in findings TMS pulses by detecting the large TMS artifact peaks in the data, as opposed to the rate of change. This function works by extracting a single channel and finding the time points in which a peak above a certain threshold is detected. Different methods for setting the threshold can be determined and either the positive or negative peak used (or an interactive GUI which allows the user to select which peaks are included). Paired pulses and repetitive TMS trains can also be detected.
Note that this script requires a toolbox developed by Daniel Wagenaar (WagenaarMBL) which is available for download at: http://www.its.caltech.edu/~daw/teach.html
Once the WagenaarMBL toolbox is unzipped, please make sure this is added to your Matlab path (see a quick intro to Matlab).
Output from tesa_findpulsepeak. Left: peaks found (marked with pink dots) using 'poly' detrend, 'manual' threshold of 10,000 uV, and 'positive' peak detection. Right: Peaks selected using the 'GUI' option. The yellow area was created by clicking and dragging over the required peaks.

EEGLAB interface

1. Manually enter or select from a list the electrode for finding the TMS pulse artifact.
2. Select a type of detrend to centre the data before peak detection is applied.
3. Select the threshold type for determining peak events. Dynamic sets threshold to the range points above/below 99.9 percent of data trace. Median sets threshold as median of points above/below 99.9 percent of data trace. Manual is a user defined integer for setting the threshold (in uV). (e.g. 1000). A separate window will pop up where this value can be entered after selecting OK.
4. Select whether to use positive or negative peaks to define artifact. Alternatively, a graphical user interface (GUI) option can be selected. This allows the user to manually select the peaks to use by clicking and dragging. When the window is generated, press 'continue with selection' and then click and drag to select the required peaks. If the selection does not capture the peaks properly, this step can be repeated by selecting 'No-redo'.
5. Plot identified artifacts. Turn on to plot a summary of the TMS artifacts found in the data. Note this plot will not be generated if the GUI option is used in 4.
6. Label for single TMS pulses. Events inserted in to the EEGLAB structure will be called by this name.
7. Turn on to search for paired pulses. If this is on, an inter-stimulus interval value must also be given in 8. This will cause the function to search for paired as well as single pulses. A paired pulse is defined as two successive pulses in which the inter-stimulus interval matches those given.
8. Define the inter-stimulus interval which the function will use to label an artifact as single or paired. For example, if you are using a LICI paradigm with an ISI of 100 ms, enter a value of 100 here. The function has a precision of 0.5 ms for determining whether two successive pulses fall within this ISI. If multiple different paired pulse conditions are present in the same file, this can be entered as: 3, 15, 100 etc. Note that the number of paired label inputs in 9 must match the number of ISIs entered.
9. Enter a customised label for the paired pulse test stimulus (i.e. the second stimulus). If left blank, the default is TMSpair. The conditioning pulse (i.e the first pulse) is automatically labeled as 'con'. Note that this label cannot be the same as the single label defined in 6. If multiple ISIs are given, multiple labels corresponding with these ISIs can be given as: SICI, ICF, LICI. Note the number of labels must match the number of ISIs.
10. Turn on to search for trains of repetitive TMS pulses. If this is on, an inter-train interval must be given in 11 and the number of pulses in a train must be given in 12.
11. Define the inter-train interval (in ms). This refers to the number of milliseconds between a train of stimulations. For example, if a 10 Hz paradigm was given in which stimulation was applied for 4 seconds (40 pulses) followed by a 26 second rest, the inter-train interval would be 2600.
12. Define the number of pulses in a train. Using the above example, the number of pulses would be 40.

Script

Base function

EEG = tesa_findpulsepeak( EEG, elec ); Default use.
EEG = tesa_findpulsepeak( EEG, elec, 'key1', value1... ); Custom input.

Pop function

EEG = pop_tesa_findpulsepeak( EEG ); Pop up window
EEG = pop_tesa_findpulsepeak( EEG, elec ); Default use.
EEG = pop_tesa_findpulsepeak( EEG, elec, 'key1', value1... ); Custom input.

Required inputs

Input
Description
Example
Default
EEG
EEGLAB EEG structure
EEG
-
elec
String defining electrode to use for finding artifact
'Cz'
-

Optional inputs (key/value pairs)

Key
Input value
Description
Example
Default
'dtrnd'
'poly' or 'gradient' or 'median' or 'linear' or 'none'
Defines the type of detrend used to centre the data, to generate an analytic signal.
'gradient'
'poly'
'thrshtype'
'dynamic' or 'median' or value
Defines the type of threshold used to determine peaks. Dynamic sets threshold to the range points above/below 99.9 percent of data trace. Median sets threshold as median of points above/below 99.9 percent of data trace. Value is a user defined integer for setting the threshold (in uV). (e.g. 1000)
10000
'dynamic'
'wpeaks'
'pos' or 'neg' or 'gui'
Defines whether to use the positive or negative peak to define the artifact, or to use an interactive GUI. For the GUI, a box is generated by clicking and dragging the mouse cursor. Peaks within the box will be included as events.
'gui'
'pos'
'tmsLabel'
'string'
'String' is a label for the single TMS event.
'Single'
'TMS'
'plots'
'on' or 'off'
Brings up a plot showing the detected peaks. Red = detected
'on'
'on'
'paired'
'yes' or 'no'
Type 'yes' to turn on paired detection
'yes'
'no'
'ISI'
integer
Required if 'paired' is 'yes'. integer is a vector defining interstimulus intervals between conditioning and test pulses. Multiple ISIs can be defined as [3,100,...].
100 (single paired condition); [3,15,100] (multiple paired conditions)
[ ]
'pairLabel'
{'string'}
Required if more than one ISI. {'string'} is a cell array containing string labels for different ISI conditions. Multiple labels can be defined as {'SICI','LICI',...}. The number of labels defined must equal the number of ISI conditions defined.
{'LICI'} (single ISI); {'SICI','ICF','LICI} (multiple ISIs)
{'TMSpair'}
'repetitive'
'yes' or 'no'
Type 'yes' to turn on repetitive detection.
'yes'
'no'
'ITI'
integer
required if 'repetitive' is 'yes'. Integer defines the inter-train interval in ms. For example, if a 10 Hz rTMS condition is used with 4s of stimulation (40 pulses) and 26s of rest, ITI = 2600.
2600
[ ]
'pulseNum'
integer
Required if 'repetitive' is 'yes'. int defines the number of pulses in a train. Using the above example, this would be 40.
40
[ ]

Outputs

Output
Description
EEG
EEGLAB EEG structure

Examples

EEG = pop_tesa_findpulsepeak( EEG, 'Cz' ); Default use.
EEG = pop_tesa_findpulsepeak( EEG, 'Fz', 'dtrnd', 'linear', 'thrshtype', 'median', 'wpeaks', 'gui', 'plots', 'off', 'tmsLabel', 'single' ); Custom inputs selecting a linear detrend and using the interactive user interface to select peaks.
EEG = pop_tesa_findpulsepeak( EEG, 'Cz', 'paired', 'yes', 'ISI', [100],'pairLabel', {'LICI'}); Paired pulse use.
EEG = pop_tesa_findpulsepeak( EEG, 'Cz', 'repetitive', 'yes', 'ITI', 26, 'pulseNum', 40 ); rTMS use.
Last modified 1yr ago