30
Bachelor Thesis at the MOSAIC group Institute for Theoretical Computer Science Department of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization Using SVM Matthias Bircher Advisors: ¨ Omer Demirel, Prof. Dr. Ivo Sbalzarini, Prof. Dr. Thomas R¨ osgen

Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Bachelor Thesis at theMOSAIC groupInstitute for Theoretical Computer ScienceDepartment of Computer Science

Bachelor Thesis

Solving the Inverse Problem in EEG SourceLocalization Using SVM

Matthias Bircher

Advisors: Omer Demirel, Prof. Dr. Ivo Sbalzarini, Prof. Dr. Thomas Rosgen

Page 2: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Contents

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Problem Description 2

3 Introducing the SVR 4

4 Implementation 4

5 SVR Tests 55.1 Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55.2 Non-linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

5.2.1 Multidimensional Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

6 EEG Forward Problem 76.1 One Regressor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

6.1.1 Parameter Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86.2 Multiple Regressors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116.3 Computational Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

7 EEG Inverse Problem 137.1 Treating Each Dimension Separately . . . . . . . . . . . . . . . . . . . . . . . . . . 13

7.1.1 Training Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137.2 Finding the Location for a Constant Orientation . . . . . . . . . . . . . . . . . . . 147.3 First Find Orientation then Find Location . . . . . . . . . . . . . . . . . . . . . . . 147.4 Training Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147.5 Dependence on Dipole Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157.6 Different Number Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167.7 Different Number of Points Measured . . . . . . . . . . . . . . . . . . . . . . . . . 167.8 Grid Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.9 Cross-validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187.10 Model with Multiple Shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

7.10.1 Grid Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217.10.2 Cross-validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

8 Application to Real EEG Data 238.1 The EEG-data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238.2 Results for Dipole Estimation on Real EEG Data . . . . . . . . . . . . . . . . . . . 24

9 Conclusion 27

Page 3: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

1 Introduction

1.1 Background

For the treatment and diagnosis of the cerebrum it is crucial to be able to analyze the brain ac-tivity at a high level of detail. In the past 15 years the detection and analysis of brain waveshave seen vast advances [1]. The most common methods for detection are functional magneticresonance imaging (fMRI), positron emission tomography (PET), single photon emission tomog-raphy (SPECT), electroencephalography (EEG) and magnetoencephalography (MEG) [1]. fMRI[3] and PET [5] use the fact that as neurons become active the local blood flow and oxygenationlevels change. Both of these methods have a high spatial resolution. Nevertheless, the temporalresolution is limited by the slow hemodynamics compared to the dynamics of the brain [1]. EEGand MEG are based on the electromagnetic field that the brain emits if certain areas are active.Each of these methods has their strengths and weaknesses. The strengths of EEG are high temporalresolution and its noninvasiveness. Hence, it can also be used bedside (e.g. in intensive care). Foran EEG measurement electric potentials on the surface of the scalp are recorded. These potentialsare directly linked to brain activity. If a large number of electrodes are used it is possible to achievea high spatial resolution. In clinical diagnostics EEG is used in a large number of applications. Itis, for instance, used to classify epilepsy [8]. For this classification it is vital to know where theepileptic seizures originate from.These considerations show that it is important to be able to localize brain activity from EEGmeasurements.

1.2 Problem

The brain activity recorded from an EEG measurement results from two types of sources: theintracellular (primary current) and extracellular currents (secondary, return or volume currents)[1]. The main generators of the recorded potentials are pyramidal cortical neurons. These arean alignment of tens of thousands neurons which are activated synchronously. In order to localizethese sources one needs to understand first how they affect the electric potentials on the scalp whichare measured. This can be regarded as a forward problem. In this thesis, several assumptions aremade:

1. The currents in the brain (primary and secondary) are modeled as one current dipole

2. The complex geometry of the head first is assumed to be a homogeneous sphere. The secondmodel that will be used is a sphere consisting of multiple shells

3. The system is quasi-static

With these assumptions the problem simplifies to computing the electric potential on the surfaceof a homogeneous sphere given the location and orientation of a current dipole situated in globe.A solution can be found in [18]. It is nonlinear.These assumptions made, it is only possible to detect brain activity if one part of the brain is a lotmore active than the other parts. This is because the model of a single dipole assumes that onlya single pyramidal cortical neuron is activated. In the case of an epileptic seizure this assumptionis suitable because the region where the seizure originates is strongly activated.To compute the location and orientation of the dipole from EEG recordings this model needs tobe inverted. Since there are many more electrodes which measure the electrical potentials thandipoles, the solution of the EEG inverse problem is not unique. Hence the goal is to find a solutionwhich fits the given data best.

1

Page 4: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

1.3 Related Work

Over the past few decades a lot of research has been done on solving this problem. This resultedin a number of different methods and algorithms.These methods can mainly be divided into two categories: non-parametric and parametric. [7]In non-parametric methods several dipoles, whose locations are fixed, are used. Usually the dipolesare assumed to be oriented normally to the cortical surface. The goal is then to estimate theamplitude of theses sources. This problem is a linear one.Some of the non-parametric methods are MNE (minimum norm estimates) [11], LORETA (lowresolution brain electromagnetic tomography) [11] and LAURA (Local AUtoRegressive Average)[6] . In [7] these methods are compared. In most cases LORETA provides good results. It is basedon the maximum smoothness of the solution. The amplitude of the signal coming from the centerof the brain is lower than the one coming from the surface. The strength of LORETA compared tominimum-norm methods is that it is capable of reconstructing sources no matter where they arelocated [7].LAURA also takes biophysical and psychological information into account. Thus, it is possible toobtain an even lower localization error than for LORETA [7].For the parametric methods only a few dipoles are used. Since the forward model is not linear inthe source locations, this problem is non-linear. Parametric models include non-linear least-squaresproblem, beamforming approaches, subspace techniques, simulated annealing and finite elements,computational intelligence algorithms and estimation of initial dipoles for parametric methods [7].

1.4 Objectives

This project is concerned with solving the inverse problem in EEG source analysis using conceptsfrom machine learning. For this investigation a support vector regression (SVR) with a nonlinearkernel is used. Using the forward model a set of training data is built to train a Support VectorMachine (SVM). Statistical measurements are then used to verify the choice of the data set.Finally the SVM is trained so that it solves the inverse problem. In the end the performanceand accuracy of the different methods are compared. The benchmark for the performance is thecomputational time. For the accuracy it is the average localization error.

2 Problem Description

