domain: scco info

text:
Marie-Constance Corsi
email: marieconstance.corsi@inria.fr

Chapter 9 Electroencephalography and Magnetoencephalography

Keywords: Electroencephalography, Magnetoencephalography, Evoked activity, Oscillatory activity, Brain-Computer Interfaces

In this chapter, we present the main characteristics of electroencephalography (EEG) and magnetoencephalography (MEG). More specifically, this chapter is dedicated to the presentation of the data, the way they can be acquired and analyzed. Then, we present the main features that can be extracted and their applications for brain disorders with concrete examples to illustrate them. Additional materials associated with this chapter are available in the dedicated Github repository.

Introduction

This chapter aims at providing an overview of electroencephalography (EEG) and magnetoencephalography (MEG) to help the reader with no previous experience with these modalities to understand the information that can be extracted, and their neurophysiological meaning in the perspective to be used for brain disorders. These two modalities, that share common characteristics, are often designated together with the acronym M/EEG.

To appear in O. Colliot (Ed.), Machine Learning for Brain Disorders, Springer

Corsi

To this end, instead of providing an exhaustive presentation of the M/EEG clinical applications, we focused on the main aspects related to these modalities. As a result, this chapter is organized as follows. We first describe the basic principles in terms of origins of the signals and electrophysiological activity exploited in M/EEG (Section 2). We then present the principles of M/EEG experiments (Section 3), the data analysis techniques (Section 4), and in particular features that can be extracted from the data (Section 5). The last part of this chapter presents illustrations of M/EEG applications to brain disorders (Section 6). To go further, additional resources are provided to the reader in Box 1, Box 2, and in a dedicated Github repository.

Basic principles

Being able to extract the information of interest to perform a classification from M/EEG data requires to have some neurophysiological background knowledge to assess the relevance of the selected features. This paragraph aims at providing some general elements regarding the origin of the signals and the recorded activity.

Origin of the signals

Neurons create electrical signals, transmitted to other cells via synapses. First, an action potential (AP) arrives at a synaptic cleft (step 1 in Figure 1) where it will transmit chemical information via neurotransmitters (step 2 in Figure 1) that generate post-synaptic potentials (PSPs) and local currents (step 3 in Figure 1). A PSP will create a current sink and will propagate until the cell body to generate a current source (step 4 in Figure 1). As a result, the PSP creates an electrical dipole consisting in a negative pole (i.e. the sink) and a positive pole (i.e. the source). This dipole will generate primary (intracellular) currents and secondary (extracellular) currents. M/EEG signals result from post-synaptic potentials. More specifically, M/EEG signals result from the spatial and temporal summation of the activity of a large population of synchronous neurons. But notable differences exist between MEG and EEG.

First, regarding the signals themselves, MEG signals are mainly caused by intracellular currents generated by the PSP at the dendrite level, and less by the extracellular currents; EEG signals correspond to a difference between electrical potentials, mainly due to extracellular currents. Secondly, regarding the sensitivity towards the dipole orientation, EEG is sensitive to both radial currents (activity located at the gyrus level) and to tangential currents (generated within sulci) even though it has Machine Learning for Brain Disorders, Chapter 9 Machine Learning for Brain Disorders, Chapter 9

Corsi stronger sensitivity to radial currents, whereas MEG is more sensitive to tangential currents. Finally, regarding the sensitivity towards the conductivity, EEG is strongly attenuated and deformed by crossing through the skull whereas MEG is less sensitive to the different layers crossed (i.e. skull, brain, etc...). Such differences between MEG and EEG have an impact on the way data are preprocessed, analyzed, and therefore, interpreted. The differences between MEG and EEG are summarized in Table 1.

Evoked and oscillatory activity

There are two main types of electrophysiological activity of interest that are exploited in the M/EEG domain: the evoked and the oscillatory activity. Evoked responses are weak variations of electromagnetic activity resulting from a stimulation (for instance, in response to a task performance by the participant). Given their amplitude, it is often necessary to average signals over chunks of signals, referred as epochs, to reduce noise.

To identify and describe these evoked responses, there is a specific way to name them according to their latency, their amplitude, their shape and the polarity. Let's take an example (see Figure 2), that represent evoked responses from a study where we simulated a visual stimulation. We first see a positive deflection occurring 300ms after the presentation of the stimulation, which is referred to as P300. These waves can reflect different mechanisms: the early components are mostly exogenous and are related to the stimulus characteristics; the late components are endogenous and are related to the performed task and to the subject's state.

The oscillatory activity, or induced activity, results from the summation of the activity in a given brain region. These rhythms are mainly defined by their frequency, their amplitude, their shape, their location, and their duration. In Figure 3), we provided examples of the main rhythms found in the literature. Each frequency band is referred to by a greek letter. Delta ([0.5-3Hz]) and Theta ([3-7Hz]) rhythms are respectively detected in the deep and slight sleeps. Alpha ( , in posterior areas) and Mu ( , in central areas) rhythms are both observed in quiet watch and resting state (with the eyes closed for Alpha). Beta ( ) rhythm is detected during the active watch and during cognitive tasks such as motor imagery for instance. Gamma rhythm (divided in two sub-rhythms: slow in , and fast beyond 70Hz) is observed during specific cognitive processing.

Machine Learning for Brain Disorders, Chapter 9

M/EEG experiments

This section provides an overview of the devices currently used and the main steps that constitute a M/EEG experiment. As a take-home message, in Table 1, we propose a comparison of the main features of MEG and EEG.

Instrumentation

EEG

EEG signals are recorded through the use of electrodes placed over the scalp. The EEG relies on the difference of potentials. The first EEG recordings have been performed by Hans Berger in 1924. He described the oscillatory activity at 8Hz occurring in the posterior area of the scalp when the subject is awake with his eyes closed. There are different types of electrodes: wet/dry electrodes, and active/passive electrodes. Wet electrodes are generally made of tin, silver, or silver chloride material (Ag/AgCl). They need an electrolytic gel to enable the conduction between the skin and the electrode. Dry electrodes are made of stainless steel that behaves as a conductor between the skin and the electrode. The active electrodes contain an electronic module that performs a preamplification of the signal to ensure the stability of the system towards changes in impedance and noise. The passive electrodes do not use a pre-amplification module.

