# Quantum Support Vector Machine Applied to the
Classication of EEG Signals with Riemanian Geometry

Anton Andreev, Grégoire Cattan

► To cite this version:

Anton Andreev, Grégoire Cattan. Quantum Support Vector Machine Applied to the Classication of EEG Signals with Riemanian Geometry. 1, GIPSA-lab; IBM. 2023. hal-03939121

HAL Id: hal-03939121

https://hal.science/hal-03939121

Submitted on 14 Jan 2023

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 Support Vector Machine Applied to the Classification of EEG Signals with Riemannian Geometry

Anton Andreev<fnref n="1" />[0000-0002-4466-4525] and Grégoire Cattan<fnref n="2" />[0000-0002-7515-0690]

**Abstract.** In this work we explored the performance of a quantum-enhanced support vector machine versus linear discriminant analysis, for the classification of electroencephalography (EEG) recordings. The data were prepared and vectorized using Riemannian Geometry, a ubiquitous method for EEG analysis. The results demonstrate that quantum classification achieved a good performance, although lower than the one achieved with LDA. We conclude that quantum computation does not provide an advantage as compared to classical computation for the classification of well-separable data. Further studies needs to investigate if quantum computation could offer an advantage in situations where classical classification fails.

**Keywords:** Quantum Support Vector Machine · Electroencephalography (EEG) · Riemannian Geometry

## 1 Introduction

Literature on quantum computing suggests it may offer an advantage as compared with classical computing in terms of computational time and outcomes, such as for pattern recognition or when using limited training sets [14, 5].

A ubiquitous library on quantum computing is Qiskit [1]. Qiskit is an IBM library distributed under Apache 2.0 which provides both quantum algorithms and backends. A backend can be either your local machine or a remote machine, which one can emulates or be a quantum machine. Qiskit abstraction over the type of machine you want to use, make designing quantum algorithm seamless.

Qiskit implements a quantum version of support vector -like classifier, known as quantum-enhanced support vector classifier (QSVC) [10]. QSVC likely offers an advantage over classical SVM in situations where the classification task is complex. Task complexity is raised by the encoding of the data into a quantum state, the number of available data and the quality of the data.

In [6], we suggested that quantum classification might have a tremendous potential for brain-computer interface relying on electroencephalography (EEG). Based on this idea, we investigated the feasability of quantum classification of EEG signals [7], by using QSVC in combination with Riemannian Geometry -

<footnote n="1">¹ GIPSA-lab, Grenoble, FR andreev.anton@gipsa-lab.grenoble-inp.fr</footnote>

<footnote n="2">² IBM Software, Kraków, PL gregoire.cattan@ibm.com</footnote>
an ubiquitous framework for EEG analysis which have demonstrated excellent
results in international competition [12]. The study demonstrated the feasability
of such classification thanks to Qiskit and pyRiemann [2], a python library for
the manipulation of time-series data using Riemannian Geometry.

In this paper, we compare the testing accuracy of QSVC as compared to
a standard classifier based on discriminant linear analysis (LDA). The results
show that the performance of QSVC is correct (mean > 0.7), although the LDA
classifier obtained a better score (mean 0.9). The article is organized as follows.
Fist section contains a description of the data. Second section describes our
method. Third section holds our results, conclusion and discussion.

## 2 Data

