Fix TMS pulse latencies
This function finds TMS pulses by detecting the large TMS artifacts present in already epoched data. This script is designed for instances when the recorded events do not correspond with when the TMS pulse was given. The script works by extracting a single channel and finding the time points in which the first derivatives exceed a certain threshold (defined by 'rate') - similar to the tesa_findpulse function. Paired pulses can also be detected.
IMPORTANT: If this function is needed, make sure that the initial epochs used are larger than the final epoch size you desire. If the initial epoch size is too small, the new epoch window will be out of range with the new triggers. E.g. initial epoch is -100 to 100 and the event is shifted 10 ms so the new 0 now sits at 10 ms. Re-epoching the data to -100 to 100 won't work as the new range is effectively -90 to 110. In this case, run the initial epoch at -120 to 120 and the epoch can now be taken.

EEGLAB interface

1. Enter the new epoch length in seconds. For example: -1,1 will epoch -1000 to 1000 ms around the selected event. See the above note. Make sure the initial epoch is larger than the desired epoch for this function to work.
2. Select the electrode for finding the TMS pulse artifact.
3. Define a refractory period (i.e. the time it takes for the TMS pulse to recover). If an artifact event is marked multiple times (instead of just once), increase this value.
4. Define the rate of change for detecting the TMS artifact (in uV/ms). If the function is incorrectly labeling too many artifacts, increase this number. Conversely, if the function is missing artifacts, decrease this number.
5. Identify the event for correcting from the drop down menu.
6. Turn on to search for paired pulses. If this is on, an inter-stimulus interval value must also be given in 7. 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.
7. 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 8 must match the number of ISIs entered.

Script

Base function

EEG = tesa_fixevent( EEG, elec, newEpoch, tmsLabel ); Default use.
EEG = tesa_fixevent( EEG, elec, newEpoch, tmsLabel, 'key1', value1... ); Custom input.

Pop function

EEG = pop_tesa_fixevent( EEG ); Pop-up window.
EEG = pop_tesa_fixevent( EEG, elec, newEpoch, tmsLabel ); Default use.
EEG = pop_tesa_fixevent( EEG, elec, newEpoch, tmsLabel, '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'
-
newEpoch
Vector with start and end time of new epoch in seconds (following pop_epoch convention).
[-1,1]
-
tmsLabel
String indicating the event that requires correcting
'TMS'
-

Optional inputs (key/value pairs)

Key
Input value
Description
Example
Default
'refract'
integer
Integer defines the refractory period (the time for the TMS artefact to recover below the rate of change). Integer is in ms.
2
3
'rate'
integer
Integer defines the rate of change of the TMS artifact in uV/ms.
1e4
1e4
'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)
[ ]

Outputs

Output
Description
EEG
EEGLAB EEG structure

Examples

EEG = tesa_fixevent( EEG, 'Cz', [-0.8,0.8], 'TMS' ); default use
EEG = tesa_fixevent( EEG, 'Fz', [-0.7,0.7], 'TMS', 'refract', 4, 'rate', 2e5 ); user defined input EEG = tesa_fixevent( EEG, 'Cz', [-0.8,0.8], 'LICI', 'paired', 'yes', 'ISI', 100 ); paired pulse use
Last modified 2yr ago