# Quantum Denoising for BCI: A Study

Ahmed Mostafa, Yash Chauhan, Wasif Ahmed, Grégoire Cattan, Marius Klug

► To cite this version:

Ahmed Mostafa, Yash Chauhan, Wasif Ahmed, Grégoire Cattan, Marius Klug. Quantum Denoising for BCI: A Study. 5th International Neuroergonomics Conference, University of Bordeaux, Jul 2024, Bordeaux, France. pp.494-499. hal-05020004

HAL Id: hal-05020004

https://hal.science/hal-05020004v1

Submitted on 3 Apr 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Quantum Denoising for BCI: A Study

Ahmed Mostafa<fnref n="1" />, Yash Chauhan<fnref n="2" />, Wasif Ahmed<fnref n="3" />, Gregoire Cattan<fnref n="4" />, Marius Klug<fnref n="5" />,<fnref n="6" />

## Synopsis

This research investigated self-supervised learning for EEG-based passive Brain-Computer Interfaces (pBCIs), focusing on quantum variational autoencoders (QVAE) for signal denoising. We trained a classifier on EEG data from tasks of varying difficulties and compared its performance with and without quantum denoising across sessions. Quantum denoising showed no benefit for feature extraction, and the two pipelines struggled to generalize due to dimensionality reduction. This study suggests that the latent space of the quantum encoder must be greater than 8 for EEG data.

## Background

A passive BCI is one that derives its outputs from arbitrary brain activity arising without the purpose of voluntary control, for enriching a human-machine interaction with implicit information on the actual user state (1). They are for example used to detect fatigue while driving or adapt the task difficulty to the cognitive workload. In order to become useful tools for interactivity and technological systems that are applied outside the research context, they require universal classifiers that work across sessions.

In this study, we hypothesize that the latent space of the autoencoder can capture the EEG inter-session variability, and we compare the performance of a linear discriminant analysis (LDA) classifier with and without QVAE.

The study utilized an open EEG dataset tailored for pBCIs (2), comprising EEG recordings from 15 participants (6 female, average age 25 years) with 62 active Ag–AgCl electrodes referenced to the right mastoid electrode. Participants engaged in 3 sessions, separated by 1 week. Each session began with a 1-minute resting-state recording (eyes open). Subsequently, participants undertook 3 tasks of varying difficulty levels (easy, medium, and difficult) in randomized order, following the MATB-II protocol. A 2-second non-overlapping epoch was obtained for each task.

<footnote n="1">¹October 6 University, Egypt</footnote>

<footnote n="2">²School of Physical Sciences, National Institute of Science Education and Research, India</footnote>

<footnote n="3">³Lahore University of Management Sciences, Pakistan</footnote>

<footnote n="4">⁴IBM Software, Data and AI, Poland</footnote>

<footnote n="5">⁵Chair of Neuroadaptive Human-Computer Interaction, Brandenburg University of Technology
Cottbus-Senftenberg, Germany</footnote>

<footnote n="6">⁶Young Investigator Group – Intuitive XR, Chair of Neuroadaptive Human-Computer Interaction,
Brandenburg University of Technology Cottbus-Senftenberg, Germany</footnote>
# Methods

## Preprocessing

The data already underwent preprocessing steps including a 1-40 Hz pass-band FIR filter, rejection of electrodes with average amplitude above 2 sd across channels followed by spherical interpolation for rejected channels, ICLabel rejection (heart, muscle and eye components with a threshold of 95%), and average re-referencing. We applied an additional downsampling to 128 Hz and a 1-35 Hz pass-band IIR filter. Easy (n = 149) and medium-difficulty (n = 149) epochs from 0 to 1 s after stimulation onset were extracted (i.e., 64 samples by epoch). Spatial filtering using xDAWN (number of filters = 4, i.e., 8 channels) (3) was applied to reduce computation time while improving the signal-to-noise ratio.

## Quantum-Denoising

We applied quantum denoising to the data and compared the pipeline's performance with and without this step. The quantum denoising process utilized a quantum autoencoder, which is a variational quantum circuit containing parametric gates with weights (referred as ansatz) determined through loss function optimization (4). In this work, we use a specialized version of this circuit called the RealAmplitudes ansatz (5). Variational quantum circuits are analogous to neural networks.