The goal of this work is to carry out an analysis of the brain activity by a given EEG measurement.To say something about the brain activity one needs to know how the brain activity affects thepotentials that are being measured by the EEG. For this so-called forward problem the head ismodeled as a sphere. In the simplest model the sphere is homogeneous. This means that theconductivity in this model is considered to be the same in the whole sphere. Since the brain has avery complex geometry and the conductivities of the brain, the skull, the cerebrospinal fluid (CSF)and the scalp differ, this is not a very realistic model. But for the purpose of testing the SVR andgetting some first results it is acceptable. The second model is a sphere that is built up by fourshells. This takes the different conductivities of the materials inside the head into account. Forboth of these models analytical solutions are available. The model for the homogeneous sphere istaken from [18]. There are two areas where the analytical solution is not valid. These zones can beseen in Figure 1. The dipole here is represented as a red arrow. The model is not valid for pointsthat are measured closer to the center of the sphere than the position of the dipole. The reasonfor this is the mathematical formulation of the model. This region is marked green. Because thedipole is a singularity, it is important that the dipole does not lie close to a measurement point.This is the second zone where the model is not valid. It is marked yellow. A measured point Pshould not lie in that region. The size of this zone needs to be determined empirically. This isdone in Section 7.5.

2

Page 5: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Figure 1: Areas (green and yellow) where the homogeneous sphere model is not valid.

For the parameters of the model, such as the radius of the sphere and the conductivities of thedifferent material, values based on literature are taken. The radius of the sphere is 8.8cm [10]. Forconductivity of the different materials in head there appear different values in literature. In thiswork for the conductivity of the homogeneous sphere the value 0.0006 S/m [17] is chosen.For the model with multiple shells the radius of the neural tissue is taken at 84% [2] of the outerradius of the head. For a radius of 8.8cm this is 7.392cm. It has a conductivity of 0.33 1

Ωm . Thelayer on top of the sphere representing the brain, the CSF, has a radius of 7.627cm [2] and aconductivity of 1 1

Ωm [2]. The skull has a radius of 8.33cm and a conductivity of 0.0042 1Ωm . The

scalp has the same conductivity as the brain.The brain activity is represented by a current dipole which produces an electric field around it.This dipole is defined by its location #»r 0 = (xx, xy, xz) and orientation

P = (mx,my,mz).The independent variables of the analytical solution of both models are location and orientationof the dipole as well as the location where potential is measured. So, the forward problem is of thefollowing form:

V = f(

#»r 0,#»

P ,#»

R)

where V is the potential at the point on the surface of the sphere#»

R.The function f is given by the corresponding analytical solution. It is a scalar function. Hence itis possible to use a one-dimensional support vector regressor. For the inverse problem the forwardproblem needs to be inverted. It then has the following form.

#»r 0,#»

P

= g(

V given,#»

Rgiven

)where

V given is a vector containing the potentials at the points#»

Rgiven.Since there are a lot more points measured than there are unknowns, this model cannot be invertedanalytically. The goal is to find a solution that fits the best. Because the function g is a vectorfunction, there is more than one output. So, it is not possible to use a one-dimensional SVR. Thereare two methods to deal with such problems. If the output variables do not strongly depend oneach other, one might split the n-dimensional problem up into n one-dimensional problems. Foreach of these n one-dimensional problems a single one-dimensional SVR can be used. If there is astrong dependence between the output variables, it is necessary to use a multi-dimensional SVR.The EEG inverse problem has six output variables. These are three coordinates for the locationand three for the orientation of the current dipole. So, if the field on the surface of a sphere isgiven one of the options is to estimate the coordinates of the location and the orientation of thedipole separately using six one-dimensional SVRs. The other approach would be to use a multi-dimensional SVR that has the six unknowns as output. Since a reliable multidimensional SVR isnot available yet, six one-dimensional SVRs are used in this thesis.

3

Page 6: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

3 Introducing the SVR

Support Vector Machines (SVM) belong to the field of machine learning. They can be used forstatistical classification and regression analysis [9]. SVM’s were originally developed for opticalcharacter recognition [14]. Later they were also used for object recognition, in regression and timeseries prediction [14].A set of input data is delivered to the SVM which then estimates a value for each of the inputdata. If the SVM is used for classification, this output is a discrete number. If a regression (SVR)is used, the output consists of real numbers. In this work only SVR’s are used. The objects of thetraining data are represented by a vector space [9]. For a statistical classification this space needsto be divided by a hyperplane [13]. Each of the sides of the hyperplane then represents a class.Depending on which side of the hyperplane a testing vector lies the SVM decides which class itbelongs to. The hyperplane can be fitted between the training vectors in many ways. The SVMdoes it in such a way that the distance to the vectors lying next to the plane, the support vectors,is maximized [13].It is only possible to use a hyperplane to separate the data if the objects are linearly separable.If they are not, the kernel trick is used [13]: The vector space is transferred to higher dimensionsuntil the data is linear separable. Afterwards, the vector space is transformed back into the originalspace. The problem is that the computational time of this transformation is very high. The kernelsare used to describe a face joint that represents a hyperplane in a higher dimension. The advantageof this is that the transformation can be done without actually performing all of the calculations.For the definition of this kernel only the support vectors are used. In this work linear (u′ · v) andradial basis function (RBF) kernels (exp(−γ · |u− v|2)) are used. This γ of the RBF kernel is oneof the two important parameters that the SVR uses. The other parameter is the cost parameterC. It provides soft margins that allow some misclassification. The higher C is, the more accuratethe model for the classification has to be. But if C is chosen too high the generalization from thetraining data to the testing data might be poor. This means that the SVR is only able to estimatevalues from the data it has been trained for, but not for other testing data.In order to do an estimation, the SVM needs to be trained in advance. The data used for thatcontains a set of training data and its corresponding target value. One-dimensional SVRs onlytake one target value. For problems with more than one output variable, multidimensional SVRsare used.In previous studies neural networks have been used to solve the EEG inverse problem [7]. Theysometimes predicted dipoles that lie outside of the head which is obviously nonsense. SVR is avery recent algorithm compared to the neural networks. That is the reason why they are preferredto neural networks.

4 Implementation

Data sizes for training a SVR can get large. Hence, it is important to choose a library for theSVR that is as fast as possible. The library libsvm [4] seems to be a good choice because it isvery fast and freely available. It offers SVM algorithms for classification as well as for regression.In this thesis only the SVR is used. Unfortunately, this library supports only one-dimensionalsupport vector regressors. In libsvm there are two different types of regressors: the epsilon-SVRand the nu-SVR. Here the epsilon-SVR is used. Four different kernel types are supported: linear,polynomial, RBF and sigmoid. Depending on the task, linear and RBF kernels are used in thiswork.Before the data for the training and estimation of the SVR can be used by the libsvm it has to betransformed into a special form. As the library is implemented in C++, the main program is alsoimplemented in the same programming language. In order to keep the code as simple as possible,MATLAB [12] is used for the data management. The data used to train the SVR for the differenttasks is calculated in MATLAB [12] and then stored in a text file. This process is also applied tothe data that has to be estimated. The C++ program then reads the data from the text file and

