TMS introduces various types of artefacts to EEG recordings, which can distort the neural signals transcranially evoked by the stimulation. Two major artefacts which can contaminate TMS-evoked potentials (TEPs) are large muscle artefacts (1) and peripherally evoked potentials (PEPs) (2). Both artefacts can be suppressed by SSP–SIR implemented in TESA. In addition to PEPs, SSP–SIR can be used to suppress any other type of undesirable EEG activity contained in the control EEGLAB structure, provided by the user.
Figure 1. Example of TMS–EEG data before and after applying SSP–SIR to suppress muscle artefacts using default settings.
Figure 2. Example of TMS–EEG data before and after applying SSP–SIR to suppress a control signal using default settings. Both TEPs and control signals were pre-processed and re-referenced to the common average before using SSP-SIR.

SSPSIR algorithm

SSP–SIR is a spatial filter, which takes two steps, signal-space projection (SSP) and source-informed reconstruction (SIR), to recover TMS-evoked neural responses. SSP estimates the signal subspace containing the targeted artefact (either TMS-evoked muscle artefacts or activity specific to a control condition) and removes it from the recorded data and the lead field. Subsequently, SIR takes the artefact-suppressed data and lead field to estimate the source of the suppressed signal in the brain using l2-minimum-norm estimate (MNE), and finally reconstructs estimated TMS-evoked neural activity in the sensor space using the original lead field. SIR attempts to restore the true TEP components, which might have been inevitably suppressed by SSP (due to their closeness to the origin of artefacts). The SIR step also interpolates the signals to any channel previously rejected from the analysis.
When rejecting muscle artefacts, the artefact subspace is estimated from the high-pass filtered data. This is based on the prior knowledge that true neuronal EEG data are pronounced at frequencies below 50 Hz, whereas muscle responses have a much broader frequency response. When taking this approach, it is assumed that the high-frequency muscle components span the whole muscle-artefact subspace and thus by projecting them out, also the low-frequency muscle artefact components are rejected.

Using tesa_sspsir

SSP–SIR requires a forward head model (lead-field matrix or gain matrix) to use MNE in the cleaning process. If an appropriate head model is not provided as an input by the user, the tesa_sspsir implementation uses a three-layer spherical head model and the theoretical 10–20 electrode locations in the EEGLAB EEG structure to compute the lead field. In most cases, the spherical lead field provides satisfactory results but, when possible, the use of anatomically accurate, subject-specific lead-field is recommended.

Important notes

1. The removal of muscle artefacts is based on estimating the muscle artefact subspace from high-frequency components of the data (the signals above 100 Hz). Therefore, it is FUNDAMENTALLY IMPORTANT to not low-pass filter the data aggressively prior to SSP–SIR. We recommend the higher cut-off frequency to be no less than 200 Hz prior to SSP–SIR.
2. When using custom lead fields, make sure that the channels are either in the same order as in the EEGLAB EEG data structure or channel order in the lead field is correctly specified in a separate file (as an input to leadfieldChansFile). If unexpected or peculiar changes are observed in the data due to SSP–SIR, check first that the channels are correctly defined both in the EEGLAB EEG structure and the applied lead field matrix. See more details about uploading lead-field matrices and specifying the channel order below.
As mentioned, tesa-sspsir can be used for two different purposes: i. to suppress muscle artefacts [1]; ii. to attenuate activity shared with a control condition [2]. Depending on the purpose of filtering, the inputs to some variables may change as explained in detail below.
Figure 3. Manually choosing the artefact dimensions from tesa_sspsir visualisation. When choosing “Plots” for parameter 5, three figures are generated by tesa_sspsir. If control data is selected, then only the last figure (bottom panel, Figure 3) is shown. The first image shows the average time courses of different PCs (upper left panel, Figure 1), the second image shows the time frequency presentations of the PCs (upper right panel, Figure 2), and the last image (bottom panel, Figure 3) shows the magnitude of the high-frequency activity explained by different PCs. In this example, the three figures suggest two PCs (artefact dimensions) to be removed. The first two PC show strong sharp responses right after the TMS pulse; characterizing muscle artefacts. Similarly, these two biggest components show very broadband responses consisting of frequencies that are too high for neuronal EEG. The last figure shows that these two components explain most of the high-frequency signal, suggesting that by removing them, we remove the majority of the muscle-artefact data.- If chosen, you need to define the number of PCs to be removed in “number of PCs” (6).


