Component classification (TESA)
NOTE: The implementation of this function has changed from TESA v1.1.0 onwards. Classification using older versions of TESA will generate different results.
This function applies a series of heuristic rules (see below for details) to classify independent components as artifacts. The component classification can then be manually checked by plotting the components and investigating the feature profile (see plot and remove components for details) before the components selected as artifacts are removed from the data. Based on the heuristic rules, components are classified as one of the following: keep; reject; reject - TMS-evoked muscle; reject - blink; reject - eye movement; reject - muscle; reject - electrode noise; or reject - sensory. If a component is selected as an artifact using a rule, it is plotted as red, if not it is plotted as blue.
Following component removal, a before-and-after plot is generated and users can select whether to continue or repeat the process. Component classification and variance represented by each component is stored in the EEG structure => EEG.icaCompClassTesaX.
Users are encouraged to report the settings used with this function in any publications.
Note that the component selection rules are intended to work as a guide only, and each component must be manually checked and re-classified if necessary. The rule thresholds can be adapted by the user and may differ between datasets. There is no guarantee for the success of these rules in accurately classifying components. For further information on selecting components, please read:
Example 1 - using automated component selection to remove TMS-evoked muscle activity following a first round of FastICA. In this example, automated component selection is 'on' for TMS-evoked muscle activity, but 'off' for blinks, lateral eye movements, persistent muscle activity and electrode noise. Each component is plotted individually and the component is categorised (drop down menu). Components detected as artifacts are plotted red and others blue. If the user is not satisfied with the classification, the categorisation can be changed using the drop down menu. The components can be scrolled through using the next/back buttons. In this example, IC 1 is automatically classified as TMS-evoked muscle activity. IC 3 represents a step artifact which can be problematic for filtering, so was manually marked as 'reject' and removed. When all components have been considered (only the first 6 of 58 are plotted here), a before-and-after component removal summary is plotted.
Example 2 - using automated component selection to remove all artifact types following a second round of FastICA. In this example, the main TMS-evoked muscle activity components has been removed following the first round of FastICA (see example 1). The missing data (i.e. where the TMS pulse was removed) were then interpolated and the data were band-pass filtered between 1-100 Hz and band-stop filtered between 48-52 Hz. Automated component selection is 'on' for all artifact types (TMS-evoked muscle activity, blinks, lateral eye movements, persistent muscle activity and electrode noise) Again, each component is plotted individually and the component is categorised (drop down menu). Components detected as artifacts are plotted red and others blue. If the user is not satisfied with the classification, the categorisation can be changed using the drop down menu. When all components have been considered (only the first 6 of 55 are plotted here), a before-and-after component removal summary is plotted.

Component classification methods

TMS-evoked muscle activity

This type of artifact is detected by comparing the mean absolute amplitude of the component time course within a target window ('tmsMuscleWin') and the mean absolute amplitude across the entire component time course. A threshold is set by the user for detection (e.g. 8 means the mean absolute amplitude in the target window is 8 times larger than the mean absolute amplitude across the entire time course).
Detection of TMS-evoked muscle activity components. Component time courses (top row) are converted to absolute values (bottom row). The mean the of data in the target window (red plotted line - 11 to 30 ms) is divided by the mean of all data. Comp. 1, which represents TMS-evoked muscle activity, returns a value of 69.62, whereas comp. 2 and comp. 3 which are not TMS-evoked muscle activity return values of 2.73 and 0.82 respectively. A threshold of 8 would therefore classify comp. 1 as TMS-evoked muscle activity.
This type of artifact is detected by comparing the mean absolute z score (calculated on the component topography weights) of two electrodes close to the eyes (e.g. 'Fp1' and 'Fp2'). A threshold is set by the user for detection (e.g. 2.5 - the mean absolute z score of the two electrodes needs to be larger than 2.5 for detection).
Detection of blinks. Component topography weights are converted to z-scores and the mean absolute z-score of the two selected electrodes (Fp1 and Fp2; marked with X) are returned. Comp. 1, which represents a blink, returns a value of 2.9, whereas comp. 2 and 3 (not blinks) return values of 1.58 and 0.03 respectively. A threshold of 2.5 would therefore classify comp. 1 as a blink.

