Dear Stephen,
As I use Brainstorm in a script manner it was easy to calculate MNE solutions using the magnetometers or the gradiometers
Sorry for the indiscretion, but is there any particular reason why you are scripting calls to Brainstorm functions? It is something useful when you process tens of subjects and hundreds of files, but it doesn't seem to be your case.
What differentiates Brainstorm from the other MEG/EEG toolboxes is most of all its rich interface: easy import/epoching, quick visualization, database manager, graphic batch processing.
If your aim is to build your own processes and own figures using only a few functions from a "toolbox" for file reading and forward models, you should consider using FieldTrip, which offers more advanced command-line features.
If you want to use Brainstorm and write your own scripts anyway, please at least do not write your own calls to bst_headmodeler and bst_sourceimaging. Brainstorm changed a lot between versions 2 and 3, and now most of the functions cannot work without the support of the database.
Scripting with Brainstorm must involve database management, such as: manual creation of protocols, subjects and conditions, clean MEG imports...
Some examples of scripts are available in folder brainstorm3/toolbox/script.
Each script corresponds to a tutorial: http://neuroimage.usc.edu/brainstorm/Tutorials
It would be nice to have brainstorm doing that from the beginning (to have Channels with weights [1 -1] and [1].
Please use import_channels or import_data to read the channels positions. Brainstorm forward models are supposed to work not only with one point per sensor, but with several integration points for each coil (defined in brainstorm3/toolbox/io/private/coildef.dat).
Your channel file should look like the attached example (Neuromag 306):
In the comments in bst_headmodeler there is some comment on that and says one should use .ChanLocs = [1:3,:] for gradiometers and [4:6,NaN] for magnetometers. I do not understand this? Can somebody explain please?
I am sorry, many of the comments in bst_headmodeler and bst_sourceimaging are outdated. The direct use of those functions is not documented yet. If you want to use them by your own you will have some reverse engineering to do: place a breakpoint at the beginning of the function, start computation from the GUI, and look at what the OPTIONS structure look like.
My final advice would be: read the tutorials, try to use the GUI, read the script examples, and come back to us if you have any question or request.
Sincerely,
Francois