Naming. Even though some differences may be found from one EEG device to another, there are some standardized ways to name and localize EEG sensors (also called channels). Each channel is often referred to by a letter and a number. Most of the time, odd channels are located on the left hemisphere and the even ones on the right hemisphere. The letters correspond to the area: frontal, temporal, parietal, central, and occipital. In addition to the sensors themselves, one can also find landmarks: nasion, inion, and pre-auricular points. An example of such naming is shown in Figure 4B.

List of montages. Depending on the scientific question to be addressed, and therefore, the brain areas of interest, different montages can be found. One can build an EEG montage from less than 5 electrodes to up to 256 channels. EEG measurements rely on a difference of electrical potentials. For this purpose, two montages can be considered: the referential montage and the bipolar montage. In the referential montage, each difference of electrical potentials considers an electrode placed over the scalp and a reference. As a result, each electrode placed over the scalp is compared to the reference electrode. The choice of the reference is cru-cial. The most commonly chosen locations for the reference electrodes are the mastoids (i.e. temporal bone behind the ears), even though several studies prefer placing the reference at the vertex (Cz, i.e. midline central of the scalp). Again, the location depends on the scientific question to be addressed. The bipolar montage consists of performing the difference between two electrodes placed over the scalp, after the experiment. Another electrode, referred as ground electrode, is used. Among the privileged locations is the scapula (i.e. shoulder blade). An example of an EEG setup and a standard montage are proposed in Figures 4A &B. For a complete description of the standardized EEG electrode arrays, the reader can refer to [START_REF] Seeck | The standardized EEG electrode array of the IFCN[END_REF].

Future of EEG hardware. In the past years, there has been an increased interest in developing wearable EEG, to remove wires and to reduce its dimension but also to enable long lasting recordings in a less constrained environment. Three bottlenecks need to be overcome: the EEG electrodes, hard to put on and to keep in place on the head; the EEG hardware to make it less power consuming and miniaturized; the EEG software, to propose the most intelligible and reliable information regarding the captured brain activity [START_REF] Casson | Wearable EEG and beyond[END_REF]. In particular, EEG systems that rely on dry EEG electrodes get more and more attention. By not requiring conductive gel, it reduces the preparation time. Recent studies relying on commercialized dry electrodes systems show performances close to those obtained with wet electrodes [START_REF] Casson | Wearable EEG and beyond[END_REF].

MEG

Sensors and main devices. The difficulty here is to detect signals that are 10 9 weaker than the Earth magnetic field. The current devices rely on Superconducting QUantum Interference Devices (SQUIDs) that can detect small MEG signals [START_REF] Hämäläinen | Magnetoencephalography-theory, instrumentation, and applications to noninvasive studies of the working human brain[END_REF]. One of the first proof-of-concept was made by D. Cohen in the 1970's [START_REF] Cohen | Magnetoencephalography: detection of the brain's electrical activity with a superconducting magnetometer[END_REF]. The SQUIDs present a sensitivity, defined here as the smallest variation of magnetic field that can be detected by the sensor, of 1 f T / √ Hz. To obtain such performance, a magnetic shielding room is required to remove the environmental noise and a part of the device needs to be cooled via a cryogenic system (see Figure 4C). Two types of sensors are used to record MEG signals: magnetometers and gradiometers. Magnetometers measure the magnetic field whereas the gradiometers measure the gradient of the magnetic field. They are used for noise elimination, and consist in a combination of magnetometers. The main difference from one manufacturer to another lies in the type of gradiometers used:

• CTF manufacturer: radial gradiometers consisting of two magne-Machine Learning for Brain Disorders, Chapter 9

Corsi tometers placed one above the other;

• MEGIN manufacturer: planar gradiometers consisting of two magnetometers placed side by side.

The type of gradiometer has an influence on the way brain activity is recorded, and therefore, on how to interpret the recorded signal [START_REF] Vrba | Signal Processing in Magnetoencephalography[END_REF]. Magnetometers and radial gradiometers are more sensitive to sources around the sensor whereas planar gradiometers are more sensitive to sources located right below the sensor.

New generation of sensors. The current devices rely on a cryogenic cooling system that engenders technical and financial constraints. New cryogenic-free sensors have recently emerged: the optically-pumped magnetometers (OPMs) [START_REF] Corsi | Magnétomètres à pompage optique à Hélium 4 : développement et preuve de concept en magnétocardiographie et en magnétoencéphalographie[END_REF][START_REF] Tierney | Optically pumped magnetometers: From quantum origins to multi-channel magnetoencephalography[END_REF]. Developing cryogenic-free sensors presents two main advantages: an increase in the amplitude of the signal recorded by the sensor and a reduction of the dimension of the magnetic shielding room. Recent studies, proved that OPMs present a better signal to noise ratio than EEG [START_REF] Boto | Wearable neuroimaging: Combining and contrasting magnetoencephalography and electroencephalography[END_REF], can detect deep sources [START_REF] Barry | Imaging the human hippocampus with opticallypumped magnetoencephalography[END_REF], and can be suited for pediatric or movement disorders studies [START_REF] Boto | Moving magnetoencephalography towards realworld applications with a wearable system[END_REF]. Promising results could be obtained with triaxial measurements obtained from OPMs [START_REF] Brookes | Theoretical advantages of a triaxial optically pumped magnetometer magnetoencephalography system[END_REF][START_REF] Labyt | Prado Machine Learning for Brain Disorders[END_REF].

Data acquisition

Depending on the tasks and on the hardware used, the duration of a M/EEG experiment may vary. This section aims presents the main steps that constitute the data acquisition.

The first step consists in preparing all the materials to perform the experiment. For EEG, it will consist in cleaning the locations where electrodes will be in contact with the skin (e.g. forehead and mastoids). The electrodes and the EEG cap are then placed. Several key distances can be measured to verify that the cap is well-placed or to record fiducial points to be matched to other modalities afterwards (e.g. MRI). Then, the experimenter needs to ensure that the communication between the electrodes and the scalp is established. For that purpose, an assessment of the impedance is made for each electrode. The lower it is, the better it is. In the case of wet electrodes, the experimenter has to inject gel at each sensor location. Once the impedances are lower than a certain threshold, typically a few kOhms, then the experiment can start. Regarding MEG, the experimenter places head tracking coils to measure the head position before each recording. It helps preventing from large head movements that could lead to motion artefacts and error in the localization of source activity. The locations of fiducial points (nasion, left and right preauricular points) are registered. The information is stored in each data file.

