Documentation#
Interictal epileptiform discharges (IEDs), also referred to as ”spikes”, are a characteristic of the epileptic brain that are recognizable as large transient events in the electroencephalogram of patients living with epilepsy [1]. Whereas, for clinicians, IEDs can provide valuable information about the epileptogenic zone, for researchers, they can also be a source of noise and need to be excluded, such as in [2] where Cusinato and Alnes et al. studied how the human brain processes sounds. Regardless of the context, the localization of IEDs in EEG recordings is a very time-consuming task.
This package aims to contribute to this issue by building on an algorithm previously developed by Baud et al. [3] that employs nonnegative matrix factorization (NMF) to automatically detect IEDs, an unsupervised machine-learning algorithm that produces a lower-dimensional approximation of the input.
It is important to note, that the algorithm used by this package is optimized for and was solely tested on intracranial EEG (iEEG) recordings. Intracranial EEG is an invasive technique with implanted electrodes that is used for clinical monitoring, e.g. to identify the epileptogenic zone and prepare for epilepsy surgery. The primary characteristic of iEEG is that it provides high spatial and temporal resolution of the electrical activity in the brain, which makes it a valuable resource for neuroscientific research as well [4].
Nonnegative Matrix Factorization#
Nonnegative Matrix Factorization (NMF) is a machine-learning algorithm used to decompose an original data matrix into two lower-rank matrices. As such it resembles other matrix decomposition algorithms, such as Principal Component Analysis (PCA), Linear Discriminant Analysis (LDA), and Independent Component Analysis (ICA), whose purpose is to reduce the dimensionality of the original data and to identify the underlying patterns, principal components or latent variables that make up the observed data. The unique characteristic of NMF is that it imposes nonnegativity constraints on the values of the factorized matrices, which only allow for additive combinations and thus result in a parts-based representation of the original data. This characteristic improves the interpretability of the results [5, 6]. In many real-world applications, such as image processing, text analysis or gene data analysis, the presence of negative values in both the original data and the latent variables is physically meaningless. This limits the application scenarios for methods like PCA and ICA [5, 7]. In [6], Lee and Seung, using image data, showed that the decomposition of human faces performed by NMF results in a range of facial parts, such as noses, mouths, and eyes, corresponding to the different parts making up the whole. By contrast, when applied to the same data set, PCA yields a set of prototypical eigenfaces that by linear combination approximates the original data.
The basic mechanism of NMF, illustrated in Fig. 1, is that it approximates an original data matrix by the linear combination of two nonnegative lower-rank matrices
Here, \(V\) is a \(M × N\) matrix incorporating the original data in terms of features (rows) and samples (columns). \(W\) is a \(M × K\) matrix, whose K columns are called basis vectors and represent the latent variables, expressed by the same features as the observed data. \(H\) is a \(K × N\) matrix whose columns are the encodings of the samples [6, 8].
Fig. 1 Conceptual diagram of Nonnegative Matrix Factorization (NMF)#
A further result reported by Lee and Seugn is that both the basis vectors and the encodings contain numerous vanishing coefficients, meaning that both the basis images and encodings are sparse [6]. The basis images contain several versions of different facial parts that are in different locations and have different forms, accounting for their sparsity. The sparsity in the image encodings is explained by the fact that all parts are used by at least one image, but no image uses all parts. In [8], Brunet et al. introduced NMF as a means of reducing the dimension of expression data from thousands of genes to a small number of metagenes. By combining NMF with consensus clustering, a model-selection algorithm developed in [9] and adding a quantitative evaluation to assess the robustness of a given decomposition, they were able to identify distinct molecular patterns and cluster samples into the different metagenes. In their model, the data matrix consists of the gene expression levels of–expressed in terms of the variables introduced above–\(M\) genes in \(N\) samples. The decomposition results in a matrix \(W\) , consisting of \(K\) metagenes, each expressed in terms of the \(M\) genes, and an \(H\) matrix whose \(N\) columns represent the metagene expression pattern of each individual sample. Translating NMF into the context of EEG data while using the analogous terminology, NMF decomposes a set of EEG signals into a small number of EEG metapatterns that make up these signals. The original data matrix \(V\) contains the measurements of the electrical activity in the brain from \(M\) different electrodes along \(N\) different time points. The \(K\) columns of W then represent the EEG metapatterns contained in the original signals, expressed in terms of the different brain activity patterns captured by the \(M\) electrodes, while the \(N\) columns of \(H\) represent the activation level of each metapattern at each point in time.
Extensions#
The methodology used in this package employs consensus clustering [9] to automatically determine the optimal rank of the decomposition, following the example of Brunet et al. [8] described in the previous section.
Additionally, the package offers a modified version of the NMF algorithm, which attempts to further exploit the spatiotemporal features of the EEG signals by integrating sparseness constraints. The method uses a model of sparseness introduced by Hoyer [10] who defined sparseness based on a relation between the \(L_1\) norm and the \(L_2\) norm
where \(x\) is a vector and \(n\) is the dimensionality of \(x\). This function has the advantage of interpolating smoothly in the interval [0, 1] and evaluating to 0 if and only if all elements of \(x\) are equal and to 1 if and only if \(x\) contains a single non-zero element. In our model, we impose sparseness constraints on individual basis vectors, i.e. the columns of \(W\). We can then define the sparseness of a single basis vector \(w_i\) as
where \(w_{ij}\) is the \(j^{th}\) element of the \(i^{th}\) basis vector \(w_i\).
Glossary#
Here, we quickly present the most important terminologies used in the library.
- Basis Function#
A basis function refers to a column of the \(W\) matrix and represents an EEG metapattern, expressed in terms of the different brain activity patterns captured by the employed electrodes. They are represented in the library by the
BasisFunctionobject.- Activation Function#
An activation function refers to a single row of the \(H\) matrix and contains the activation levels of a given metapattern at each point in time. They are represented by the
ActivationFunctionobject.
Limitations#
The default algorithm ran by means of the SpikeDetectionPipeline
employs a simple K-Means clustering to split the returned activation functions into those coding
for a certain EEG pattern and those coding for noise and sorts them starting with the noisy functions. However,
there is no functionality that is guaranteed to find which of the activation functions exactly codes for
spikes. Therefore, it is recommended to use additional tools that allow the visualization of the
activation functions and their respective event periods.