4

Page 7: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

sends it to libsvm. The result of the C++ code is the estimated value from the test data. This valueis again stored in a text file which can be read by the MATLAB [12] program. Using the receiveddata further calculations e.g. cross-validation can be done.

Figure 2: The blocks in blue are implemented in MATLAB [12] and the white blocks in C++

Depending on the task this procedure is repeated (e.g. for different training sizes).

5 SVR Tests

In order to find out how well the libsvm library works, it needs to be tested. For this purposeseveral regressions are run as examples. These tests include linear and nonlinear regressions forsingle as well as multidimensional functions.

5.1 Linear Regression

The starting point is a linear regression. Therefore a linear kernel is used. The function whichhas to be estimated by SVR in the first example is given by f(x) = 2x. To train the SVR a setof training data is generated. This means that for a number of random x the function value iscalculated. This function value is also called the target value. The training data then has thefollowing form:

Target value Training valuef(x1) x1

f(x2) x2

f(x3) x3

......

f(xN ) xN

The values on the left of the double line are the target values and the ones on the right are thetraining values. N is the size of the training data. For all the tests it is set to 100. While generatingtraining data it is important that there are no symmetries in the dataset (e.g. only values witha certain difference to each other), since then the SVR would also learn these symmetries. Toprevent that, the values for the training data (xi) are randomly chosen.

5

Page 8: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

After the SVR is trained, the desired points can be estimated. It is important to use different pointsfor the estimation than for the training because otherwise the SVR would already be trained forthese points. But the goal is to find out whether the SVR is able to estimate points it has not beentrained for.The result of this regression can be seen in Figure 3. Here 100 random points have been estimated.They are represented by the blue dots. The red line is the function f(x) = 2x that has to beestimated.As expected, the estimated points lie close to the red line.

0 5 100

5

10

15

20

x

2x

Figure 3: Linear Regression

5.2 Non-linear Regression

In the next step, the SVR is tested on polynomials and trigonometric functions. For this investiga-tion a RBF kernel is used. Figure 4 on the left shows the result of the regression. This procedurehas also been done for a sinusoid. The result can be seen in Figure 4 on the right. The SVR alsoprovides good results for non-linear functions.

0 1 2 3 4 5 6 7 8 9 100

20

40

60

80

100

120

140

160

180

200

x

2 x2

(a) 2x2

0 1 2 3 4 5 6 7 8 9 10−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

x

2sin(x)

(b) 2 sin(x)

Figure 4: Regression for the functions f(x) = 2x2 and f(x) = 2 sin(x)

6

Page 9: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

5.2.1 Multidimensional Functions

Since the problem of this thesis is multi-dimensional, in a sense that there is more than oneindependent variable, the SVR is also tested for these kinds of functions. As an example a regressionfor the function f(x, y) = x · y is run.The training data has the following form:

Target value Training valuesf(x11, x21) x11 x21

f(x12, x22) x12 x22

f(x13, x23) x13 x23

......

...f(x1N , x2N ) x1N x2N

The result of the regression can be seen in Figure 5. The red dots represent the functions thathave to be estimated and the green dots stand for the estimated points.

Figure 5: Regression for the function f(x, y) = x · y

This example shows that the estimation using a SVR is good also for multidimensional functions.The errors in all the tests are in the order of a few ‰.

6 EEG Forward Problem

6.1 One Regressor

Before starting with the solution of the inverse problem, the SVR is tested on the forward problem.The model for the forward problem is a homogeneous sphere. The dipole is placed somewhere inthe sphere and the electric potentials on different points on the surface of the sphere are calculatedusing the analytical solution from [18]:

V =

P

4πσ·

2

R − #»r 0

r3p

+1

R2rp

[#»

R +

Rr0 cosϕ−R #»r 0

R+ rp − r0 cosϕ

],

where#»

P = (mx,my,mz) is the orientation of the dipole at position #»r 0 = (xx, xy, xz).#»

R =(px, py, pz) is the place on the surface of the sphere where potential is measured. r0 is the lengthof #»r 0. rp is the distance between the measured point and the location of the dipole. ϕ is the anglebetween #»r and #»r 0. σ is the conductivity of the sphere. The training size is 1000. Using the aboveformula, training data that looks like this is obtained:

7

Page 10: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Target value Training valuesV1 px1 py1 pz1 xx1 xy1 xz1 mx1 my1 mz1

V2 px2 py2 pz2 xx2 xy2 xz2 mx2 my2 mz2

V3 px3 py3 pz3 xx3 xy3 xz3 mx3 my3 mz3

......

......

......

......

......

VN pxN pyN pzN xxN xyN xzN mxN myN mzN

Here Vi is the i’th target value. The training vector contains the point on the sphere where thepotential is measured, the location as well as the orientation of the dipole. This means that theSVR is trained to estimate the electric potential at a given point resulting from a dipole at a givenlocation and orientation.In order to minimize symmetries in the training data, the dipole and the measurement points arechosen using a random number generator.For the regression a RBF kernel is used. Since the result of the regression turned out to be verysensitive to the parameter of the SVR, it is important to find the optimal parameters.In this work this is done for the two parameters C and γ. While holding γ constant, C is varieduntil the estimation error is minimal. In a second step, γ is varied while the value of C is heldconstant. The error is given by the 2-norm of the difference between the estimated and calculatedfields divided by the number of points that are estimated:

ε =|| #»V i,est −

V i,cal||2k

,

where#»

V i,est is the vector containing the potentials estimated by the SVR and#»

V i,cal is the potentialcalculated using the analytical solution. k is the number of points that are estimated. (|| · ||2 is the2-norm). In the case of the forward problem, 64 points are estimated.

6.1.1 Parameter Optimization

First C is varied. Figure 6 shows the error for different C’s while γ is held constant at 0.01. Thisvalue is chosen because the tests above showed that this value for γ is typically a good first guess.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11.513

1.5135

1.514

1.5145

1.515

1.5155

1.516

1.5165

1.517

1.5175

1.518

C

error

Figure 6: C is varied while γ is held constant at 0.01

In this manner the optimal value for C is found as 0.282. In the next step C is held constant atits optimal value and γ is varied.

8

Page 11: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

0 0.05 0.1 0.15 0.2 0.25 0.3 0.351.512

1.5125

1.513

1.5135

1.514

1.5145

!

error

Figure 7: γ is varied while C is held constant at 0.282

The optimal value for γ is then 0.0611.Using the optimal parameters a regression is run. The result can be seen in Figure 8. On theleft the field one can see the field which is obtained by the analytical solution. On the right theestimated field is plotted. The color stands for the value of the potential at that point. In Figure9 the difference between the field which is estimated by the SVR and the field calculated using theanalytical solution is plotted.