Corsi

The subject is then placed in the magnetic shielding room after taking off all the elements that could generate magnetic interference with the device (e.g. jewels, belt). The experimenter helps the subject to place his/her head in the MEG helmet. Once the subject is in a comfortable position, the experimenter will save the head position that will be used as reference during the whole session.

Once the subject is correctly installed, the experimenter can start some pre-recordings to check the quality of the signal and give specific instructions to the subjects accordingly (e.g. loosening the jaw to avoid muscular artifacts). Finally, the experimenter can give further instructions regarding the task to perform before starting the recordings. After the end of session, the data are stored in specific servers to be processed.

Items

Data analysis

This sections aims at providing recommendations for analysing M/EEG data. An overview of the main steps of the M/EEG data analysis is provided in Figure 6.

Types of artifacts/noise

The notion of artifacts depends strongly on the signal of interest. Here, we consider as artifacts the signals that make the recording more difficult and may hamper the analysis of the brain activity recorded with EEG and/or MEG. Such artifacts can be divided in two categories: the neu-rophysiological artifacts, and the environmental noise. This section aims at presenting their main features.

Neurophysiological artifacts

This category of artifacts corresponds to noise generated by the subjects themselves, whether it is voluntarily or not. In a nutshell, it is important to bear in mind that the brain is far from being the only organ that generates electromagnetic activity. In particular, the eyes and the heart produce electromagnetic activity, that shows an amplitude higher than that of the brain. As a result, the main neurophysiological artifacts are related to cardiac activity and ocular activity (via blinks and saccades) and can be visually spotted out during a M/EEG recording (see Figures 5A &B). A possible way to reduce the ocular artifacts is to instruct the subject to avoid moving their eyes and, for short recordings only, to avoid eyes blinking. Another neurophysiological artifacts may be induced by the subjects' voluntarily motion. Indeed, motion engenders muscular activity that can distort the recorded brain signals. Typical examples are jaw clenching and swallowing. They generate high frequency activity that propagates to temporal electrodes. In the specific case of MEG, the device consisting in a helmet, it is strongly sensitive to head motion. A possible way to reduce the muscular artifacts is to instruct the subjects to remain as quiet as possible and to avoid moving their jaws.

Environmental noise

This category refers to the artifacts generated by the environment that surrounds the experimental setup. They can be magnetic (e.g. magnetized devices that can interfere with the MEG sensors), linked with mechanical vibrations (e.g. presence of a tramway nearby), or simply associated with power line (occurring at 50Hz or 60Hz, see Figure 5C). We do not aim at being exhaustive. We simply want the reader to be aware of the possible sources of environmental noise when analyzing M/EEG signals even though the Faraday cage and the shielded room, used respectively in EEG and MEG, can partly prevent them.

System noise

This category refers to artifacts generated by the sensors themselves. For example, in MEG, one can observe SQUIDs jumps or saturation. In both MEG and EEG, one can have broken sensors.

Preprocessing

This sections aims at presenting the main steps that constitute the preprocessing pipeline, dedicated to artifacts removal. This is probably the most crucial part when analyzing M/EEG data. Indeed, the point here is to remove noise without eliminating information of interest or distorting the signal. Attention must be paid to build the pipeline the most suited to the dataset and to the scientific question to be addressed. As such, the first thing to do when working with a new dataset is to extensively study it. In particular, inspecting the M/EEG signals but also the associated broadband power spectra. This preliminary step enables to identify most of the artifacts, and more importantly, if they have a specific temporal and/or frequency signature (e.g. presence of periodic artifacts).

From this point, it is possible to choose a specific strategy to remove the observed noise. In the case of cardiac and ocular artifacts, given their clear pattern, an efficient way to isolate and reduce them consists in applying Independent Component Analysis (ICA) [START_REF] Bell | An information-maximization approach to blind separation and blind deconvolution[END_REF]. One can visually identify the components to be removed from both the temporal and the topographies (to avoid removing too many components) and manually select them. Another possibility, more reproducible, consists of using biosignals (e.g. electrocardiogram and electrooculogram) and to compute correlations between timeseries. This technique enables to ensure the robustness of the decision of removing a component.

In the case of artifacts at a specific frequency (e.g. power line noise at 50Hz or 60Hz), one can consider applying notch filters. With the same philosophy, in the case of muscular activity, applying a low-pass filter with a cut-off frequency at 40Hz can be of interest. Nevertheless, one objection can be raised: the signal distortion induced by the filtering. As previously explained, here, we aim at finding a trade-off between removing artifacts and preserving the information of interest. That is why the pipeline strongly depends on the scientific question to be addressed. In the case of muscular activity, if someone is interested in the activity in the gamma band (>30Hz), applying a low-pass filter will be a poor choice and as such, removing noisy trials can be an option. Regarding head motion, as explained in section 3.2, MEG systems enable to register the head position. Methods relying notably on Signal-Space Separation [START_REF] Taulu | Spatiotemporal signal space separation method for rejecting nearby interference in MEG measurements[END_REF] can correct small movements (i.e. less that several centimeters).

Another type of artifacts consists of a broken channel. To avoid having a different number of sensors from one subject to another, the proposed solution depends on the sensor location. If the sensor has four neighbors, strategies relying on the interpolation can be considered. It consists in creating a virtual sensor that is the linear combination of the signals recorded by the broken sensor's neighbors. If the sensor is located on the periphery, the interpolation is no longer reliable. The experimenter may consider removing the channel from the dataset. In the specific case of MEG, after an optional head movement correction step, if SQUID jump artifacts remains, one should consider re-applying the head movement correction on the raw data after having labeled as "bad" the sensors that show jumps. The bad MEG channels will be reconstructed.

Once the pipeline has been chosen and tested, it is important to check that the signals have been correctly preprocessed. This step corresponds to the quality check. There are different possibilities to perform it. The qualitative way would consist in superimposing pre-and post-processed signals (which can be displayed as time-series and/or power spectra) and to visualize potential differences. A more reliable way would consist in identifying a judgement criterion to assess to which extent the output signals are noisy. Possible metrics are the variance, the z-score or the kurtosis. Using one of these metrics on the output may lead to both noisy channels and trials to be discarded. As a rule of thumb, the trials elimination must not exceed 10% of the total number of trials to ensure to have enough data to perform a relevant analysis [START_REF] Gross | Good practice for conducting and reporting MEG research[END_REF].

