Setting Radius and Headcenter while while writing a script a call to bst_headmodeler

@Raymundo.Cassani @tmedani @John_Mosher

I am writing a script which calls bst_headmodeler. I would like to specify parameters to meg_sphere, such as Center and Radius. Could you help me? Thanks a lot for taking the time!
My current call is:

sFiles = bst_process('CallProcess', 'process_headmodel', [], [], ...
        'Comment',     '', ...
        'sourcespace', 1, ...  % Surface 
        'meg',         1, ...  % Single sphere
        'channelfile', meg_channel_fname);

Hey Yash,

I think this parameter can't be set from the script. Since it's a single sphere, Brainstorm will estimate the best fit for the sphere based on the available anatomy of the subject (inner skull for the meg, and scalp for eeg- or used defined-), then the radii and center are fixed.
you can check this on the panel_headmodel function at the line 467 with the function GetBfsEstimations.
if you run from the GUI, brainstorm will also ask you to select the best-fitting sphere.

If you want to compute your own sphere with center and radii, then you need to build a custom script and not from the best processes, you can refer to the functions "bst_os" , "bst_meg_sph" within the function "bst_headmodeler".
Once computed you can populate the Gain matrix with the desired LF.

Hi Tak,
Thanks a lot for the quick response! I understand what you are saying.
Also, could I temporarily change the default options ("DEF_OPTIONS") in "bst_headmodeler" to hard-code a sphere center and a radius?


There is not need of modifying the the default options ("DEF_OPTIONS") in "bst_headmodeler".
Just proving the fields HeadCenter and Radii to the sMethod struct when calling process_headmodel('ComputeHeadModel', ...) would override the default ones. There are at least two way to do so in your script:

  1. Create your own process. Copy of the process process_headmodel where you add the sphere center and radious as inputs. Then read them in the Run function of the process and add them to sMethod in the fields HeadCenter and Radii respectively.

  2. Place a breakpoint at the call of panel_headmodel('ComputeHeadModel', iChanStudies, sMethod); (line 210) in process_headmodel, and check the fields and values that are already set. From your script just make the same call but adding the HeadCenter and Radii respectively to sMethod

Hi Raymundo,
Your input was quite clear and useful. I used the second method to programmatically call panel_headmodel. Now, I am able to pass the parameters to bst_headmodeler and bst_meg_sp scripts.

Thanks a lot for solving the problem!

1 Like