−10

0

10

−10−5

05

10−10

−5

0

5

10

calculated field

−5

−4

−3

−2

−1

0

1

2

3

4

−10

0

10

−10−5

05

10−10

−5

0

5

10

estimated field

−2.5−2−1.5−1−0.500.511.522.5

−10

0

10

−10−5

05

10−10

−5

0

5

10

estimated field − calculated field

−1.5

−1

−0.5

0

0.5

1

1.5

2

2.5

3

Figure 8: Regression for EEG forward problem

9

Page 12: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

−10

0

10

−10−5

05

10−10

−5

0

5

10

calculated field

−5

−4

−3

−2

−1

0

1

2

3

4

−10

0

10

−10−5

05

10−10

−5

0

5

10

estimated field

−2.5−2−1.5−1−0.500.511.522.5

−10

0

10

−10−5

05

10−10

−5

0

5

10

estimated field − calculated field

−1.5

−1

−0.5

0

0.5

1

1.5

2

2.5

3

Figure 9: Difference between the calculated and the estimated field

Hence, if there is only one regressor used for all the points in the sphere, the error is relativelyhigh. It is better to use one SVR for each of the measured points on the surface of the sphere.

10

Page 13: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

6.2 Multiple Regressors

For the forward problem, 100 points are measured. Each one of these regressors estimates the fieldat the position it belongs to. Hence there are as many regressors as there are points measured. Forthe training data the position of the place where the potential is measured is not given any more.The training data is given as follows:

Target values Training valuesV11 xx1 xy1 xz1 mx1 my1 mz1

V12 xx2 xy2 xz2 mx2 my2 mz2

V13 xx3 xy3 xz3 mx3 my3 mz3

......

......

......

...V1N xxN xyN xzN mxN myN mzN

V21 xx1 xy1 xz1 mx1 my1 mz1

V22 xx2 xy2 xz2 mx2 my2 mz2

V23 xx3 xy3 xz3 mx3 my3 mz3

......

......

......

...V2N xxN xyN xzN mxN myN mzN

......

......

......

......

...

Vt1 xx1 xy1 xz1 mx1 my1 mz1

Vt2 xx2 xy2 xz2 mx2 my2 mz2

Vt3 xx3 xy3 xz3 mx3 my3 mz3

......

......

......

...VtN xxN xyN xzN mxN myN mzN

Each table above stands for one of the t regressors. All regressors receive the same orientationsand locations of the dipoles as training data but measured at different places on the sphere.The result of the regression can be seen in Figures 10 and 11. The result is a lot better than theone where only one regressor is used.

−100

10

−10

0

10−10

−5

0

5

10

calculated field

−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

−100

10

−10

0

10−10

−5

0

5

10

estimated field

−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

−100

10

−10

0

10−10

−5

0

5

10

calculated field − estimated field

−0.1

−0.05

0

0.05

0.1

0.15

Figure 10: Regression for EEG forward problem using multiple regressors

11

Page 14: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

−100

10

−10

0

10−10

−5

0

5

10

calculated field

−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

−100

10

−10

0

10−10

−5

0

5

10

estimated field

−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

−100

10

−10

0

10−10

−5

0

5

10

calculated field − estimated field

−0.1

−0.05

0

0.05

0.1

0.15

Figure 11: Difference between the calculated and the estimated field

6.3 Computational Time

One of the goals of the thesis is to have a reasonable computational time. But as one increases thesize of training data in order the achieve a small error, the computational time rises.To take this effect into account, the error and computational time can be plotted for different sizesof training data for the EEG forward problem using one regressor.Figure 12 shows the error and computational time for different training data sizes.

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

3

4

5

6

data size

red:

com

puta

tiona

l tim

e (s

) , b

lue:

erro

r

Figure 12: Computational time and error plotted for different training data sizes for the case ofmultiple regressors

Up to a training size of about 1000, the error decreases heavily. For bigger data sizes, the error isalmost constant while the computational time increases steadily. In order to keep the time spentfor a regression short, it does not make any sense to use a training size that is larger than 1000-1500in this case.

12

Page 15: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

7 EEG Inverse Problem

In case of the forward problem there are one target value and six or nine training values, dependingon whether one or multiple regressors are used. The EEG inverse problem is different in a sensethat there are six target values and a large number of training values. The six target valuescome from the three dimensions of the orientation and location of the dipole. Because the sixvariables depend on each other the problem is multidimensional. Since libsvm does not supportmultidimensional support vector regression, the goal is to split up the six dimensional probleminto six one dimensional problems, which can each be treated separately by one SVR. The trainingvalues are the values of the field at the measured points. Here, the number of training pointsis 64. This is one of the standard configurations used for EEG measurements. Later on otherconfigurations are tested. The model that is first tested is the homogeneous sphere model.

7.1 Treating Each Dimension Separately

The easiest way of splitting up the six-dimensional problem is to treat each of the dimensionsseparately. The training values are then the values of the field at the measured points and thetarget value one of the six coordinates of the location and the orientation.

7.1.1 Training Data

The training data has the following form:

xx1 V11 V12 · · · V1k

xx2 V21 V22 · · · V2k

xx3 V31 V32 · · · V3k

......

.... . .

...xxN VN1 VN2 · · · VNk

mx1 V11 V12 · · · V1k

mx2 V21 V22 · · · V2k

mx3 V31 V32 · · · V3k

......

.... . .

...mxN VN1 VN2 · · · VNk

xy1 V11 V12 · · · V1k

xy2 V21 V22 · · · V2k

xy3 V31 V32 · · · V3k

......

.... . .

...xyN VN1 VN2 · · · VNk

my1 V11 V12 · · · V1k

my2 V21 V22 · · · V2k

my3 V31 V32 · · · V3k

......

.... . .

...myN VN1 VN2 · · · VNk

xz1 V11 V12 · · · V1k

xz2 V21 V22 · · · V2k

xz3 V31 V32 · · · V3k

......

.... . .

...xzN VN1 VN2 · · · VNk

mz1 V11 V12 · · · V1k

mz2 V21 V22 · · · V2k

mz3 V31 V32 · · · V3k

......

.... . .

...mzN VN1 VN2 · · · VNk

where Vij is the electric potential at the jth point measured for the ith training value. Againthe potentials Vij are calculated using the analytical solution, in this case with the model of thehomogeneous sphere. The error of the orientation is given by the 2-norm of the difference betweenthe estimated and the calculated orientation:

ε = || #»mest − #»mcal||2

The error for the location is calculated equivalently.In order to compare the results, here the dipole is always placed at a distance of 3cm from thecenter.

13

Page 16: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