Source reconstruction

It is possible to directly analyze the signals recorded by the sensors. In such a case, one will say that the analysis is performed in the space of the sensors. However, it is also possible to go one step further and estimate the activity within the brain. This processing step is called source reconstruction and consists in estimating the neural correlates M/EEG signals location. It can be performed when one wants to have access to a higher spatial resolution to provide a more accurate description, and interpretation, of the neurophysiological phenomena occurring. For that purpose, both the direct and the inverse problems need to be solved [START_REF] Baillet | Electromagnetic brain mapping[END_REF][START_REF] Gross | Good practice for conducting and reporting MEG research[END_REF].

Direct problem

Here, we aim at modelling the electromagnetic field produced by a cerebral source with known characteristics. For that purpose, it is necessary to consider both a physical model of the sources, and a model that predicts the way that these sources will generate electromagnetic fields at the scalp level. The simplest model is the spherical model, that considers the head as an ensemble of spheres. Each sphere corresponds to a given tissue (brain, cerebrospinal fluid, skull, or skin) characterized by a given conductivity. Even though it is possible to adjust the spheres to the geometry of the head or restrict them to a limited number of region of interest, this model is an oversimplification of the head geometry. More realistic models rely on geometrical reconstruction of the different layers that form the head tissues, directly extracted from the anatomical magnetic resonance imaging (MRI) data of, ideally, the participant (the MRI thus needs to be acquired separately) or a dedicated template (e.g. MNI Colin 27). They consist in building meshes of the interfaces between different tissues. We can cite three approaches: the Boundary Element Method (BEM) [START_REF] Fuchs | Boundary element method volume conductor models for EEG source reconstruction[END_REF] that is the most widely used, the Finite Difference Method (FDM), and the Finite Element Method (FEM). Another model, called Overlapping spheres [START_REF] Huang | A sensor-weighted overlapping-sphere head model and exhaustive head model comparison for MEG[END_REF], consists of fitting a given sphere under each sensor.

Even though there are no guidelines regarding the choice of the method, we could provide some elements of recommendations: given the high sensitivity of the EEG towards variations in terms of conductivity, the BEM model can be a tool of choice. As for the MEG, being less sensitive to changes in conductivity, the overlapping spheres can be considered.

Inverse problem

One of the main challenge of the inverse problem lies in the non-uniqueness of its solution. In other words, a large number of brain activity patterns could generate the same signature detected at the sensor level. Therefore, some constraints or assumptions are essential to lead to a unique solution that reflects the best the acquired data [START_REF] Gross | Good practice for conducting and reporting MEG research[END_REF][START_REF] Baillet | Electromagnetic brain mapping[END_REF]. In this section, we aim at providing a short overview of the methods that are the most used in routine.

The dipole modelling methods rely on a source modelling via a reduced number of equivalent dipoles where each of them represents a source activity. As a result, such methods are based on an a priori hypothesis on the required number of sources.

Scanning methods, such as the MUSIC approach [START_REF] Mosher | EEG source localization and imaging using multiple signal classification approaches[END_REF], consist in estimating the probability of presence of a current dipole inside each voxel. Among them are the beamformer methods [START_REF] Hillebrand | Beamformer Analysis of MEG Data[END_REF], that consist in applying a spatial filtering to estimate the source activity at each location. We can cite the linearly constrained minimum variance (LCMV) and the synthetic aperture magnetometry (SAM) [START_REF] Robinson | Functional neuroimaging by synthetic aperture magnetometry (SAM) -ScienceOpen. Recent advances in Biomagnetism[END_REF] as examples of beamformer methods [START_REF] Van Veen | Localization of brain electrical activity via linearly constrained minimum variance spatial filtering[END_REF].

The approaches relying on distributed source models consist in estimating the amplitudes of dipoles located on the cortical surface. The characteristics of the groups of dipoles are fixed or are estimated via the individual MRI of the participant. The most famous methods relying on distributed sources models are the weighted minimum norm (wMNE) Corsi [START_REF] Fuchs | Linear and nonlinear current density reconstructions[END_REF][START_REF] Lin | Assessing and improving the spatial accuracy in MEG source localization by depth-weighted minimum-norm estimates[END_REF] and LORETA [START_REF] Rd | Standardized low-resolution brain electromagnetic tomography (sLORETA): technical details[END_REF].

Similarly to the preprocessing step, there is no ideal choice of method for the inverse problem, as it depends on the question to be addressed. A general recommendation would be to consider the minimum norm method when expecting distributed sources, and the dipole modelling for focal sources.

Features extraction and selection

When considering M/EEG from the Machine Learning perspective, an important aspect is the extraction, and the selection of the features. This section aims at presenting the main features that can be extracted from M/EEG. As previously mentioned, the selection of the features depends on the scientific question to be addressed but also on the neurophysiological phenomenon underlying the M/EEG experiment. In M/EEG, filtering both in the time domain and in the spatial domain to select the most relevant features is common.

The two main types of features used in the literature rely on the information in the frequency domain and in the time domain. In an effort of completeness, we will see alternatives features that reflect the interconnected nature of brain.

The event-related features consist of chunks of time-series concatenated from all the channels, resulting from a low-pass or band-pass filtering and/or from a down-sampling step. This category of features is relevant when considering evoked activity after the presentation of a given stimulus (e.g. visual, auditory or sensory). They are therefore of interest when one is expecting significant changes in signal amplitudes occurring at a given moment. In the example presented in section 2.2, a positive wave occurred 300 ms after the visual stimulation. One could consider using chunks of timeseries centered at t=300ms to detect automatically the P300 wave.

The spectral features are used in the case of the detection of an oscillatory activity (see section 2.2), when changes in M/EEG rhythms amplitudes are expected. The features are associated with the power spectra estimated in a given channel and in a given frequency band for a specific time window. Power spectra can be computed via a plethora of methods, we can notably cite the spectrogram, the Morlet wavelet scalogram, and the auto-regressive models. For a thorough comparison of spectral features extraction techniques on EEG signals, please refer to [START_REF] Brodu | Comparative study of band-power extraction techniques for Motor Imagery classification[END_REF].