EEG epochs (149 + 149 trials, 8 channels, 64 samples) were vectorized (512 samples) and passed as input to a QVAE. It consisted of a 9-qubit parameterized quantum circuit using the RealAmplitudes ansatz from Qiskit as the encoder circuit. The number of qubits is determined based on the number of samples (512 samples = $2^9$). 8 qubits were used for the latent space, and 1 qubit for the trash space. Reconstruction fidelity was measured using a SWAP test (6) between the encoded input and decoded output states. The fidelity loss was optimized using Simultaneous Perturbation Stochastic Optimization (SPSA) (7, 8). SPSA is a local optimization algorithm that converges well and rapidly in many dimensions. The maximum of iteration was set to 100, rejecting updates that increased the loss (Blocking = True). Learning rate and perturbation were determined through autocalibration. The output EEG data vectors (512 samples) were reshaped into matrices of size 8 x 64.

## Feature extraction

After preprocessing and denoising, the epochs of the signal (denoted as $X_i$) were transformed into symmetric positive definite (SPD) sample covariance matrices (SCMs) defined by:

$$C_i = \frac{1}{N} X_i X_i^T, \text{ where N is the number of samples.}$$

The matrices contained 64 (8 x 8) components. Considering the Riemannian geometry of SPD matrices, we vectorized these matrices by projection into the tangent space of the Riemannian manifold (9). All vectors contained 2080 components (64 x [64 + 1] / 2) and were passed to a LDA classifier.
## Evaluation

The LDA performance (with and without quantum denoising) was assessed with a 5-fold, cross-validation, cross-session evaluation and measured using the area under the curve (AUC) of the classifier. To avoid implementation bias, spatial filtering and feature extraction was done with pyRiemann (10), and performance was assessed within MOABB (11, 12), a BCI library offering a standardized implementation for cross-subject, within and cross-session evaluations. Note that our implementation of QVAE is made available in pyRiemann-qiskit (13).

## Results

The performance and execution time of the LDA classifier without and with QVAE are reported in TABLE I.

<table><caption>TABLE I. Score and time required for the classification.</caption><thead><tr><td>Pipeline</td><td>AUC (sd)</td><td>Time (sd) in seconds</td></tr></thead><tbody><tr><td>LDA</td><td>0.58 (0.04)</td><td>0.33 (0.02)</td></tr><tr><td>LDA+QVAE</td><td>0.51 (0.01)</td><td>11029.03 (28.73)</td></tr></tbody></table>

TABLE I highlights the computational complexity of LDA+QVAE as compared to LDA (0.33 vs 11029.03 respectively). The performance of LDA alone (AUC=0.58) is greater than the performance of LDA+QVAE (AUC=0.51). The significance threshold of the dataset was estimated using permutation testing (14). Significance is reached at 55.70% or 166 correct classification (α = 0.05). This suggests that QVAE might not have captured sufficient information in its latent space. This is confirmed by the average fidelity: 0.57 (sd=0.05).

The cost functions for the minimum and maximum fidelities are depicted in FIG 1.
<figure><img src="image_2.png" /><figcaption>FIG. 1. Cost functions of SPSA.</figcaption></figure>

The FIG. 1 shows that between 250 and 350 cost function calls were necessary for the function to converge. Note that the number of cost function calls does not necessarily match the number of iterations. The 50 first function calls correspond to autocalibration.

Discussion

This study is an original approach of using quantum autoconder for signal denoising. The study compares the performance of two pipelines, with and without QVAE, across sessions. The AUC of the classifiers with and without QVAE was 0.51 and 0.58 respectively. Our study has limitations due to the computational complexity of QVAE. For this reason, only 8 out of 64 EEG components were selected with xDAWN. The data dimensionality was further reduced by projecting the SCMs into the tangent space of the Riemannian manifold. Using more components could have preserved more salient information, potentially improving the results for both quantum and classical pipelines. Additionally, the QVAE used a small latent space of 8 qubits and 1 trash qubit, likely limiting the representational capacity for encoding complex signal features. Another limitation is that xDAWN is mostly designed for oscillatory activity classification, and may not be suitable for the current application.

Despite the preliminary results not demonstrating quantum advantage for signal denoising, publishing negative results is considered as a good practice in the field of BCI (15). This research lays a foundation for future investigations in quantum computing applications in neuroscience and BCIs. The identified research directions have the potential to address the limitations and advance quantum-assisted EEG signal processing at the intersection of quantum computing and BCIs.
References