The SVR uses a RBF kernel. The parameters for the regression for the orientation are: γ = 0.0002,C = 4.5. For the location we find: γ = 0.001 and C = 40. These parameters are found in the samemanner as described for the forward problem. The error for the orientation then is 0.8% and theerror for the location 2.3%. So, the error for the orientation is much smaller than the one for thelocation. Hence, if the field on the surface of the sphere is given, it is easier to find the orientationrather than the location.

7.2 Finding the Location for a Constant Orientation

Another approach is to keep the orientation constant and then try to find the location of thedipole. This would reduce the six-dimensional problem to three dimensions, since only the threecomponents of the location of the dipole are unknown. The training data for the location looksthe same as in the example above. The difference is that the potentials Vij originate from a sourcethat only allows one orientation. This orientation is chosen at the beginning of the training andkept constant. The optimal parameters used here are: γ = 0.01, C = 24. Using these parametersto run a regression, a localization error of 0.14 % is found. This error is of course a lot smallerthan the localization error found when the orientation is not constant because there are only threeoutput variables.

7.3 First Find Orientation then Find Location

The goal of this work is to combine the two methods above in order to get a smaller error thanby treating each of the six dimensions separately. The combination of the two methods works asfollows:

• Train SVR for the orientation in the same way as if the dimensions were treated separately

• Use test data to estimate the orientation of the dipole

• Using the found dipole, generate a set of training data with the found orientation and thecomponents of the location as the target value

• Find the dipole location from test data

In the next sections this method is verified.

7.4 Training Size

The first important thing to determine is the appropriate size of the training data. If it is chosentoo small, the error will be large and if is too high the computational time will rise. In order tofind out how big the training data should be to achieve the optimal trade-off between error andcomputational time, the error and computational time are computed for different sizes of trainingdata. The result can be seen in Figure 13. In Figure 13(a) the red line is the error in estimating theorientation and the blue line the error in estimating the location. The errors are absolute values.The radius of the sphere is 8.8cm and the magnitude of the dipole is chosen to be 1.

14

Page 17: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

0 1000 2000 3000 4000 5000 6000 70000

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0.16

0.18

0.2

size of training data

erro

r

(a) Error

0 1000 2000 3000 4000 5000 6000 70000

200

400

600

800

1000

1200

size of training data

com

puta

tiona

l tim

e

(b) Computational time

Figure 13: Computational time and error for different sizes of training data

Up to a training size of 1000, the error for both location and orientation is heavily decreasing. Fortraining sizes above 1000 the error is almost constant. Since the computational time increases veryfast, a training size between 1000 and 2000 seems to be a reasonable choice. In this work a trainingsize of 1500 is chosen.

7.5 Dependence on Dipole Location

As mentioned above the analytical solution is not correct if the dipole lies close to the surface. Thereason for this is that the dipole is a singularity. Hence the position where the dipole is locatedneeds to be restricted to a sphere that has a smaller radius than the head. To find out what thesize of this radius is, the dipole is placed at different distances to the center. For each of thesedistances the localization error is calculated. The result can be seen in Figure 14.

0 1 2 3 4 5 6 7 8 90

5

10

15

20

25

distance from center

loca

lizat

ion

erro

r

Figure 14: Error depending on the distance from the center of the sphere

Up to ca. 50% of the outer radius of the sphere, the error is small. For distances above that theerror is a lot higher. So if the homogeneous sphere model is used, only dipoles that lie closer than50% of the outer radius of the sphere can be estimated accurately.

15

Page 18: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

7.6 Different Number Generators

The reason for the increasing error for dipoles that lie closer to the surface of the sphere might alsocome from the fact that there is less training data on the surface of the sphere. To show that theincreasing error is not based on that effect, more training points are used the closer to the surfacethe location of dipole gets. This can be achieved using a different random number generator forthe training data. Up to now a uniform distribution was used. Here the uniform distribution iscompared to a triangular one. The triangular one is shown in Figure 15(a). More numbers closerto one occur. If these random numbers are multiplied by the radius of the sphere, more numbersoccur near the value of the radius. These random numbers are then used to compute the trainingdata. So for the training, more dipoles close to the surface are used.The comparison of the two distributions can be seen in Figure 15(b). As expected, the result doesnot get better by using a different distribution. It gets even worse. So, the phenomenon that thelocalization error is bigger the further apart the dipole is from the center seems to be based onphysical reasons. Hence, it is not possible to do anything about it but restrict the area where thedipoles are allowed to be located.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2x 104

random number

num

ber o

f tim

es o

ccur

ed o

ut o

f 105

(a) triangular distribution

0 2 4 6 8 10 12 14 16 180

5

10

15

20

25

R

Loca

lisat

ion

Erro

r

Triangular DistibutionUniform Distribution

(b) Error depending on the distance to the center of thesphere for uniform and triangular distributions

Figure 15

7.7 Different Number of Points Measured

In practice, there are different configurations of the electrodes used for an EEG measurement. Theydiffer in the number of electrodes used and the location where they are placed. Since it takes a lotof time to place the electrodes at the right position, it is important to use a number of electrodesthat is high enough for a good localization of the brain activity.In order to find out how many electrodes need to be used to get a good result, the number of pointsthat are measured are varied from 1 electrode up to 100 and the error is calculated for each of theconfigurations. The result can be seen in Figure 16.

16

Page 19: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

0 10 20 30 40 50 60 70 80 90 1000

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

number of points measured

loca

lizat

ion

erro

r

(a) Localization error

0 10 20 30 40 50 60 70 80 90 1000

10

20

30

40

50

60

number of points measured

com

puta

tiona

l tim

e [s

]

(b) Computational time

Figure 16: Localization error and computational time for different numbers of points measured

Up to 40 points measured the error decreases heavily. For more than 40 points the error staysapproximately constant. One of the standard EEG configurations uses 64 electrodes. Hence, usingthis configuration, there should be enough points measured to be able to compute the location ofthe dipole. If it is necessary for the localization to be even more accurate, one can use an EEGconfiguration with 128 electrodes, but the decrease of the error will not be very large.The computational time rises approximately linearly.

7.8 Grid Search

The methods to find the optimal parameters for the SVR (γ,C) as described above might onlydeliver local minima instead of global ones. In order to find the global minima a grid searchis carried out. For every combination of γ and C a regression is run and the absolute error iscalculated. The result for the homogeneous sphere can be seen in Figure 17

012345

x 10−5

0

2

4

6

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

C

gamma

C = 4, gamma = 4.41 *10−4

erro

r

(a) Error in orientation

0 0.002 0.004 0.006 0.008 0.01

0

20

40

60

80

1000

2

4

6

8x 10−3

gamma

C

erro

r

(b) Error in localization

Figure 17: Grid search for homogeneous sphere

For the orientation the optimal parameters are: C = 4, γ = 4.41 · 10−4. For the location, theparameters C = 40 and γ = 2.4 · 10−3 are found.

17