Spatial filtering can be a valuable tool both for the event-related and the spectral features [START_REF] Lotte | A Review of Classification Algorithms for EEG-based Brain-Computer Interfaces: A 10-year Update[END_REF].

It relies on the combination of signals, recorded

Machine Learning for Brain Disorders, Chapter 9 Corsi from different sensors, to obtain a new one, associated with an improved signal-to-noise ratio. We can divide the spatial filtering methods into three categories. The first one, not data driven, relies on physical considerations regarding the way the signals propagate through the different brain tissues. The most famous illustration of this category is the Laplacian filter. In its simplest version, the small Laplacian consists, for each electrode location, of a derivation of the EEG waveform via the average signal computed from the four nearest-neighbors [START_REF] Mcfarland | Spatial filter selection for EEG-based communication[END_REF]. The second category of spatial filtering is data-driven and unsupervised. It can rely, for example, on a Principal Component Analysis (PCA) approach (see Chapter 2, section 13.1). The third category is data-driven and supervised. The most famous examples in M/EEG are the Common Spatial Patterns (CSP) for spectral features [START_REF] Ramoser | Optimal spatial filtering of single trial EEG during imagined hand movement[END_REF], and xDAWN for event-related features [START_REF] Rivet | xDAWN Algorithm to Enhance Evoked Potentials: Application to Brain-Computer Interface[END_REF]. The CSP consists of a linear combination of EEG signals to maximize the difference between two classes in terms of variance. The xDAWN approach aims at improving the signal-to-noise ratio obtained with evoked potentials via a projection of the raw EEG signals onto an estimated evoked subspace. Recent efforts have been put together to combine approaches to provide ways to optimize simultaneously spectral and spatial filters, with for example the Filter Bank CSP (FBCSP) [START_REF] Ang | Filter Bank Common Spatial Pattern (FBCSP) in Brain-Computer Interface[END_REF].

Even though spectral and event-related features are the most used in the M/EEG literature, alternative features have been considered in the past years. First, features relying on covariance matrices have recently been extensively used, in particular for Riemannian geometry-based classification [START_REF] Yger | Riemannian Approaches in Brain-Computer Interfaces: A Review[END_REF]. Despite an unclear neurophysiological interpretation, they enabled to reach state-of-the art performance and to win a large number of competitions. Secondly, new features, that take into account the interconnected nature of brain functioning have recently emerged [START_REF] Gonzalez-Astudillo | Network-based brain computer interfaces: principles and applications[END_REF]. There is a plethora of estimators to assess the intensity of the interactions between brain areas [START_REF] Bastos | A Tutorial Review of Functional Connectivity Analysis Methods and Their Interpretational Pitfalls[END_REF]. The most frequent estimators used as features in M/EEG are derived from the coherency i.e. the normalized cross-spectral density obtained from two signals (e.g. imaginary part of coherence), or rely on the assessment of the phase synchrony between two signals (e.g. Phase-Locking Value (PLV), Phase-Lag Index (PLI)).

Here, two challenges need to be dealt with: the volume conduction that can lead to spurious connectivity 1 and the online implementation. In the first case, even though some estimators, such as the imaginary coherence, are less sensitive to the volume conduction, working in the source space is recommended. In the second case, a large majority of studies that consider estimators of functional interactions between two brain areas (i.e. functional connectivity estimators) as features are performed offline. Estimating brain interactions in real-time is not trivial: it consists in finding the compromise between ensuring the quasi-stationarity of the signals and the statistical reliability of the functional connectivity estimation [START_REF] Gonzalez-Astudillo | Network-based brain computer interfaces: principles and applications[END_REF]. Recent studies considered the use of brain network metrics as potential features. Again, there is a plethora of metrics that characterize brain networks [START_REF] Gonzalez-Astudillo | Network-based brain computer interfaces: principles and applications[END_REF]. Here, we will cite the most used metrics. At the local scale, the node degree counts the number of connections linking one node to the others. In weighted networks (i.e. without having filtered the connectivity/adjacency matrix) it is referred to as node strength and consists in summing the weights of the connections of the considered node [START_REF] Fornito | Fundamentals of Brain Network Analysis[END_REF]. Another local-scale property of interest is the betweenness centrality defined as the extent to which a node lies "between" other pairs of nodes via the proportion of shortest paths in the network passing through it. This metric enables the identification of the nodes that are crucial for the information transfer between distant regions. At the global scale, we can cite two metrics: the characteristic path length and the clustering coefficient. The characteristic path length indicates the global tendency of the nodes in the network to integrate and exchange information. The clustering coefficient measures the tendency of having nodes' neighbors mutually interconnected. Lastly, it is worthwhile noting the use of heterogeneous features (e.g. relying on both functional estimators and power spectra) that improves the classification accuracy [START_REF] Lotte | A Review of Classification Algorithms for EEG-based Brain-Computer Interfaces: A 10-year Update[END_REF]. Such an approach leads to an increase of the dimension, requiring cautious to select the most relevant features, via dimensional reduction methods.

The feature selection is a crucial step as it prevents redundancy, ensures the reliability of the features, reduces the dimensionality tuned, and helps in providing interpretable results. In this section, we aim at presenting the most popular features selection methods in the M/EEG domain. For a complete description of the features selection methods, the reader can refer to [START_REF] Lotte | A Review of Classification Algorithms for EEG-based Brain-Computer Interfaces: A 10-year Update[END_REF]. They can be divided into three categories: embedded, filter, and wrapper methods. In filter methods, the feature selection is performed independently, and before, the evaluation. Different criteria can be chosen to select features. The most popular criterion is the R 2 score, that assesses to which extent a given feature is influenced by a task performed by the subject. In wrapper methods, the feature selection utilizes the classification. In other words, in an iterative process, the relevance of each subset of features is assessed via the classification performance until a given criterion is met. The embedded method consists in integrating both the features selection and the classification in the same process, via a decision tree for example or an ℓ 1 penalty term.

Corsi

Box 1: Tools for M/EEG analysis All these tools provide a wide range of tutorials, publicly available datasets, and codes. Python-based:

• MNE-Python [START_REF] Gramfort | MNE software for processing MEG and EEG data[END_REF] • MOABB [START_REF] Jayaram | MOABB: trustworthy algorithm benchmarking for BCIs[END_REF] Matlab-based:

