Motion artifact removal using Artifact Subspace Reconstruction

  • out-of-lab
  • how-to

What’s the challenge?

EEG signal amplitudes are really small (at the order of [µV]) and the recorded signal can be corrupted by artifacts coming from literaly anywhere. This is especially challenging in cases when subjects are moving, as a movement elicits a number of different artifact sources that are all stronger than the EEG signal itself. These artifacts are coming from neck, jaw, teeth clenching, or even just due to the micro-movements of EEG electrodes in respect to the scalp.

Now, these artifacts are extremely complex to detect, and even more complex to remove from the EEG signal when we want to obtain clean EEG. Why? Well, for several reasons:

  1. The frequency band of the signals is overlapping with the useful EEG;
  2. The signals may be uncorrelated in the electrode space, and therefore cannot be easily removed by principal or independent component analysis or similar tools;
  3. Both EEG and the artifacts are non-stationary.

To deal with these artifacts, mbt implemented the real-time cleaning algorithm based on Artifact Subspace Reconstruction (ASR) in SMARTING PRO. The ASR algorithm is developed by the scientists from University of California San Diego and will be outlined further in the text. This algorithm takes chunks of data and assesses whether the data is artifact free or not. Only in the case when the algorithm detects artifacts, it goes into the procedure of cleaning the data. The above corrupted EEG data, when cleaned by the algorithm, are shown in the figures below in red.

The algorithm works in two steps — Calibration and Processing, and I will take a cew paragraphs below to explain those steps. In the meantine, it is useful to say that the implementation of the algorithm is freely available from EEGLab, and we encourage you to try it out on your data.

Now, let’s take a deeper dive into what the algorithm actually does.

General Idea

The purpose of this article is not to be entirely mathematically correct, but to present the concept, and introduce the idea behind this algorithm.

The algorithm relies on the assumption that if Mr is the PCA Mixing Matrix of the “clean” or “calibration” signal

Then the signal window X at time t, Xt can be represented in the space of Mr, and the such that

where St are the latent sources, and so given that PCA(Xt) is

this means that the latent clean components (or sources) St(clean) can be derived as follows

In the above equation, the trunc denotes the truncated demixing matrix, where the artifact components are removed.

The entire workflow of ASR (as taken from Chang et al.) is depicted in the figure below



The first step of the algorithm is calibration. In the calibration step, the algorithm “learns” the “data principal components space” (in practice it compute covariance matrix) and uses the learned components in the further steps to assess whether a chunk of data is clean, or it is corrupted by artifacts.

However, the first step is to preserve the EEG-specific data (like alpha frequency), so that it never gets removed. This is achieved by subtracting the mean of the data and pushing the data through an IIR filter to remove alpha before computing PCA.

In the next step we compute the mixing matrix of the filtered data:

Then simply compute the root-mean square of the principal components and set the threshold for calibration at

where Г is the threshold matrix, μ and σ are the mean and standard deviations of the principal components and k is the parameter of the algorithm that regulates the threshold above which the principal components would be considered artifacts. This parameter is in regular applications of artifact cleaning usually set between 5 and 7.


After the algorithm has been calibrated (usually 30second to 2minute of data are needed for calibration), we can start with the processing step. The processing step takes short chunks of data (e.g. 64 samples), checks the data to assess whether the chunk contains artifact components or not (based on calibration) and if so, removes the artifact pricnipal components and substitutes them with the latent components from calibration.

To do this, the processing step first calculates the principal components of the windowed input signal Xt.

For each window, check if the j-th principal component Y with variance D larger than the rejection threshold Г, projected from Vr onto Vt.

If yes, replace the activation of that component with zeros (or truncate)

and reconstruct back the “clean” component as

Obviously, this processing step can be iteratively performed in real-time, and the real-time data cleaning can be achieved.

Wrap up

Artifact Subspace Reconstruction algorithms (ASR) successfully cleans artifact data from EEG. It is especially useful in non-stationary conditions, as it may handle artifacts coming from motion-related sources (such as muscles or electrode micro-movements).

To view the demonstration of real-time artifact cleaning with SMARTING PRO, check out the following video.

In the meantime read more about the algorithm and check the performance on a number of artifact-removal comparisons to other algorithms from the below resources.

Credits and references

•Mullen, T. R., Kothe, C. A., Chi, Y. M., Ojeda, A., Kerth, T., Makeig, S., … & Cauwenberghs, G. (2015). Real-time neuroimaging and cognitive monitoring using wearable dry EEG. IEEE Transactions on Biomedical Engineering62(11), 2553–2567.

•Chang, C. Y., Hsu, S. H., Pion-Tonachini, L., & Jung, T. P. (2019). Evaluation of Artifact Subspace Reconstruction for Automatic Artifact Components Removal in Multi-channel EEG Recordings. IEEE Transactions on Biomedical Engineering.

•Dereymaeker, A., Pillay, K., Vervisch, J., Van Huffel, S., Naulaers, G., Jansen, K., & De Vos, M. (2017). An automated quiet sleep detection approach in preterm infants as a gateway to assess brain maturation. International journal of neural systems27(06), 1750023.

Recommended reading