Page 20: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

For these parameters a regression is run. The result of such a regression can be seen in Fig-ure 18. The dipole has been placed at a random location with a random orientation. Using theanalytical solution, the field is calculated at 64 random locations on the surface of the sphere.These 64 measurement points represent the location of the electrodes in an EEG. This field is theinput data for the regression. It is plotted in the top left picture of figure 18. In the bottom leftpicture both the dipole that has been used to generate the testing data and the estimated dipoleof the regression are plotted. Since they lie very close together it seems as if there was only one.On the top right the field that results from the estimated dipole is plotted. In order to make thedifferences between the calculated field and the estimated field visible, in the bottom right picturethe difference of the two is plotted.

Figure 18: Result of the algorithm

7.9 Cross-validation

To find out how well an algorithm will perform in practice, a cross-validation is carried out. Here,this is done for a 3- and a 5-fold cross-validation. For a 3-fold cross-validation a set of trainingdata is generated. Two thirds are then used to train the SVR. The left third is used as the testingdata. This is done three times so that every third has been used once as testing data. The errorfor each fold is calculated. The error is then calculated as the average of the three folds. The 5-foldcross validation is the same as the 3-fold cross-validation but here, the training data is split intofive parts. The data size for the cross-validation is 2250. The size of the training data for a 3-foldcross-validation is 1500. The other 750 data points are then estimated by the SVR.

18

Page 21: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

For the 5-fold cross-validation the size of the training data is 1800. 450 orientations and locationsare estimated. As before the absolute error is calculated as the 2-norm of the difference of theestimated and the calculated vector. The relative localization error is calculated as the norm ofdifference between the estimated and the calculated location divided by the norm of the calculatedlocation.

εrel =|| #»r 0,est − #»r 0,cal|||| #»r 0,cal||

The relative error of the orientation is the same as the absolute error since the norm of the orien-tation is always one.These errors are calculated for the case where the dipole is allowed to lie in the whole sphere andthe case where the dipole location is restricted to an inner sphere with radius 5cm.There are two possible localization error sources. First the error that arises even if the orientationwas estimated correctly. Second the error resulting from the fact that the orientation for whichthe SVR has been trained for is contaminated with an error. This error is referred to as the overallerror. To distinguish between the two errors, two separate cross-validations are performed. Forthe first the input is the field. The output is the location. In this case the error is the overall error.Here also the error in the orientation is calculated. For the second cross-validation, the error fromthe orientation to the localization is calculated.The results of these cross-validations can be seen in the following tables.

Absolute error

Radius is restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold0.0242 0.0182 0.0022 0.0015 0.0923 0.06780.0206 0.0170 0.0022 0.0015 0.0808 0.06280.0218 0.0170 0.0021 0.0017 0.0782 0.0644

0.0208 0.0014 0.06820.0191 0.0018 0.0696

Radius is not restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold0.2242 0.2159 0.7705 0.6601 1.5375 1.56290.2420 0.2249 0.9385 0.7045 1.6992 1.73490.2570 0.2275 0.7259 0.9486 2.0709 1.5812

0.2340 0.7104 1.65210.2485 0.6559 1.8566

19

Page 22: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Relative error

Radius is restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold

0.0012 0.5181 ·10−3 0.0290 0.02050.0008 0.9998 ·10−3 0.0256 0.01930.0007 0.4742 ·10−3 0.0268 0.0198

0.7823 ·10−3 0.02210.7480 ·10−3 0.0209

Radius is not restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold

0.0997 0.0844 0.2184 0.21650.1191 0.0910 0.2404 0.24010.0926 0.1178 0.2871 0.2233

0.0894 0.22880.0843 0.2566

The first thing that is striking about these results is that the error for the 5-fold cross-validationis always smaller than the error for the 3-fold cross-validation. This results from the fact that thetraining size for the 5-fold cross-validation is larger.The error for the localization is smaller than the error for the orientation. This makes sensesince the problem of finding the location has three dimensions, whereas the problem to find theorientation has six unknowns.As expected, the overall error is not the sum of the error for the orientation and the location. Theorientation for which the SVR for the location has been trained for is contaminated by an error.Therefore the additional error for the location is a lot higher than the error if the orientation wascorrect. This shows that the biggest part of the error for the localization comes from the fact thatthe orientation for the training is contaminated by an error.If the location of the dipole is not restricted, the error is about 10 times higher than in the casewhere the location is restricted.

7.10 Model with Multiple Shells

The second model that is used in this thesis is the sphere that is built up by several spherical shells.The model is taken from [15]. The four shells represent brain, CSF, skull and scalp. The code usedhere is taken from [16]. It is a very efficient C++ implementation. Since brain activity can onlyappear in the inner sphere, representing the brain, the dipole location is already restricted. Hencethe problem that the error rises for further distances from the center of the sphere is no longer ofinterest.Apart from this, the solution of the EEG inverse problem is the same as for the homogeneoussphere. The only difference is that the training data is generated using a different model.

20

Page 23: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

IEEE TRANSACTIONS ON BIOMEDICAL ENGINEERING, VOL. 44, NO. 12, DECEMBER 1997 1243

An Efficient Algorithm for Computing MultishellSpherical Volume Conductor Models inEEG Dipole Source Localization

Mingui Sun, Member, IEEE

Abstract—Computationally localizing electrical current sourcesof the electroencephalographic signal requires a volume con-ductor model which relates theoretical scalp potentials to thedipolar source located within the modeled brain. The commonlyused multishell spherical model provides this source–potentialrelationship using a sum of infinite series whose computationis difficult. This paper provides a closed-form approximationto this sum based on an optimal fitting to the weights of theLegendre polynomials. The second-order (third-order) approxi-mation algorithm, implemented by a provided C-routine, requiresonly 100 (140) floating point operations to compute a singlescalp potential in response to an arbitrary current dipole locatedwithin a four-shell spherical volume conductor model. This costof computation represents only 6.3% (8.9%) of that required bythe direct method. The relative mean square error, measuredby using 20 000 random dipoles distributed within the modeledbrain, is only 0.29% (0.066%).

Index Terms— Approximation, bioelectric phenomena, bio-physics, brain, brain modeling, dipole localization, electro-encephalography, electromagnetic fields, fast algorithm, forwardsolution, head, inverse problems, multichannel EEG, sourcelocalization.

I. INTRODUCTION

LOCALIZING electrical activity within the brain basedon multichannel electroencephalograms (EEG) has been