We used the 'BI.EEG.2012-GIPSA' dataset recorded at GIPSA-lab (Saint-Martin-d'Hères, France), which are freely available on Zenodo (Geneve, Switzerland) <fnref n="1" />.

This dataset contains the (noninvasive) EEG recordings of 26 participants (seven female) with a mean (SD) age of 24.4 (2.76) who attended a visual P300 TARGET / NON-TARGET experiment. The visual P300 is an endogenous ERP peaking at 240-600 ms after the appearance of a visual stimulation on screen. Unlike short-latency exogenous components, which are automated and sensory responses to a stimulation, endogenous components reflect a neural processing, which is solely task-dependent [13]. In particular, the P300 is elicited by the appearance of an improbable and highly distinct stimulation (i.e., the oddball paradigm).

The participants played Brain Invaders, a BCI version of the famous vintage game Space Invaders (Taito, Tokyo, Japan), consisting of 36 aliens displayed in a 6 × 6 matrix. The participants' task consisted of counting the number of flashes of a TARGET alien, which was designated at the beginning of each set of eight repetitions. In the Brain Invaders P300 paradigm, a repetition is composed of 12 flashes, of which two include the TARGET alien and 10 do not (NON-TARGET). For each participant, there were a total of eight randomly predefined TARGET aliens. Therefore, a total of (resp.) 128 (8 × 8 × 2) and 640 (8 × 8 × 10) TARGET and NON-TARGET trials were recorded for each participant during the experiment

EEG signals were acquired using a NeXus-32 biofeedback system (MindMedia, Herten, Germany), consisting of a research-grade amplifier and a EEG cap. The cap was equipped with 16 Silver/Silver Chloride wet electrodes placed according to the 10-20 international system (F7, F3, F4, F8, T7, C3, CZ, C4, T8, P7, P3, PZ, P4, P8, O1 and O2), with FZ as a ground. Note that the NeXus-32 headset does not use an electrode as a reference; rather, a hardware common average reference is used.

The amplifier was linked by USB connection to the PC where the data were
acquired by means of the software OpenVibe [15]. Data were acquired at a sam-
pling frequency of 128 samples per second. For ensuing analysis, the application

<footnote n="1">¹ https://zenodo.org/record/2649069</footnote>
tagged the EEG using software tagging. The tags were sent by the application to the OpenVibe plateform thanks to the Boost inter-process messaging <fnref n="3" />. Note that the tagging process introduces a jitter and a latency which artificially mod- ify the ERPs onset. These belong to the hardware and software components of the experiment. In particular, a disadvantage of software tagging is a strong drift over time, resulting in higher jitter. As a consequence, it is only possible to compare the ERP acquired within the same experimental conditions when the latency is not corrected [8].

A complete description of the dataset is available in [17].

## 3 Methods

Data were filtered between 1 and 24 Hz using a zero-phase IR filter with a ham- ming window. We extracted all TARGET (n = 128) and NON-TARGET (n = 640) epochs starting from 100 ms to 700 ms after the onset of stimulation, and applied a spatial filter using xDAWN (number of filters = 2) [16]. The number of filter was determined using a trial-error approach. The use of a spatial filter allowed us to reduce the epochs' dimensionality (and therefore the computation time), while improving the signal-to-noise ratio. We then transformed epochs into symmetric positive definite (SPD) correlation matrices using the method described in [9]. The matrices contained 64 elements (8 × 8). Considering the Riemannian geometry of SPD matrices, we vectorized these matrices by projec- tion into the tangent space of the Riemannian manifold [4]. All vectors contained 36 elements (8 x [8 + 1] / 2). We finally applied a principal component analysis to reduce the size of the feature vectors from 36 to 10 elements. The limit of 10 elements was set considering the computational limitation of the quantum emulator.

Data were linearly entangled using a second-order Pauli-Z evolution cir- cuit (the so-called ZZFeatureMap in Qiskit). The number of repetitions for the ZZFeatureMap was set to 2 and the number of shots was set to 1024. The quan- tum computer was emulated using QasmSimulator [1]. Data entanglement was only required for QSVC.

Data were then passed as input to a QSVC and LDA classifier.

*Performance assessment* The performance of QSVC and LDA was assessed with five-fold cross validation and measured using the area-under the curve of the clas- sifier. To avoid implementation biases, performance was assessed within MOABB [11, 3], a BCI benchmark for reproducible. The code for this paper is available online <fnref n="2" />

<footnote n="3">³ https://theboostcpplibraries.com/</footnote>

<footnote n="2">² https://github.com/pyRiemann/pyRiemann-qiskit/blob/main/examples/ERP/classify_P300_bi.py</footnote>
# 4 Results, Conclusion and discussion

*Results* Figure 1 contains the scatter plot of the results obtained with our two pipelines (Riemannian Geometry plus either QSVC or LDA). The AUC was 0.88 and 0.72 for the classical and quantum pipeline respectively.

<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Scatter plots: AUC as a function of the pipeline, that is Riemannian Geometry plus quantum (RG+QuantumSVM) or classical (RG+LDA) computation. Each point corresponds to a participant in the datasets (26 + 24 subjects in total).</figcaption></figure>

*Conclusion and discussion* The results suggests that QSVC achieved a good performance, but still lower than a standard pipeline with LDA. However classical classification already provided good results with the data. In order to demonstrate a quantum advantage, it would have been better to include data where the classical classification failed. In addition, the hyper parameters of the model such as the number of shots and the entanglement methods was chosen arbitrary as we experienced computational issues with the simulator. In fact, it is possible that with a set of parameters chosen through a systematic method, the results would have been better.

Finally, our pipelines rely on the vectorization of the input matrices using the tangent space of the riemanian manifold. Vectorization implies dimensionality reduction and therefore loss of information. It exists other algorithms as minimum-distance-to-means (MDM) that directly take matrices as an input. The MDM algorithm is an optimization problem and thereby can be espressed using constraining programming. Qiskit directly accepts constraint programming models to solve binary and unconstrained optimization problems. One possible axe of research is to implement a convex model of the MDM which respects Qiskit
contraints (binary and unconstrained variables), or to enable Qiskit optimization
to solve problems containing continuous variables.

References

1. Abraham, H., AduOffei, Agarwal, R., Akhalwaya, I.Y., Aleksandrowicz, G., Alexander, T., Arbel, E., Asfaw, A., Azaustre, C., AzizNgoueya, Bansal, A., Barkoutsos, P., Barron, G., Bello, L., Ben-Haim, Y., Bevenius, D., Bishop, L.S., Bolos, S., Bosch, S., Bravyi, S., Bucher, D., Burov, A., Cabrera, F., Calpin, P., Capelluto, L., Carballo, J., Carrascal, G., Chen, A., Chen, C.F., Chen, E., Chen, J.C., Chen, R., Chow, J.M., Churchill, S., Claus, C., Clauss, C., Cocking, R., Cross, A.J., Cross, A.W., Cross, S., Cruz-Benito, J., Culver, C., Córcoles-Gonzales, A.D., Dague, S., Dandachi, T.E., Daniels, M., Dartiailh, M., DavideFrr, Davila, A.R., Dekusar, A., Ding, D., Doi, J., Drechsler, E., Drew, Dumitrescu, E., Dumon, K., Duran, I., EL-Safty, K., Eastman, E., Eendebak, P., Egger, D., Everitt, M., Fernández, P.M., Ferrera, A.H., Fouilland, R., FranckChevallier, Frisch, A., Fuhrer, A., GEORGE, M., Gacon, J., Gago, B.G., Gambella, C., Gambetta, J.M., Gammanpila, A., Garcia, L., Garion, S., Gilliam, A., Giridharan, A., Gomez-Mosquera, J., González, S.d.I.P., Gorzinski, J., Gould, I., Greenberg, D., Grinko, D., Guan, W., Gunnels, J.A., Haglund, M., Haide, I., Hamamura, I., Hamido, O.C., Havlicek, V., Hellmers, J., Herok, \., Hillmich, S., Horii, H., Howington, C., Hu, S., Hu, W., Huisman, R., Imai, H., Imamichi, T., Ishizaki, K., Iten, R., Itoko, T., JamesSeaward, Javadi, A., Javadi-Abhari, A., Jessica, Jivrajani, M., Johns, K., Jonathan-Shoemaker, Kachmann, T., Kanazawa, N., Kang-Bae, Karazeev, A., Kassebaum, P., King, S., Knabberjoe, Kobayashi, Y., Kovyrshin, A., Krishnakumar, R., Krishnan, V., Krsulich, K., Kus, G., LaRose, R., Lacal, E., Lambert, R., Lapeyre, J., Latone, J., Lawrence, S., Lee, C., Li, G., Liu, D., Liu, P., Maeng, Y., Malyshev, A., Manela, J., Marecek, J., Marques, M., Maslov, D., Mathews, D., Matsuo, A., McClure, D.T., McGarry, C., McKay, D., McPherson, D., Meesala, S., Metcalfe, T., Mevissen, M., Mezzacapo, A., Midha, R., Minev, Z., Mitchell, A., Moll, N., Mooring, M.D., Morales, R., Moran, N., MrF, Murali, P., Müggenburg, J., Nadlinger, D., Nakanishi, K., Nannicini, G., Nation, P., Navarro, E., Naveh, Y., Neagle, S.W., Neuweiler, P., Niroula, P., Norlen, H., O'Riordan, L.J., Ogunbayo, O., Ollitrault, P., Oud, S., Padilha, D., Paik, H., Pang, Y., Perriello, S., Phan, A., Piro, F., Pistoia, M., Piveteau, C., Pozas-iKerstjens, A., Prutyanov, V., Puzzuoli, D., Pérez, J., Quintiii, Rahman, R.I., Raja, A., Ramagiri, N., Rao, A., Raymond, R., Redondo, R.M.C., Reuter, M., Rice, J., Rodríguez, D.M., RohithKarur, Rossmannek, M., Ryu, M., SAPV, T., SamFerracin, Sandberg, M., Sapra, R., Sargsyan, H., Sarkar, A., Sathaye, N., Schmitt, B., Schnabel, C., Schoenfeld, Z., Scholten, T.L., Schoute, E., Schwarm, J., Sertage, I.F., Setia, K., Shammah, N., Shi, Y., Silva, A., Simonetto, A., Singstock, N., Siraichi, Y., Sitdikov, I., Sivarajah, S., Sletfjerding, M.B., Smolin, J.A., Soeken, M., Sokolov, I.O., SooluThomas, Starfish, Steenken, D., Stypulkoski, M., Sun, S., Sung, K.J., Takahashi, H., Tavernelli, I., Taylor, C., Taylour, P., Thomas, S., Tillet, M., Tod, M., Tomasik, M., Torre, E.d.l., Trabing, K., Treinish, M., TrishaPe, Turner, W., Vaknin, Y., Valcarce, C.R., Varchon, F., Vazquez, A.C., Villar, V., Vogt-Lee, D., Vuillot, C., Weaver, J., Wieczorek, R., Wildstrom, J.A., Winston, E., Woehr, J.J., Woerner, S., Woo, R., Wood, C.J., Wood, R., Wood, S., Wood, S., Wootton, J., Yeralin, D., Yonge-Mallo, D., Young, R., Yu, J., Zachow, C., Zdanski, L., Zhang, H., Zoufal, C., Zoufalc, a-kapila,
a-matsuo, bcamorrison, brandhsn, chlorophyll-zz, dekel.meirom, dekool, dime10, drholmie, dtrenev, ehchen, elfrocampeador, faisaldebouni, fanizzamarco, gadial, gruu, hhorii, hykavitha, jagunther, jliu45, kanejess, klinvill, kurarrr, lerongil, ma5x, merav-aharoni, michelle4654, ordmoj, rmoyard, saswati-qiskit, sethmerkel, strick-roman, sumitpuri, tigerjack, toural, vvilpas, welien, willhbang, yang.luh, yotam-vaknibm, Čepulkovskis, M.: Qiskit: An Open-source Framework for Quantum Computing (2019). https://doi.org/10.5281/zenodo.2562110

2. Barachant, A.: pyRiemann (2015), https://github.com/pyRiemann/pyRiemann, original-date: 2015-04-19T16:01:44Z

3. Barachant, A.: Mother of All BCI Benchmarks. (2017), https://github.com/NeuroTechX/moabb

4. Barachant, A., Bonnet, S., Congedo, M., Jutten, C.: Multiclass brain-computer interface classification by Riemannian geometry. IEEE transactions on bio-medical engineering 59(4), 920-928 (2012). https://doi.org/10.1109/TBME.2011.2172210

5. Blance, A., Spannowsky, M.: Quantum machine learning for particle physics using a variational quantum classifier. Journal of High Energy Physics 2021(2), 212 (Feb 2021). https://doi.org/10.1007/JHEP02(2021)212, https://doi.org/10.1007/JHEP02(2021)212

6. Cattan, G.: The Use of Brain-Computer Interfaces in Games Is Not Ready for the General Public. Frontiers in Computer Science 3 (Mar 2021). https://doi.org/10.3389/fcomp.2021.628773, https://hal.archives-ouvertes.fr/hal-03182066, publisher: Lausanne: Frontiers Media SA

7. Cattan, G., Andreev, A.: First steps to the classification of ERPs using quantum computation. In: NTB Berlin 2022 - International Forum on Neural Engineering & Brain Technologies. Berlin, Germany (May 2022), https://hal.archives-ouvertes.fr/hal-03672246

8. Cattan, G., Andreev, A., Maureille, B., Congedo, M.: Analysis of tagging latency when comparing event-related potentials. Technical Report 1, Gipsa-Lab ; IHMTEK, Grenoble (2018), https://hal.archives-ouvertes.fr/hal-01947551

9. Congedo, M.: EEG Source Analysis. thesis, Université de Grenoble (Oct 2013), https://tel.archives-ouvertes.fr/tel-00880483

10. Havlíček, V., Córcoles, A.D., Temme, K., Harrow, A.W., Kandala, A., Chow, J.M., Gambetta, J.M.: Supervised learning with quantum-enhanced feature spaces. Nature 567(7747), 209-212 (Mar 2019). https://doi.org/10.1038/s41586-019-0980-2, https://www.nature.com/articles/s41586-019-0980-2, bandiera_abtest: a Cg_type: Nature Research Journals Number: 7747 Primary_atype: Research Publisher: Nature Publishing Group Subject_term: Computer science;Quantum information;Quantum simulation;Qubits;Statistics Subject_term_id: computer-science;quantum-information;quantum-simulation;qubits;statistics

11. Jayaram, V., Barachant, A.: MOABB: trustworthy algorithm benchmarking for BCIs. Journal of Neural Engineering 15(6), 066011 (Sep 2018). https://doi.org/10.1088/1741-2552/aadea0, https://iopscience.iop.org.gaelnomade-1.grenet.fr/article/10.1088/1741-2552/aadea0/meta

12. Lotte, F., Bougrain, L., Cichocki, A., Clerc, M., Congedo, M., Rakotomamonjy, A., Yger, F.: A review of classification algorithms for EEG-based brain-computer interfaces: a 10 year update. Journal of Neural Engineering 15(3), 031005 (Apr 2018). https://doi.org/10.1088/1741-2552/aab2f2, https://doi.org/10.1088/1741-2552/aab2f2, publisher: IOP Publishing

13. Luck, S.J.: Event-related potentials. In: APA handbook of research methods in psychology, Vol 1: Foundations, planning, measures, and psychometrics,
pp. 523–546. American Psychological Association, Washington, DC, US (2012).
https://doi.org/10.1037/13619-028

14. Rebentrost, P., Mohseni, M., Lloyd, S.: Quantum Support Vector Machine for Big Data Classification. American Physical Society (Sep 2014), https://dspace.mit.edu/handle/1721.1/90391, accepted: 2014-09-26T14:53:32Z
Publisher: American Physical Society

15. Renard, Y., Lotte, F., Gibert, G., Congedo, M., Maby, E., Delannoy, V., Bertrand, O., Lécuyer, A.: OpenViBE: An Open-Source Software Platform to Design, Test, and Use Brain-Computer Interfaces in Real and Virtual Environments 19(1), 35–53 (2010).
https://doi.org/10.1162/pres.19.1.35, http://dx.doi.org/10.1162/pres.19.1.35

16. Rivet, B., Souloumiac, A.: Optimal linear spatial filters for event-related potentials based on a spatio-temporal model: Asymptotical performance analysis. Signal Processing 93(2), 387–398 (2013). https://doi.org/10.1016/j.sigpro.2012.07.019, https://hal.archives-ouvertes.fr/hal-00742644

17. Van Veen, G.F.P., Barachant, A., Andreev, A., Cattan, G., Coelho Rodrigues, P.L., Congedo, M.: Building Brain Invaders: EEG data of an experimental validation. Research Report 1, GIPSA-lab (2019), https://hal.archives-ouvertes.fr/hal-02126068