[1] Zander, T. O., and Kothe, C. (2011). Towards passive brain–computer interfaces: applying brain–computer interface technology to human–machine systems in general. *J. Neural Eng.* 8, 025005. doi: [10.1088/1741-2560/8/2/025005](https://doi.org/10.1088/1741-2560/8/2/025005)

[2] Hinss, M. F., Darmet, L., Somon, B., Jahanpour, E., Lotte, F., Ladouce, S., et al. (2021). An EEG dataset for cross-session mental workload estimation: Passive BCI competition of the Neuroergonomics Conference 2021. doi: [10.5281/ZENODO.5055046](https://doi.org/10.5281/ZENODO.5055046)

[3] Rivet, B., and Souloumiac, A. (2013). Optimal linear spatial filters for event-related potentials based on a spatio-temporal model: Asymptotical performance analysis. *Signal Processing* 93, 387–398. doi: [10.1016/j.sigpro.2012.07.019](https://doi.org/10.1016/j.sigpro.2012.07.019)

[4] Romero, J., Olson, J. P., and Aspuru-Guzik, A. (2017). Quantum autoencoders for efficient compression of quantum data. *Quantum Sci. Technol.* 2, 045001. doi: [10.1088/2058-9565/aa8072](https://doi.org/10.1088/2058-9565/aa8072)

[5] He, G. P. (2023). Computing the gradients with respect to all parameters of a quantum neural network using a single circuit. doi: [10.48550/arXiv.2307.08167](https://doi.org/10.48550/arXiv.2307.08167)

[6] Buhrman, H., Cleve, R., Watrous, J., and de Wolf, R. (2001). Quantum fingerprinting. *Phys. Rev. Lett.* 87, 167902. doi: [10.1103/PhysRevLett.87.167902](https://doi.org/10.1103/PhysRevLett.87.167902)

[7] Spall, J. C. (2012), "Stochastic Optimization," in Handbook of Computational Statistics: Concepts and Methods (2nd ed.) (J. Gentle, W. Härdle, and Y. Mori, eds.), Springer-Verlag, Heidelberg, Chapter 7, pp. 173–201. doi: [10.1007/978-3-642-21551-3_7](https://doi.org/10.1007/978-3-642-21551-3_7)

[8] Spall, J. C. (1999), "Stochastic Optimization: Stochastic Approximation and Simulated Annealing," in Encyclopedia of Electrical and Electronics Engineering (J. G. Webster, ed.), Wiley, New York, vol. 20, pp. 529–542

[9] Barachant, A., Bonnet, S., Congedo, M., and Jutten, C. (2012). Multiclass Brain–Computer Interface Classification by Riemannian Geometry. *IEEE Trans. Biomed. Eng.* 59, 920–928. doi: [10.1109/TBME.2011.2172210](https://doi.org/10.1109/TBME.2011.2172210)

[10] Barachant, A., Barthélemy, Q., King, J.-R., Gramfort, A., Chevallier, S., Rodrigues, P. L. C., et al. (2023). *pyRiemann/pyRiemann*: v0.5. doi: [10.5281/zenodo.8059038](https://doi.org/10.5281/zenodo.8059038)

[11] Jayaram, V., and Barachant, A. (2018). MOABB: trustworthy algorithm benchmarking for BCIs. *J. Neural Eng.* 15, 066011. doi: [10.1088/1741-2552/aadea0](https://doi.org/10.1088/1741-2552/aadea0)

[12] Aristimunha, B., Carrara, I., Guetschel, P., Sedlar, S., Rodrigues, P., Sosulski, J., et al. (2023). Mother of all BCI Benchmarks. doi: [10.5281/ZENODO.10034224](https://doi.org/10.5281/ZENODO.10034224)

[13] Andreev, A., Cattan, G., Chevallier, S., and Barthélemy, Q. (2023). *pyRiemann-qiskit: A Sandbox for Quantum Classification Experiments with Riemannian Geometry*. *Research Ideas and Outcomes* 9. doi: [10.3897/rio.9.e101006](https://doi.org/10.3897/rio.9.e101006)
[14] Mueller-Putz, G., Scherer, R., Brunner, C., Leeb, R., and Pfurtscheller, G. eds. (2008).
Better than random: A closer look on BCI results. *International Journal of Bioelectromagnetism*.
10, 52-55.

[15] Lotte, F., Jeunet, C., Chavarriaga, R., Bougrain, L., Thompson, D. E., Scherer, R., et al. (2019). Turning negative into positives! Exploiting ‘negative’ results in Brain–Machine Interface (BMI) research. *Brain-Computer Interfaces* 6, 178–189. doi: [10.1080/2326263X.2019.1697143](https://doi.org/10.1080/2326263X.2019.1697143)