a problem of major significance in both basic and clinicalneuroscience [1]. In this approach active neurons within smallregions of the brain are often modeled as current dipoles whoseparameters may be computationally determined based on theobserved EEG data from the scalp. This has been consideredas an inverse problem of the EEG [2], [3]. Solving this problemrequires a theoretical model to specify the geometry andconductivity of the head. Although several sophisticated headmodels have been developed which provide realistic headshapes [4], most frequently used models are multishell spheri-cal models due to their simplicity in theoretical treatment andcomputation. These models consist of three to four concentricshells (see Fig. 1 for the four-shell model) with differentconductivity values representing the brain, skull, cerebrospinalfluid (optional), and scalp [5]–[7]. The problem of modeling

Manuscript received October 1, 1996; revised June 18, 1997. This workwas supported by the Whitaker Foundation under the Biomedical EngineeringGrant Program.The author is with the Department of Neurosurgery, Suite B-400,

PUH, University of Pittsburgh, Pittsburgh, PA 15213 USA (e-mail:[email protected]).Publisher Item Identifier S 0018-9294(97)07600-3.

Fig. 1. Central cross-section of the four-shell spherical volume conductormodel. The brain, cerebrospinal fluid, skull, and scalp regions are illustrated,and their respective conductivity values are labeled by . Theboundaries of these regions are located at , , and , where is theradius of the head model.

the head volume conductor is called the forward problem ofthe EEG.The forward problem has been investigated for about half of

a century since Wilson and Bailey derived an analytic solutionrelating a current dipole within a homogeneous sphericalvolume conductor to the electric potential at the surface ofthe sphere [8]. Analytic solutions were later derived for thethree-shell spherical volume conductor by Rush and Driscoll[5]. Subsequently, two four-shell models were presented byCuffin and Cohen [6] and Stok [7]. More recently, analyticsolutions for the spheroidal conductor with arbitrary numberof concentric shells were provided by de Munck [9]. Inaddition, de Munck and Peters [10] derived a mathematicalasymptotic approximation to these analytic solutions. Amongvarious spherical and spheroidal models only the homogeneousmodel has a closed-form solution. The analytic solutions forthe remaining models must be represented by infinite sumsof weighted Legendre and associated Legendre polynomials.Since the forms of these solutions are complicated and manyterms of polynomials must be evaluated to achieve sufficientaccuracy, practical computations of these analytic solutionsare considerably expensive.Efforts have been made to improve computational effi-

ciency of the multishell spherical head models. Ary et al.presented a simple transformation between the source locations

0018–9294/97$10.00 ! 1997 IEEE

Figure 19: Model with four shells [16]

7.10.1 Grid Search

To find the optimal parameter for the SVR, as for the model with the homogeneous sphere, a gridsearch is performed. The result can be seen in Figure 20.

00.01

0.020.03

0.040.05 0

50

100

150

200

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

C

gamma

error

(a) Error in orientation

0

1

2

3

4

5

050

100150

200250

300

0

1

2

3

4

5

Cgamma

error

(b) Error in localization

Figure 20: Grid search for inhomogeneous sphere

For the orientation the parameters C = 8 and γ = 0.022 are found. For the localization the optimalparameters are C = 300 and γ = 0.6.

7.10.2 Cross-validation

As for the model of the homogeneous sphere, a 3- and 5-fold cross-validation is carried out. Thisresults show the same regularity as for the model of the homogeneous sphere. The difference isthat overall error is a lot smaller.

21

Page 24: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Absolute Error

Radius is restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold0.0013 0.0013 0.0010 0.8302 ·10−3 0.0059 0.00590.0014 0.0014 0.0010 0.7792 ·10−3 0.0056 0.00560.0013 0.0013 0.0011 0.7635 ·10−3 0.0058 0.0058

0.0013 0.7254 ·10−3 0.00560.0014 0.9346 ·10−3 0.0059

Radius is not restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold0.0055 0.0055 0.0234 0.0209 0.0358 0.03580.0062 0.0062 0.0275 0.0153 0.0337 0.03370.0058 0.0058 0.0271 0.0271 0.0381 0.0381

0.0062 0.0187 0.03970.0067 0.0158 0.0400

Relative Error

Radius is restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold

0.5237 ·10−3 0.3461 ·10−3 0.0033 0.00330.3629·10−3 0.8249·10−3 0.0027 0.00270.4609·10−3 0.2844·10−3 0.0029 0.0029

0.3246·10−3 0.00570.4997·10−3 0.0031

Radius is not restricted

Orientation Location Overall3-Fold 5-Fold 3-Fold 5-Fold 3-Fold 5-Fold

0.0037 0.0032 0.0070 0.00700.0041 0.0028 0.0063 0.00630.0041 0.0040 0.0071 0.0071

0.0029 0.00920.0026 0.0075

22

Page 25: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

8 Application to Real EEG Data

The final step of this thesis is to apply the algorithm to real EEG data. The procedure for this isthe following.

• Read training data for orientation from text file

• Train SVR with this training data

• Estimate dipole orientation using the EEG data

• Generate training data for location according to the estimated orientation

• Estimate dipole location using the EEG data

8.1 The EEG-data

The EEG data was provided by Dr. Lorena Gianotti1 . The data was measured based on a 10/10system with 64 channels. This configuration can be seen in Figure 21. Reference electrode was Cz.The data was recorded with a sampling ratio of 512 Hz for 500 ms. This corresponds to 256 datapoints. The data was filtered from original 0.3-70 Hz to 2-20 Hz. The data shows a visual evokedpotential with a brain activity in the occipital lobe after 104 ms.

Figure 21: The yellow dots on the sphere show where the electrodes of the EEG lie on the sphere

In Figure 22 the EEG data used in this thesis is plotted. On the left hand side, the names of theelectrodes are written. The abscissa is the time axis and on the ordinate the electric potential isplotted in micro volts. The blue line shows when the visual evoked potential happens. On someelectrodes the potential changes rapidly at any point of time.

1Department for Social and Affective Neuroscience, Faculty of Psychology, University of Basel, Switzerland

23

Page 26: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

Figure 22: EEG data

8.2 Results for Dipole Estimation on Real EEG Data

For every time step of the EEG Data, the dipole location and orientation are calculated. Thefield of the estimated dipole is calculated using the analytical solution. Since a true dipole is notavailable here it is not possible to calculate the localization error. The error in this case is the sameas for the forward problem. It is calculated as 2-norm of the difference between the field givenby the EEG data and the field that was calculated from the analytical solution of the estimateddipole. Figure 24 shows the result of algorithm for one time step. On each of the images in theleft column, on the top left the EEG data is plotted. The estimated dipole is drawn on the bottomleft. The picture on the top right shows the field that the estimated dipole emits. On the bottomright image the difference between the EEG data and the calculated field is plotted. The differenceof the field shows that on some points the estimated field fits the EEG-data well, whereas at othermeasured points there occur large errors.The magnitude of the error depends heavily on the brain activity. This can be seen in Figure 23,where the error is plotted for every time step. As mentioned above, one of the assumptions for themodel was that only one part of the brain is active. Therefore, if there is no area of the brain thatis a lot more active than the other parts, the SVR will not be able to estimate the location of thedipole. Hence the error rises. It is important to say that this error is not a result of an error inthe estimation using an SVR. It comes from the fact that the model is not accurate enough. Evenan estimation of dipoles which lie outside of the head is possible.