Lateral eye movement

This type of artifact is detected by comparing the z scores (calculated on the component topography weights) of two electrodes on either side of the forehead (e.g. 'F7','F8'). The z score must be positive for one and negative for the other. A threshold is set by the user for detection (e.g. 2 means the z score in one electrode must be greater than 2 and less than -2 in the other electrode).
Detection of lateral eye movement. Component topography weights are converted to z-scores and the z-score values of the two selected electrodes (F7 and F8; marked with X) are returned. Comp. 1, which represents lateral eye movement, returns values of -2.49 and 2.54, whereas comp. 2 and comp. 3 (not movement) return values of -0.76 and -0.31, and 4.76 and -0.23 respectively. A threshold of 2 would classify comp. 1 as eye movement, as one value is > 2 and one value < -2.

Persistent muscle activity

Persistent muscle activity is detected by calculating the slope of the line of best fit between the log EEG power and the log frequency (TESA v1.1.0 and higher). This approach has been validated in individuals under pharmacological paralysis (i.e. with no muscle activity). The default slope value of -0.31 dB/Hz provides a cut-off at the maximum value of EMG-free components. See the following manuscript for details:
Detection of persistent muscle activity. The component time series are a converted into the frequency domain using the Welch's power spectral density estimate. A linear line is then fit to the log-log frequency data and the slope used to determine a muscle component threshold. In this example, frequency and log power spectral density of 3 components is plotted on the top row. The first 2 are neural whereas the third is a muscle component. The bottom row shows the corresponding log-log plots with the linear line of best fit and the corresponding slope values. The neural components are <-0.31 whereas the muscle component is >-0.31.
Legacy implementation. In TESA v1.0.1 and earlier, persistent muscle activity is detected by comparing the mean power of the component time course frequency distribution between a target window and the mean across all frequencies(calculated using an FFT across all trials). A threshold is set by the user for detection (e.g. 0.6 means the high frequency power is 60% of the total power).
Detection of persistent muscle activity (legacy). A fast Fourier transform is performed across all individual trials of the component time course. The mean power between frequencies in a target window (30-100 Hz; indicated by red plotted line) is divided by the mean total power. Comp. 1 returns a value of 1.27, comp. 2 a value of 0.24 and comp. 3 a value of 0.86. A threshold of 0.6 would classify both comp. 1 and comp. 3 as persistent muscle activity.

Electrode noise

This type of artifact is detected by comparing z scores in individual electrodes (calculated on the component topography weights). A threshold is set by the user for detection (e.g. 4 means one or more electrodes has an absolute z score of at least 4).
Detection of electrode noise. Component topography weights are converted to z scores and the electrode with the maximum absolute z score is returned (marked with X). Comp. 1, which represents electrode noise, returns a value of 5.46, whereas comp. 2 and comp. 3 return values of 2.56 and 2.17 respectively. A threshold of 4 will classify comp. 1 as electrode noise.

Sensory and other artifacts

Note that categories for sensory and other artifacts are also available in the dropdown menu. There are currently no specific rules suitable for accurately detecting these components and are therefore classified entirely at the user's discretion.

Adapting component thresholds

The default thresholds for detecting each type of artifact were determined by observing the values for each component on a data set (62 electrodes, TMS over posterior parietal cortex). As some of the thresholds are dependent on the electrode montage, the default values may not be appropriate for all data sets. If a certain type of artifact is continually being mis-classified, turn on the threshold feedback for that artifact and run this through several participants. The value used to classify the component corresponding to the rule will appear in the Matlab command window. You can then use this information to determine an appropriate threshold for the data.

Other notes on ICA

Most ICA algorithms are initiated randomly. This means that running ICA multiple times on the same dataset can return slightly different solutions. Adequate pre-processing, data quality and larger data quantity tend to improve the stability of ICA decomposition and therefore minimise differences between solutions. However, the result of random initiation means that analysing a dataset a second time could return a slightly different result. This is an important limitation in the context of using ICA to clean TMS-EEG data.
The polarity of the time course and topography weights is not meaningful in the context of removing components from the data. For example, if ICA is run twice and the component representing blinking is positive in one run, but negative in the next, removing this component will have the exact same final result on the data.
There are a number of key assumptions underlying ICA that TMS-EEG data might violate. This could substantially reduce the ability of ICA to accurately decompose neural and artifact components. For an excellent discussion on this issue, please read the following:

