Skip to content

[in progress] GLM implementation

Thomas Vincent edited this page Jun 29, 2018 · 11 revisions

This page is aimed to describe our specific implementation of the GLM in Brainstorm.

Processes

process_nst_compute_design_matrix

This process return the design matrix specification from the events, convolved with the canonical HRF. Inputs :

  • Hb data
  • Basis function ( Hrf, Gamma ...)
  • Trend function ( Constant )

Output :

  • Design matrix

TV Let's use the matrixmat data type of brainstorm for this, see toolbox/io/import_matrix.m

to test it, create a random matrix: my_mat = randn(10, 100);

Warning: convention is nb vectors x nb samples (time is in the 2nd axis whereas the convention of SPM is 1st axis).

Then right-click on a functional data folder. File > Import Data Matrix and select my_mat now you have an object "Imported matrix" that you can view as an image or signals, use the embedded features of brainstorm. So we don't have to code our own display ;)

Looking at the code, there are fields to indicate signal labels that we can set. They will be our regressor names for the design matrix.

process_nst_compute_glm

This process aimed to determine the weight for the B matrix. Such as Y = XB +e. This process also return the error e that is made when using this model.

Inputs :

  • Hb data
  • Design matrix or a design_matrix_mat structure.

Output :

  • B and the standard error e or a ChannelStats structure

TV

Let's just output the results (effect maps and residuals) for now.

the data structure of Huppert is useful for them for prototyping purpose but it contains too many redundant data. Let's try to have only one instance of each piece of data at a time.

Then we have to add a process to compute stats from the GLM fitting.

Data Structure

Our first process works by saving our data into a 'matrixmat' structure but for a better implementation we propose to implement new data structure in order to hold GLM parameters and data. having our own data structure will also let us define our own visualisation process ( eg visualisation of the design matrix, or the B parameters )

TV

matrixmat is the way to go for now I think, let's try to not add new data structures.

Let's just stick to outputs that are using brainstorm objects and not save GLM parameters / data to avoid duplication. That said, we can store any relevant info in the Comment field of the Output.

The B effects will be visualized as a functional map, the same way we visualize raw NIRS data.

design_matrix_mat :

This structure will hold information about the design matrix such as :

  • Regressors name
  • Basis function
  • Trend function
  • X : the design matrix

ChannelStats

Similarly to Huppert's toolbox ( see ChannelStats ), ChannelStats holds subject and group level channel statistics info such as :

  • description - description of data (e.g. filename)

  • variables - a table containing w/ source, detector, type, cond for each regression coefficient

  • beta - regression coefficients

  • covb - covariance of beta

  • dfe - degrees of freedom

  • e - standard error

  • cove - covariance of the standard error

  • demographics - Dictionary containing demographics info (e.g. demographics('age') returns 28)

  • conditions - (dependent) list of stim conditions

  • tstat - (dependent) t-stats of beta

  • p - (dependent) p-values of beta

  • q - (dependent) q-values of beta (false discovery rate)