• EEGLAB [START_REF] Delorme | EEGLAB: an open source toolbox for analysis of singletrial EEG dynamics including independent component analysis[END_REF] • Fieldtrip [START_REF] Oostenveld | FieldTrip: Open Source Software for Advanced Analysis of MEG, EEG, and Invasive Electrophysiological Data[END_REF] • Brainstorm [START_REF] Tadel | Brainstorm: A User-Firendly Application for MEG/EEG Analysis[END_REF] • SPM [START_REF]Statistical Parametric Mapping: The Analysis of Functional Brain Images[END_REF] 6. M/EEG and brain disorders

Clinical applications of M/EEG

The spatial and temporal resolutions of M/EEG enables the observation of a large number of processes. Notably, they can detect both evoked responses and oscillatory activity. As such, using these information could pave the way to biomarkers of brain disorders. To illustrate this point, we will focus our presentation on two specific clinical applications: epilepsy and Alzheimer disease. Nevertheless, M/EEG can be useful for a wider range of applications both in neurological and psychiatric disorders [START_REF] Hari | IFCN-endorsed practical guidelines for clinical magnetoencephalography (MEG)[END_REF][START_REF] Boutros | Standard Electroencephalography in Clinical Psychiatry: A Practical Handbook[END_REF].

Epilepsy

Epilepsy is a neurological disorder that presents a high prevalence of 1% [START_REF]Épilepsies de l'enfant et de l'adulte[END_REF]. It is established that between 20 and 30% of the patients present a pharmacoresistant form of epilepsy [START_REF] Kwan | Early Identification of Refractory Epilepsy[END_REF]. Among this proportion of patients, only 30% can undergo a surgery [START_REF] Micoulaud-Franchi | Biofeedback et épilepsie pharmacorésistante : le retour d'une thérapeutique ancienne ?[END_REF]. Epilepsy is a distributed disease that induces brain network reorganization and brain rhythms alterations both during ictal and interictal periods [START_REF] Ev | Functional and structural brain networks in epilepsy: What have we learned?[END_REF][START_REF] Bartolomei | Defining epileptogenic networks: Contribution of SEEG and signal analysis[END_REF]. Due to its time resolution compatible with the capture of dynamical changes as Machine Learning for Brain Disorders, Chapter 9 well as its wide availability, EEG is a key modality for the evaluation of epilepsy [START_REF]Épilepsies de l'enfant et de l'adulte[END_REF]. In addition to scalp EEG, stereotactic-EEG (SEEG) can be used to further localize epileptogenic foci and proved to provide valuable information on epileptogenic networks [START_REF] Bartolomei | Defining epileptogenic networks: Contribution of SEEG and signal analysis[END_REF]. MEG can also be used for pre-surgical evaluation and for functional mapping [START_REF] Stefan | Magnetoencephalography (MEG): Past, current and future perspectives for improved differentiation and treatment of epilepsies[END_REF], but it is much more costly and less widely available.

The use of network theory in epilepsy provides a useful framework to characterize the seizure (onset and propagation), and its clinical expression (e.g. comorbidities) [START_REF] Ev | Functional and structural brain networks in epilepsy: What have we learned?[END_REF][START_REF] Bartolomei | Defining epileptogenic networks: Contribution of SEEG and signal analysis[END_REF]. At the local scale, the node strength or degrees, and the betweeness centrality have been used to characterize the epileptic network [START_REF] Wilke | Graph analysis of epileptogenic networks in human partial epilepsy[END_REF][START_REF] Bartolomei | Defining epileptogenic networks: Contribution of SEEG and signal analysis[END_REF]. At the global scale, two metrics have proved to be of interest in epilepsy [START_REF] Bartolomei | Interictal network properties in mesial temporal lobe epilepsy: a graph theoretical study from intracerebral recordings[END_REF]: the characteristic path length and the clustering coefficient.

Alzheimer disease

Alzheimer disease is the most common dementia with 60 to 80% of the cases. The first symptoms are a deficit in short-term memory and concentration, followed later by a decline of linguistic skills, visuo-spatial orientation, abstract reasoning judgement. As the pathophysiological process of the disease starts many years before the occurrence of symptoms [START_REF] Bateman | Dominantly Inherited Alzheimer Network (2012) Clinical and biomarker changes in dominantly inherited Alzheimer's disease[END_REF], it is crucial to elicit biomarkers to provide a diagnosis as soon as possible. Efforts have been put together to describe mild cognitive impairment (MCI) and Alzheimer's disease (AD) with M/EEG. These studies are essentially focused on oscillatory activity and on interactions between brain areas [START_REF] Babiloni | Brain neural synchronization and functional coupling in Alzheimer's disease as revealed by resting state EEG rhythms[END_REF][START_REF] Engels | Alzheimer's disease: The state of the art in resting-state magnetoencephalography[END_REF]. In particular, patients present a reduced synchrony [START_REF] Stam | Use of magnetoencephalography (MEG) to study functional brain networks in neurodegenerative disorders[END_REF] and a decrease of the alpha power (i.e. between 8 and 12Hz) correlates with lower cognitive status and hippocampal atrophy. Studies performed with MEG in preclinical and prodomal stages of AD showed that the effects of amyloid-beta deposition were associated with an increment of the prefrontal alpha power and that altered connectivity in the default mode network was present in normal individuals at risk for AD [START_REF] Nakamura | Early functional network alterations in asymptomatic elders at risk for Alzheimer's disease[END_REF][START_REF] Nakamura | Electromagnetic signatures of the preclinical and prodromal stages of Alzheimer's disease[END_REF].

A recent EEG work showed that effects of neurodegeneration were focused in frontocentral regions with an increase in high frequency bands (beta and gamma) and a decrease in lower frequency bands (delta) [START_REF] Gaubert | EEG evidence of compensatory mechanisms in preclinical Alzheimer's disease[END_REF]. In particular, EEG patterns differ depending on the degree of amyloid burden, suggesting a compensatory mechanism: following a U-shape curve in delta power and an inverted U-shape curve for the other tested metrics.