EEGLAB user interface

1. Set whether to remove components following classification. Setting to 'on' will remove components.
2. Set the time course limits (x axis limits) for the component time course plots.
3. Set the y-axis scaling for the frequency plot. Four scaling options are possible: raw, log, log10 and dB.
4. Set the size of the plotted figures. Three sizes are possible: small, medium and large.
5. Set the frequency limits (x axis limits) for the component frequency plots.
6. Turn on or off automated selection of components representing TMS-evoked muscle activity.
7. Set the threshold for detection of TMS-evoked muscle activity.
8. Set the target time window for detecting TMS-evoked muscle activity.
9. Turn on or off threshold feedback for TMS-evoked muscle activity. If on, values for each component will appear in the command window.
10. Turn on or off automated selection of components representing eye blinks.
11. Set the threshold for detection of eye blinks.
12. Set the electrodes for detecting eye blinks. These should be the two electrodes closest to the eyes (e.g. FP1 and FP2 or AF3 and AF4 if the previous are not present in the data).
13. Turn on or off threshold feedback for eye blinks. If on, values for each component will appear in the command window.
14. Turn on or off automated selection of components representing lateral eye movements.
15. Set the threshold for detection of lateral eye movements.
16. Set the electrodes for detecting lateral eye movements. These should be the two electrodes on the outer most edges of the forehead (e.g. F7 and F8).
17. Turn on or off threshold feedback for lateral eye movements. If on, values for each component will appear in the command window.
18. Turn on or off automated selection of components representing persistent muscle activity.
19. Set the threshold for detection of persistent muscle activity.
20. Set the frequency window to include when fitting the log-log linear function for detecting persistent muscle activity.
21. Set the frequency window to exclude when fitting the log-log linear function for detecting persistent muscle activity (e.g. to avoid line noise).
22. Turn on or off threshold feedback for persitent muscle activity. If on, values for each component will appear in the command window.
23. Turn on or off automated selection of components representing electrode noise.
24. Set the threshold for detection of electrode noise.
25. Turn on or off threshold feedback for electrode noise. If on, values for each component will appear in the command window.
26. Turn on or off plot check for automated component selection. On is highly recommended.
27. Turn on or off whether to save the IC weights in the EEG structure (useful for post hoc analysis of classified component features). Note turning this on will lead to larger file sizes.

Scripts

Base function

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

Pop function

EEG = pop_tesa_compselect( EEG ); Pop up window
EEG = pop_tesa_compselect( EEG, 'key1',value1... ); Custom input

Required inputs

Input
Description
Example
Default
EEG
EEGLAB EEG structure
EEG
-

Optional inputs (key/value pairs)

