Skip to content

Sparse Source Reconstruction

Finn Årup Nielsen edited this page Jul 15, 2015 · 25 revisions

Introduction

SparseReconstruction is a class that contains a set of methods for solving the EEG inverse problem using structured sparsity techniques based on the Fast Iterative Shrinkage Thresholding Algorithm (FISTA). In the following, we will use the following notation:

  • Y: EEG measurements matrix
  • S: sources matrix
  • A: Lead-Field matrix
  • L: Lipschitz constant for the gradient of the reconstruction error.

Constructor

SparseReconstruction(QObject *parent = 0, int channels_input=14, int sources_input=1028, int sourcesReconstructionDelta_input=8, int numDatosTrain_input = 8, int numDatosTest_input = 6)

Input arguments:

  • channels_input: Number of rows of the matrix Y
  • sources_input= Number of rows of the matrix S
  • sourcesReconstructionDelta_input: Number of columns of the matrix Y
  • numDatosTrain_input: To be used in future versions of the cross-validation function
  • numDatosTest_input: To be used in future versions of the cross-validation function

Example of usage:

int channels = 14;

int sources = 1028;

int sourcesReconstructionDelta = 8;

int numDatosTrain = 8;

int numDatosTest = 6;

SparseReconstruction *sparseReconstruction;

sparseReconstruction = new SparseReconstruction(
    0,channels,sources,sourcesReconstructionDelta,numDatosTrain, numDatosTest);

Note: At the moment, the lead-field matrix (A) and the Lipschitz constant for the gradient of the reconstruction error (L) are loaded internally inside the constructor.

DTU::DtuArray2D<double> *A_normalized;

double L;

loadData("/sdcard/smartphonebrainscanner2_data/newforwardmodel_spheres_reduced_1028.txt",A_normalized);

loadData("/sdcard/smartphonebrainscanner2_data/L_forwardmodel_sphere_reduced_1028.txt",&L);

Methods

  • void doRec(DTU::DtuArray2D *Y_input, DTU::DtuArray2D *S_output, int *isSourceReconstructionReady, vector &lambdas, double *error_tol)

Input arguments:

  • Y_input: EEG measurements matrix
  • S_output: Matrix estimated by the algorithm
  • isSourceReconstructionReady: Flag that indicates if the reconstruction has finished
  • lambdas: Vector that contains all the regularization parameters to be used in the cross-validation
  • error_tol:

This is the main method of the SparseReconstrucion class. It receives an EEG measurements matrix (Y_input), which it is preprocessed (subtract the row-mean). It then performs cross-validation to select the best regularization parameter, and finally, it returns the reconstructed sources matrix S_output.

Example of usage:

DTU::DtuArray2D<double> *Y = new DTU::DtuArray2D<double>(channels, sourcesReconstructionDelta);//channel matrix

DTU::DtuArray2D<double> *S = new DTU::DtuArray2D<double>(sources, sourcesReconstructionDelta);//sources matrix

vector<double> lambdas;

lambdas = vector<double>(5);

lambdas[0]=0.01;

lambdas[1]=0.1;

lambdas[2]=1;

lambdas[3]=10;

lambdas[4]=100;

int isSourceReconstructionReady = 0;

double error_tol = 0.0001;

sparseReconstruction->doRec(Y,S,&isSourceReconstructionReady,lambdas, &error_tol);