6.2 Advanced uses: the example of BCI as a rehabilitation tool BCI devices can be a valuable tool in the treatment of neurological disorders such asstroke [START_REF] Kashihara | A brain-computer interface for potential non-verbal facial communication based on EEG signals related to specific emotions[END_REF], and to provide assistive solutions for patients with spinal cord injury [START_REF] King | Operation of a braincomputer interface walking simulator for individuals with spinal cord injury[END_REF] or the amyotrophic lateral sclerosis [START_REF] Kashihara | A brain-computer interface for potential non-verbal facial communication based on EEG signals related to specific emotions[END_REF]. With regard to the communication, devices such as the P300 Speller, that rely on the evoked response occurring 300ms after the visual stimulation, allow the users to communicate by selecting letters to form words and even sentences. For an overview of the main steps to be considered when performing a BCI experiment, please refer to Figure 7.

Brain activity recording

Features extraction Classification

BCI as a rehabilitation tool

Stroke is one of the most common neurological conditions. In 2010, stroke was the second leading cause of death worldwide [START_REF] Feigin | Global and regional burden of stroke during 1990-2010: Machine Learning for Brain Disorders, Chapter 9 Corsi findings from the Global Burden of Disease Study 2010[END_REF]. After a stroke, most patients require rehabilitation and assistance for daily tasks. Motor deficit of the upper limbs affects 70% of the survivors [START_REF] Houwink | Measuring Upper Limb Capacity in Patients After Stroke: Reliability and Validity of the Stroke Upper Limb Capacity Scale[END_REF] and 85% of those presenting paralysis will have persistent damage [START_REF] Kavanagh | Costs and disability among stroke patients[END_REF]. Rapid recovery is observed during the first three months (acute phase) but can continue for several months after the accident (chronic phase) [START_REF] De Santé | Accident vasculaire cérébral : méthodes de rééducation de la fonction motrice chez l'adulte[END_REF]. Motor-imagery (MI) based BCI can constitute a motor substitution in the case of stroke by building alternative pathways from the stimulation to the brain [START_REF] Prasad | Applying a braincomputer interface to support motor imagery practice in people with stroke for upper limb recovery: a feasibility study[END_REF]. In this particular case, the system relies on the desynchronization effect associated with a decrease of the power spectra computed within the contralateral sensorimotor area [START_REF] Pfurtscheller | Event-related EEG/MEG synchronization and desynchronization: basic principles[END_REF]. In a recent meta-analysis [START_REF] Cervera | Brain-computer interfaces for post-stroke motor rehabilitation: a metaanalysis[END_REF], the authors observed that rehabilitation to restore upper-limb motor function based on BCIs could improve the motricity, assessed via the Fugl-Meyer scale, more than other therapies. A part of the screened studies showed that BCI could induce neuroplasticity.

Brain network changes in stroke patients represent a very promising clinical application of closed-loop systems in rehabilitation strategies. Motor imagery has been proved to be a valuable tool in the study of upper-limb recovery after stroke [START_REF] Sharma | Motor imagery: a backdoor to the motor system after stroke?[END_REF]. It enabled observations of changes in ipsilesional intrahemispheric connectivity [START_REF] Pichiorri | Brain-computer interface boosts motor imagery practice during stroke recovery[END_REF] but also modifications in connectivity in prefrontal areas, and correlations between node strengths and motor outcome [START_REF] Sharma | Motor imagery after stroke: Relating outcome to motor network connectivity[END_REF]. Based on previous observations in restingstate [START_REF] Dubovik | The behavioral significance of coherent resting-state oscillations after stroke[END_REF], a recent double-blind study involving ten stroke patients at the chronic stage revealed that node strength, computed from the ipsilesional primary motor cortex in the alpha band, could be a target for a motor-imagery-based neurofeedback and lead to significant improvement on motor performance [START_REF] Mottaz | Modulating functional connectivity after stroke with neurofeedback: Effect on motor deficits in a controlled cross-over study[END_REF].

Current challenges and perspectives

Despite being beneficial for patients, controlling a BCI system is a learned skill that 15 to 30% of the users cannot develop even after several training sessions. This phenomenon, called "BCI inefficiency" [START_REF] Allison | Could Anyone Use a BCI?[END_REF], has been presented as one of the main limitations to a wider use of BCI. From the machine learning perspective, the main challenges to overcome in current BCI paradigms relying on EEG recordings are: the low signal-to-noise ratio of signals; the non-stationarity over time mainly resulting from the difference between calibration and feedback sessions; the reduced amount of available data to train the classifier explained by the number of classes to be discriminated and/or the need to avoid the subject's tiredness; the lack of robustness and reliability of the BCI systems, in particular when decoding the users' mental command.

To tackle these challenges, efforts have been put to improve the classification algorithms. They can be divided in three main groups: the adaptive classifiers, the transfer learning techniques and the matrix or tensor based algorithms. The adaptive classifiers aim at dealing with EEG non-stationarity by taking into account changes in signal properties, and feature distribution, over time. Their parameters are updated when new EEG signals are available [START_REF] Schlögl | Adaptive Methods in BCI Research -An Introductory Tutorial[END_REF]. Even though most of the adaptive classifiers can rely on a supervised approach, the unsupervised one has proven to outperform the classifiers that cannot catch temporal dynamics [START_REF] Vidaurre | Toward unsupervised adaptation of LDA for brain-computer interfaces[END_REF]. Besides, it can be a valuable tool to reduce the training duration and potentially to remove the calibration part. Nevertheless, the adaptive classifiers present one main pitfall: their lack of online validation with a user in most of the current literature. This leads to two potential issues: the difficulty to find a trade-off between fully retraining the classifier and updating some key-parameters, and the adaptation that may not follow the actual user's intent by being too fast or too slow [START_REF] Müller | A mathematical model for the two-learners problem[END_REF].

Transfer learning consists here in exploiting changes in EEG signals properties over time and subjects to extract knowledge. More specifically, it relies on learned classifiers that are trained on one task (called domain here) and are adapted to another task with little or no new training data [START_REF] Waytowich | Spectral Transfer Learning Using Information Geometry for a User-Independent Brain-Computer Interface[END_REF]. For example, it can be applied to a dataset formed by two motor imagery tasks performed by two different subjects. There is plethora of methods to solve the transfer learning problem [START_REF] Pan | A Survey on Transfer Learning[END_REF]. The most common in the EEG-based BCI domain consists in learning the transformation to correct the mismatch between the domains, occurring when one domain corresponds to a hand motor imagery and the other to a foot motor imagery for instance, finding a common feature representation for the domains, or learning a transformation of the data to make their distributions match [START_REF] Lotte | A Review of Classification Algorithms for EEG-based Brain-Computer Interfaces: A 10-year Update[END_REF]. Despite its robustness and recent advances in proposing guidelines [START_REF] Bougrain | Guidelines to use Transfer Learning for Motor Imagery Detection: an experimental study[END_REF], there is a lack of online experiments relying on transfer learning to fully validate this approach and assess to which extent it can be beneficial to patients.

