Compute sources iteratively

Hello Brainstorm,

I am newbie in Brainstorm. I am analyzing EEG data from N subjects in 2 different states and I should calculate sources for each case. The main steps are:

  1. upload data file (.edf) and choose the anatomy (default anatomy should be perfect now)
  2. upload channel location file (e.g. one that is already in Brainstorm database 10-20 setting)
  3. compute the head model
  4. calculate the noise covariance matrix
  5. compute sources estimation with a specific method (e.g. sLORETA)
  6. save the matrix
    I have noticed that at the end of every Tutorial (and I should congratulate because they are really something!) there are the main functions related to the topic. Moreover, Tutorial-28 is about Matlab script and it seems to fit the bill. I have tried with just one subject, yet the following script has some issues:

script_new.m (3.1 KB)

In particular this is the error:

Dot indexing is not supported for variables of this type.

Error in bst_report>Save (line 764)
ProtocolName = file_standardize(GlobalData.ProcessReports.Reports{iStart,4}.Comment);

Error in bst_report (line 63)
eval(macro_method);

Error in script_new (line 87)
ReportFile = bst_report('Save', sFiles);

Do you have any idea to fix the problem? I am sure I am missing something.
Thankyou very much for your time.

DM

Hi @dariomilea, welcome to Brainstorm.

Regarding the reported error.
Did you try to run the script with a new installation of Brainstorm before having at least one Protocol?

Regarding the script. The shared script does not do what you described in the post, there are some important problems with it, here the major:

  • Either the Procotol is already created, or the script should create a new Protocol
  • Similar with the Subject, either is already created in the protocol, or the script should create it
  1. For linking the raw data to a Subject, the needed process is: process_import_data_raw()

  2. If you want to use the 10-20 system locations already in Brainstorm use the process_channel_addloc() with the channelfile setting empty and the usedefault setting indicating which default channel locations.

  3. For EEG, the recomended head model methods is OpenMEEG BEM
    https://neuroimage.usc.edu/brainstorm/Tutorials/HeadModel#Forward_model

  4. Looks good

  5. For computing the sources, use the most recent process process_inverse_2018()

  6. There is nothing in the script to do this.

Before scripting in Brainstorm, it is recommended to use the GUI to perform the pipeline (at least for one Subject) this will help you to understand what are the inputs and parameters for the processes, as well as the outputs. This is very important when debugging your codes.

As you know it is possible to create a script directly from the Pipeline editor. However, you need to be sure that the Pipeline is working.

Also, you can find the script to run all the Get started tutorials in the link below. Note that in the same script folder there are scripts for other tutorials, these are a good reference on preparing scripts to be run in Brainstorm
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Final_scripts

Thank you very much for the answer, fast and thorough. I will try everything you suggest.
Unfortunately, talking about OpenMEEG BEM, every time I try to use this model it give me the error:

No download URL for mac64arm: openmeeg

Do you think it is a problem of my release or maybe should I download some packages?
I think that to save the final matrix there are some example in the Tutorials.
Thankyou very much.

Kind regards.

It just means that you are running in a Mac with Apple Silicon (not Intel) and OpenMEEG has not been released for this architecture. For the sake of writing the pipeline you can use the sphere model (it is faster to compute). Once the pipeline is correct you can decide on the method to compute the head model