Key
Input value
Description
Example
Default
Plot settings
'compCheck'
'on' or 'off'
Turns on or off the component plots for checking automated component selection. On is highly recommended.
'off'
'on'
'remove'
'on' or 'off'
Turns on or off removal of components after classification.
'off'
'on'
'saveWeights'
'on' or 'off'
Saves the winv (topoplot weights) and icaact (time course weights) that the classification was performed on. Note this will increase the storage size of the files.
'on'
'off'
'figSize'
'small' or 'medium' or 'larger'
Determines the size of the figures that are plotted displaying the information on the components.
'medium'
'small'
'plotTimeX'
[start,end]
Vector with integers for plotting the component time course (in ms).
[-300,600]
[-200,500]
'plotFreqX'
[low,high]
Vector with integers for plotting the frequency distribution of components (in Hz)
[2,45]
[1,100]
'freqScale'
'raw' or 'log' or 'log10' or 'db'
y-axis scaling for the frequency plots
'log10'
'log'
TMS-evoked muscle activity
'tmsMuscle'
'on' or 'off'
A string which turns on TMS-evoked muscle activity detection.
'off'
'on'
'tmsMuscleThresh'
integer
Integer determining the threshold for detecting components representing TMS-evoked muscle activity.
10
8
'tmsMuscleWin'
[start,end]
Vector describing the target window for TMS-evoked muscle activity (in ms).
[5,50]
[11,30]
'tmsMuscleFeedback'
'on' or 'off'
String turning on feedback of TMS-evoked muscle threshold value for each component in the command window. (Useful for determining a suitable threshold).
'on'
'off'
Eye blinks
'blink'
'on' or 'off'
A string which turns on eye blink detection.
'off'
'on'
'blinkThresh'
integer
Integer determining the threshold for detecting components representing eye blinks.
3
2.5
'blinkElecs'
{'string','string'}
Cell with the two electrodes for blink detection. The two electrodes closest to the eyes are best for this purpose.
{'AF3', 'AF4'}
{'Fp1', 'Fp2'}
'blinkFeedback'
'on' or 'off'
String turning on feedback of blink threshold value for each component in the command window. (Useful for determining a suitable threshold).
'on'
'off'
Lateral eye movement
'move'
'on' or 'off'
A string which turns on lateral eye movement detection.
'off'
'on'
'moveThresh'
integer
Integer determining the threshold for detecting components representing lateral eye movements.
2.5
2
'moveElecs'
{'string','string'}
Cell with the two electrodes for movement detection. The two electrodes on either side of the forehead are best for this purpose.
{'F9', 'F10'}
{'F7', 'F8'}
'moveFeedback'
'on' or 'off'
String turning on feedback of lateral eye movement threshold value for each component in the command window. (Useful for determining a suitable threshold).
'on'
'off'
Persistent muscle activity
'muscle'
'on' or 'off'
A string which turns on persitant muscle activity detection.
'off'
'on'
'muscleThresh'
integer
Integer determining the threshold for detecting components representing persistent muscle activity (slope of log-log linear fit).
-0.72
-0.31
'muscleFreqIn'
[int, int]
A vector with the frequency limits for including in the slope analysis. Leave empty to include all of the frequency spectra. [7,70] is recommended.
[7,70]
[]
'muscleFreqEx'
[int, int]
A vector with frequencies to exclude (e.g due to line noise). Leave empty to include all of the frequency spectra.
[48, 52]
[]
'muscleFeedback'
'on' or 'off'
String turning on feedback of persistent muscle activity threshold value for each component in the command window. (Useful for determining a suitable threshold).
'on'
'off'
Persistent muscle activity (legacy)
'muscleLegacy'
'on' or 'off'
Call this key/value pair to turn on TESA legacy heuristic (e.g. comparing the mean values between a target window and the remaining window using a ratio)
'on'
'off'
'muscleFreqWin'
[int, int]
A vector with the frequencies for the target window (in Hz).
[3, 100]
[]
Electrode noise
'elecNoise'
'on' or 'off'
A string which turns on electrode noise detection.
'off'
'on'
'elecNoiseThresh'
integer
Integer determining the threshold for detecting components representing electrode noise.
5
4
'elecNoiseFeedback'
'on' or 'off'
String turning on feedback of electrode noise threshold value for each component in the command window. (Useful for determining a suitable threshold).
'on'
'off'

Outputs

Output
Description
EEG
EEGLAB EEG structure

Examples

EEG = pop_tesa_compselect( EEG, 'comps', 10, 'figSize', 'medium','plotTimeX',[-600,600], 'plotFreqX', [2,45] ); Changes the number of components to select, the size of the figure and the x axis' of the time course and frequency plots.
EEG = pop_tesa_compselect( EEG, 'elecNoise','off','blinkThresh',3,'blinkElecs',{'AF3','AF4'},'blinkFeedback','on'); Turn off electrode noise detection, change threshold for blinks to 3, change electrodes used to AF3 and AF4 and turn on the feedback of blink threhsolds for individual components in the command window.
EEG = pop_tesa_compselect( EEG, 'blink', 'off', 'move', 'off', 'muscle', 'off', 'elecNoise', 'off'); Just detect TMS-evoked muscle activity.
Last modified 1yr ago