Among the classification methods relying on matrices and tensors the most well-known is the Riemannian geometry-based one. One of the main original characteristics of this approach is that it is able to manipulate and classify the data by representing them as symmetric positive definite matrices, such as covariance matrices, and by mapping them onto a dedicated geometrical space, involving less steps than the classic approaches. This approach relies on the assumption that the sources are specific of a given task encoded via the covariance matrix computed from EEG signals. Here, trials are classified via nearest neighbour methods relying on the Riemannian distance, and the geometric mean. With the method relying on the minimum distance to mean (MDM), each class is associated with a geometric mean computed from the training data. Then, the MDM will attribute an unlabelled trial to the class showing the closest mean [START_REF] Yger | Riemannian approaches in brain-computer inter-faces: a review[END_REF]. The Riemannian approaches present many advantages: they Machine Learning for Brain Disorders, Chapter 9 can be applied to all BCI paradigms, no parameter tuning is required, they are robust to noise and, combined to transfer learning methods, they can lead to calibration-free BCI sessions [START_REF] Andreev | Recreational Applications of OpenViBE: Brain Invaders and Use-the-Force[END_REF]. In particular, Riemannian geometry-based methods [START_REF] Yger | Riemannian approaches in brain-computer inter-faces: a review[END_REF][START_REF] Congedo | Riemannian geometry for eeg-based braincomputer interfaces; a primer and a review[END_REF] are now the state-of-the-art is terms of performance [START_REF] Lotte | A Review of Classification Algorithms for EEG-based Brain-Computer Interfaces: A 10-year Update[END_REF] and have won several data competitions2 [START_REF] Corsi | Riemannian Geometry on Connectivity for Clinical BCI[END_REF].

Conclusion

EEG and MEG are key modalities for the study of brain disorders. In particular, EEG is relatively cheap and widely available and is thus a widely used tool in neurology. When dealing with EEG and MEG data, it is important to understand the origin of the signals as well as the different steps in their preprocessing and feature extraction. Machine learning is increasingly used on EEG and MEG data, in particular for BCI but also for computer-aided diagnosis and prognosis of brain disorders.

Figure 1 :

 1 Figure 1: Origin of M/EEG signals.

Figure 2 :

 2 Figure 2: Evoked activity. Results from a simulation where two sources, located in the visual area, generated an activity after a stimulus. On the right, we plotted the associated time course over the scalp (synthetic signals), resulting from the averaging of 1000 repetitions. One can observe notably a positive wave around t=300ms. The code to generate this figure is accessible via the dedicated Github repository.

Figure 3 :

 3 Figure 3: We plotted the time course associated to the main rhythms that one can observe from M/EEG recordings. These plots were obtained from synthetic signals. The code to generate this figure is accessible via the dedicated Github repository.

Figure 4 :

 4 Figure 4: M/EEG instrumentation. (A) EEG experimental setup (B) Example of EEG montage. For an illustrative purpose, each color corresponds to a brain area. Each circle represents either a sensor or a landmark. Sensors appear in color while landmarks appear in gray. Sensors are designated with a letter and a number. The letter is indicative of the brain region. Odd numbers correspond to the left hemisphere and even ones to the right hemisphere. (C) MEG experimental setup

Figure 6 :

 6 Figure 6: Data analysis in M/EEG: general workflow. QC stands for quality check. Source reconstruction is not compulsory but advisable in specific cases. The code to generate this figure is accessible via the dedicated Github repository.

6. 2 . 1 .

 21 Presentation of the BCI Brain-Computer Interfaces (BCIs) consist of acquiring, analyzing and translating brain signals into commands in real time for control or communication. These systems present a large number of clinical applications and assistive technologies including control of wheelchairs and brainbased communication.

Figure 7 :

 7 Figure 7: BCI experiment workflow.

Box 2 :

 2 To go furtherGuidelines and books of reference • Hari, M., and Puce, A. (2017). MEG-EEG Primer. In MEG-EEG Primer. Oxford University Press. • M. Clerc, L. Bougrain, and F. Lotte. (2016) Brain-Computer Interfaces 1: Methods and Perspectives, Wiley. • M. Clerc, L. Bougrain, and F. Lotte. (2016) Brain-Computer Interfaces 2: Technology and Applications, Wiley. • Gross, J., Baillet, S., Barnes, G. R., Henson, R. N., Hillebrand, A., Jensen, O., Jerbi, K., Litvak, V., Maess, B., Oostenveld, R., Parkkonen, L., Taylor, J. R., van Wassenhove, V., Wibral, M., and Schoffelen, J.-M. (2013). Good practice for conducting and reporting MEG research. Neuroimage, 65, 349-363. • Puce, A. and Hämäläinen, M. S. (2017). A Review of Issues Related to Data Acquisition and Analysis in EEG/MEG Studies. Brain Sci, 7(6).

Table 1 :

 1 Main features to compare MEG and EEG.

		MEG		EEG
	Measurement	Magnetic field, + intracellular currents	Difference of potentials, + extracellular currents
	Spatial resolution	1 cm		2-3 cm
	Temporal resolution	1 ms or less
	Amplitudes	≈ 100 fT		≈ 100 µVolts
	Advantages	-Absolute values -Less affected by bone-Focal		-Portable -Cost
	Drawbacks	-Financial constraints -Mechanical constraints	-Need of a reference -Affected by bone -Diffuse

Machine Learning for Brain Disorders, Chapter 9

originating from the mixture of signals engendered by different sources recorded at a given sensor. Machine Learning for Brain Disorders, Chapter 9

See for example the 6 competitions won by A. Barachant: http://alexandre. barachant.org/challenges/

Acknowledgments

The author acknowledges support from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation program (grant agreement No. 864729) and from the program "Investissements d'avenir" ANR-10-IAIHU-06. The author thanks D. Schwartz for his suggestions and insightful comments.