Calculate Gain from script

Hello,
I am reaching out for clarification regarding the gain calculation using OpenMG for 15,002 vertices. It appears that the resultant gain, based on the direction of X, Y, and Z, equates 64* 45,006(if channels are 64). However, with the current code([sHeadModel] = bst_get('HeadModelForStudy', iStudy);
bst_call(@export_matlab, {char(sHeadModel.FileName)},'model');
Gain=model.Gain(channelselect,:);
GridLoc=model.GridLoc;
GridOrient=model.GridOrient;

Gain = bst_gain_orient(Gain,GridOrient);
), we seem to be obtaining gain based on 64*15002.

Could you please provide an explanation regarding this code?

Thank you for your assistance.

The result of openMEEG for 15002 vertices gives the gain matrices for all three orthogonal vector directions of each source point. Thus 64*(150002*3).

Using bst_gain_orient you restrict the Gain matrix to one orientation per source point, thus collapsing the three dimensions to one value.

2 Likes

Which direction does this code consider in the brainstorm? Does it take into account the resultant of the three directions?

According to the brainstorm tutorial on head modeling (https://neuroimage.usc.edu/brainstorm/Tutorials/HeadModel?highlight=(Useful)|(functions))

GridOrient: [Nvertices x 3], directions of the normal to the surface for each vertex point (copy of the 'VertNormals' matrix of the cortex surface). Empty in the case of a volume head model.

The code you are using projects the lead field vectors on the normal direction of the surface, which is a common simplification.

2 Likes

Thank you very much.

Thank you @SBeumer

I am currently working with a matrix of dimensions 6445006 and wish to convert it to a size of 6415002 in MATLAB, utilizing the GridOrient value without using Brainstorm. Could you please advise on the appropriate command in MATLAB to achieve this transformation?

Thank you for your assistance.

You can check and use this function: Gain = bst_gain_orient(Gain,GridOrient)

Thank you very much.

1 Like