24

Page 27: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.50

0.05

0.1

0.15

0.2

0.25

time [s]

erro

r

Figure 23: EEG error over time

In the data used in this thesis such a brain activity of a certain part of the brain first occurs after104 ms. Because of the visually evoked potential the occipital lobe is active. As expected, theerror is small at this time. Figure 24(a) shows that the estimated dipole location is in that region.After 0.3s the error is again small. The location of the dipole is again in the occipital lobe. Thiscan be seen in Figure 24(b). After 0.45s the dipole travels to the to the frontal lobe. The plot ofthis is in Figure 24(c).

25

Page 28: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

(a) 104ms

(b) 300ms

(c) 450ms

Figure 24: Field and dipole location for different time steps

26

Page 29: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

9 Conclusion

In this thesis a new attempt in solving the inverse EEG problem has been made. For the forwardproblem two different models were used. In both cases the head is modeled as a sphere with asingle current dipole in it. In the first model the conductivity is constant in the whole sphere.In the second, more realistic model, the sphere is built up by several shells which have differentconductivities.First the SVR is tested on the forward problem. Here only the homogeneous model is taken intoaccount. It turned out that it is a lot better to use a SVR for each of the measured points ratherthan using one SVR for all of the measured points.For the inverse problem first the homogeneous sphere model is used. The error rises heavily if thedipole is placed at a distance that is further apart from the center of the sphere than 5cm. There-fore it makes sense to restrict the location where the dipole is allowed to be placed by a distanceof 5cm from the center of the sphere. In this manner, the relative overall localization error can bereduced by a factor of approximately 10. For the absolute error, the factor is approximately 20.In one of the standard EEG measurement configurations 64 electrodes are used. This seems to bea good number since for more electrodes the error does not decrease a lot more. But the compu-tational time increases linearly. This means that the 64 electrodes used are enough for a sourcelocalization.The results of the cross-validation for the inhomogeneous model show that the localization erroris smaller for this model. The error for the orientation is approximately 10 times smaller for theinhomogeneous model, whereas the localization error for a constant orientation is only about twotimes smaller. This shows that the reduction in the overall localization error is mostly a conse-quence of the orientation being estimated more accurately in the inhomogeneous model.In the case of the inhomogeneous sphere, the location where the dipole is allowed to lie is alreadyrestricted to the smallest sphere of the different shells. Hence, a further restriction to a radius of5cm does not reduce the error as much as in the case of the homogeneous sphere. The reductionfactor for the relative overall error for the inhomogeneous model is approximately two. For theabsolute error it is about 6.5.

LORETA has a maximal absolute localization error of 2.04mm [7]. If the method presented inthis thesis is used the maximal absolute overall localization error is 1.667mm. This is the maximalvalue that occurred during the cross-validation. Hence by using a SVR instead of LORETA, themaximal absolute localization error can be reduced by 0.373mm. The great advantage of the SVRis that it is not an actual inversion of the model but rather a training for the inverse problem. Thisallows the use of more realistic models.

References

[1] S. Baillet, J.C. Mosher, and R.M. Leahy. Electromagnetic brain mapping. Signal ProcessingMagazine, IEEE, 18(6):14–30, 2001.

[2] P. Berg and M. Scherg. A fast method for forward computation of multiple-shell sphericalhead models. Electroencephalography and clinical Neurophysiology, 90(1):58–64, 1994.

[3] B. Chance and A. Villringer. Non-invasive optical spectroscopy and imaging of human brainfunction. Trends Neurosci, 20:435–42, 1997.

[4] Chih-Chung Chang and Chih-Jen Lin. LIBSVM: A library for support vector machines. ACMTransactions on Intelligent Systems and Technology, 2:27:1–27:27, 2011. Software available athttp://www.csie.ntu.edu.tw/ cjlin/libsvm.

[5] S.R. Cherry, M.E. Phelps, et al. Imaging brain function with positron emission tomography.Brain mapping: The methods, pages 191–221, 1996.

27

Page 30: Department of Computer Science Bachelor Thesis …mosaic.mpi-cbg.de/docs/Bircher2011.pdfDepartment of Computer Science Bachelor Thesis Solving the Inverse Problem in EEG Source Localization

[6] R. Grave de Peralta Menendez, M.M. Murray, C.M. Michel, R. Martuzzi, and S.L. Gonza-lez Andino. Electrical neuroimaging based on biophysical constraints. NeuroImage, 21(2):527–539, 2004.

[7] R. Grech, T. Cassar, J. Muscat, K. Camilleri, S. Fabri, M. Zervakis, P. Xanthopoulos,V. Sakkalis, and B. Vanrumste. Review on solving the inverse problem in eeg source analysis.Journal of neuroengineering and rehabilitation, 5(1):25, 2008.

[8] H. JASPER and J. Kershman. Electroencephalographic classification of the epilepsies.Archives of Neurology and Psychiatry, 45(6):903, 1941.

[9] O.Z. Maimon and L. Rokach. Data mining and knowledge discovery handbook. Springer-VerlagNew York Inc, 2005.

[10] B. Neil Cuffin and D. Cohen. Comparison of the magnetoencephalogram and electroencephalo-gram. Electroencephalography and Clinical Neurophysiology, 47(2):132–146, 1979.

[11] R.D. Pascual-Marqui. Review of methods for solving the eeg inverse problem. InternationalJournal of Bioelectromagnetism, 1(1):75–86, 1999.

[12] MATLAB R2010b. The MathWorks Inc.

[13] A. Shmilovici. Support vector machines. Data Mining and Knowledge Discovery Handbook,pages 257–276, 2005.

[14] A.J. Smola and B. Sch”olkopf. A tutorial on support vector regression. Statistics and computing, 14(3):199–222,2004.

[15] C. J. Stok. The inverse problem in EEG and MEG with application to visual evoked responses.1986.

[16] M. Sun. An efficient algorithm for computing multishell spherical volume conductor models ineeg dipole source localization. Biomedical Engineering, IEEE Transactions on, 44(12):1243–1252, 1997.

[17] R. Van Uitert, C. Johnson, and L. Zhukov. Influence of head tissue conductivity in forwardand inverse magnetoencephalographic simulations using realistic head models. BiomedicalEngineering, IEEE Transactions on, 51(12):2129–2137, 2004.

[18] D. Yao. Electric potential produced by a dipole in a homogeneous conducting sphere. Biomed-ical Engineering, IEEE Transactions on, 47(7):964–966, 2000.

28