[1] Mutanen, T. P., Kukkonen, M., Nieminen, J. O., Stenroos, M., Sarvas, J., & Ilmoniemi, R. J. (2016). Recovering TMS-evoked EEG responses masked by muscle artifacts. Neuroimage, 139, 157-166.
[2] Biabani, M, Fornito, A, Mutanen, T. P., Morrow, J, & Rogasch, N. C. (2019). Characterizing and minimizing the contribution of sensory inputs to TMS-evoked potentials. Brain Stimulation.

EEGLAB user interface

Depending on the choices made when defining input to the GUI, some fields may become disabled/activated as required.
1. Load a custom lead-field matrix (optional). SSP–SIR requires a forward model of the head for solving the MNE. Users can either provide an individualised/custom lead field, or use the TESA default. For custom lead fields, save the lead field matrix in. mat format. The saved file should only contain an n x m lead-field matrix, n being the number of channels and m the sources in the lead field. If no lead-field is provided by the user, TESA automatically uses a spherical three-layer model and the theoretical electrode positions to compute a lead-field matrix.
2. Load the lead field channel matrix (channelName x 1) (optional). When using a custom lead-field matrix, the user can specify the channel order in the lead field as an input parameter: The input is a file path to a cell array containing the names of the EEG electrodes corresponding to the n dimension in the lead field, saved in a .mat format. For SSP–SIR to work correctly, it is essential that the channels in the EEG dataset and those in the uploaded lead field are defined correctly. TESA sorts the provided lead field channel order to match EEGLAB data based on the order of channels provided in this input.
3. Choose the method to estimate the artefacts in the PCA.
If using the function to suppress muscle artefact, choose ‘automatic’, ‘manual’ or ‘manualConstant’:
'automatic' (default)- Uses a sliding window to first estimate the relative power of muscle artefacts as a function of time. The obtained weighting function is used: 1) to weight different samples when estimating the artefact subspace; and 2) to proportionally suppress different time points based on the relative artefact power defined by the artefact weighting. When this option is chosen, the parameter timeRange is not needed.
'manual'- Only uses the data within a window provided by the user in timeRange to estimate the muscle artefact subspace. Correspondingly, only the specified time window is suppressed from muscle artefacts.
'manualConstant': Works like 'manual' but projects out the artefact dimensions estimated from timeRange across the whole-time domain. Useful for the validation of SSPSIR. For instance, we might know that the muscle artefacts are only covering the first 30 ms after TMS. With this option, we can check from the deflections at 50 ms or later, how much the signals or interest might be over-corrected by SSP–SIR.
If using the function to suppress control data, choose ‘control’:
‘control’- If chosen, EEG_control(*.set) (8) becomes activate and you need to provide the path to the control data.
4. timeRange should be a vector with start and end times in ms of window containing the artefact, e.g., [5 50].
Not available for artScale 'automatic'.
Required for artScale 'manual'. The vector should be the window of time containing TMS-evoked muscle response (default 5,50 ms).
Optional for artScale 'control'. Vector with start and end times in ms of window containing control responses. If the control signal (artefact) is not well-characterized, it is recommended to leave timeRange empty and let the function take the whole signal as an artefact.
5. Choose the way you want to define the number of principle components (PCs) of the artefact to be removed.
plot- If chosen, the PC dimensions will be plotted and require the user to select the number of PCs for suppression (default). Please see Fig. 2 and the corresponding caption for practical instructions. The example shown in Fig. 2 corresponds to the data in Fig. 1.A.
N- If chosen, you need to define the number of PCs to be removed in “number of PCs” (6).
Data- If chosen, you need to define the % of the variance in the explained by PCs to be removed in “%of Variance” (6).
6. Specify the number of PCs to be removed- Enabled if ‘N’ is selected in option 5.
7. The truncation dimension used in the SIR step. If not provided, TESA estimates it from the EEG data as> rank(data) - PC.
8. Load the control data - enabled when the purpose of filtering is to suppress a control signal in TEPs (as specified in 3).


