Changes in brainstorm functions that doesn't work when scripting

Hello,

I'm trying to have access to information that Brainstorm doesn't return in its result files when doing source localization with dipole modelling. That's why I changed Brainstorm code and I saved in matlab files what I needed that is computed during the process. And now, when I do source localization from the brainstorm interface the files are indeed created.

But then, I wanted to automatize the process to do it on many files so I script the different steps with Generate .m script in Brainstorm. And when I run the program the files aren't saved anymore. Is the function bst_process from the script not calling the same process as the Brainstorm interface?

Thanks',
Aurore

Is the function bst_process from the script not calling the same process as the Brainstorm interface?

It depends for what.
If you want some help from us, please try to be more specific.

If you're already at a level of editing the inverse functions, you are probably beyond the scope of this user forum.
You would probably much more efficient by learning how to use the Matlab debugger: click on the line number to set up a breakpoint at the beginning of the function you edited, run the computation either from the interface or from a script, then when the debugger stops the execution, you can start inspecting the contents of the variables, and execute the code line by line to see where the execution goes and why.
This would be the most direct way for you to understand why your files are not created.
If this does not feel intuitive to you, start by watching a tutorial introducing the Matlab debugger.

Thank you for your answer, I didn't think about using matlab debugger.

In fact we found the issue. It was because we didn't reload the database at each iteration of our for loop. For memory issue I was deleting some files at the end of each iteration. The code when running wasn't showing any error but no window showing the process opened. So I think that because of the mismatch between the files that really exist and those that Brainstorm consider in its database, the program wasn't running well.

Hello,

I have another question regarding the same matter. I generated this script with Brainstorm interface:


And when I run it these messages appear in Matlab:

But when I did the exact same steps but with the interface it's not the same messages that appear, and it has consequences on the SNR and a small difference with the localization computed. I don't understand why it doesn't use the diagonal components from the noise covariance matrix. When I launch the same thing from Brainstorm I have these messages:

Is there an option that I have to change to obtain the same results with both the interface and the script?

I can't reproduce this behavior. My guess is that you selected different options and/or different input files in your script and from the interface.
If you are not sure, put a breakpoint at the beginning of the function bst_inverse_linear_2018.m and explore the input variables. If there is any mismatch between what you expect and what you observe, please let me know.

If you need further help from us, or if you think there is some bug in the way the options are passed through the different layers of the the application, we'd need you to post further debugging information here:

  • A full minimal script to reproduce the behavior: processing only one file, and with one process, and including the definition of the input list sFiles.
  • The screen capture of the database explorer, with the file on which you right-click to compute the sources highlighted, and with the blue tooltip label with the file path displayed.
  • The screen capture of the "Compute sources" option window, when executed from the GUI.

I found my error, thanks!
It was the output option for the noise covariance matrix that I didn't check.