Base function

[EEG] = tesa_sspsir(EEG); %Default use
[EEG] = tesa_sspsir(EEG, 'key1’, value1...); %Custom input

Pop function

[EEG] = pop_tesa_ sspsir(EEG); %Pop up window
[EEG] = pop_tesa_ sspsir(EEG, 'key1’, value1...); %Custom input

Required inputs

EEGLAB EEG structure

Optional inputs (key/value pairs)

Input value
File path and name of individualised leadfield matrix (a channels x dipoles matrix containing individualised leadfield) IMPORTANT – The channel number and order must match the channels in the analysed EEGLAB structure OR the channel order should be sorted to match EEGLAB using the 'leadfieldChansFile' input below.
'C:\data\Le eadfield_Su bj1.mat'
A spherical three-layer model is used
File path and name of cell array listing the channel order of the individualised leadfield matrix.
If called, this command will load the indicated cell array and then sort the leadfield matrix channel order to match the EEGLAB data channel order.This is particularly important when the leadfield has been generated in another program, storing the channels in an order different from EEGLAB.
NOTE: the channel names must match those in the EEGLAB data.
‘/Users/my PC/Desktop /Leadfield
[ ]
'automatic' OR 'manual' OR 'manualConstant' OR 'control'
Determines the method to estimate the artefacts in the PCA. If using the function to suppress muscle artefact, choose ‘automatic’, ‘manual’ or ‘manualConstant’, depending on your preferred method, and choose ‘control’ only if using the function to suppress control data.
(only suppresses muscle artefacts)
[start, end]
the window of time(ms) in EEG recordings that contain the artefact. Disabled for artScale = automatic.
'plot' OR 'N' OR 'Data'
Determines the method to define the number of principle components (PCs) of the artefact to be removed. If ‘plot’ is chosen, the function plots the dimensions of the artefact as a line graph and the user needs to click on the line to choose the number of PCs. If ‘N’ or ’Data’ is chosen the user will need to specify the number of components or the percentage of variance, as the next variable, respectively.
‘Number of PCs’
‘% of variance’
Depends on the input to ‘PC’: if ‘PC’ = N; m should be the number of principal components to remove. Whereas, if ‘PC” = ‘Data’, m should be the %of variance in the artefacts (the function will then calculate and remove the number of principal components explaining m% of variance in the artefact).
(For ‘PC’ = ‘N’)
(For ‘PC’ = ‘Data’)
The truncation dimension used in the SIR step.
rank(data) -PC
File path and name of the EEGLAB EEG structure containing the control data. Only enabled for ‘artScale’ = ‘control’.
/control Response


Output of SSPSIR applied on single trials as an EEGLAB EEG structure
EEG.meanTrials is the output of SSPSIR applied to the average of all trials


[EEG] = pop_tesa_sspsir(EEG);
%default use
[EEG] = pop_tesa_sspsir(EEG, 'artScale', 'manual','timeRange’, [5,50], 'PC', {'data', [90]});
%Suppresses muscle artefacts by removing the data components explaining more than 90% of variance in the time window of 5-50ms
[EEG] = pop_tesa_sspsir(EEG, 'artScale', 'control','PC’, [5], 'EEG_control', ['/Users/myPC/Desktop/controlResponse.set/']);
%Suppresses control data by removing the first 5 principal components of controlResponse.Data from
Last modified 1yr ago