"Generate .m script" to run wMEM

Hello all,
I have a problem when trying to run wMEM via script:
if I generate the matlab script (.m) to run wMEM, I get an error (pasting it below along with screenshot).
If I run the same exact pipeline via the GUI, it works; when I generate the .m script and run it instead, I get this error (despite I do not change anything to the code automatically generated by Brainstorm). This is quite odd to me. Could you please help me figure out what's the issue? (I need this to automatize the computation for different epochs and subjects)
Thank you very much in advance!
Eleonora

ERROR:
Error: File: script_new.m Line: 41 Column: 69
Nesting of {, [, and ( cannot exceed a depth of 32.

image

I fixed a bug in the generation of the Matlab scripts including cells in substructures:

Please update Brainstorm and try again.

@aliobaibk
Are you really expecting to copy the entire channel file in "BaselineChannels"?
This seems like data that should be passed as a reference to the channel file, not loaded first and passed in the command line.

Thanks a lot @Francois! It works. This will make things much easier!

I have an additional question/doubt; it's about the baseline that is used when computing the wMEM. We have a set of imported epochs named "baseline" that we want to use as such when computing the wMEM (see screenshot below); so, we select the option "default (baseline dataset)" when running it.
My concern is whether this implies that all the baseline epochs are used or only one of them.
I have this concern because, if I look at the wMEM output exported in Matlab (see 2nd screenshot below), I see that for Baseline it is only reported one epoch (#1). Am I misinterpreting this? If not, is there a way to use all the epochs?
Thanks again!

20 Epochs imported for baseline:
image

MEMoptions:
image

Baseline history:
image

Hello @eletamilia,

Thanks for reporting these issues to us.
When multiple recordings contain "baseline" in their name (i.e. Comment field), this would trigger a warning from the BEst panel as follows:

'MEM : more than one baseline found in workspace.'
'MEM : first file selected'

In your case, this means that a single trial, from the list of 20, is selected for further processing.

Did you want the noise covariance to be estimated from all baseline trials?
If yes, you would need to concatenate all trials (and make sure that only the concatenated file has the sub-string "baseline" in its name).
Note: the next release of BEst will give you the flexibility of automatically loading a baseline file from any sub-string (not just "baseline").

@Francois,
Yes I agree, file paths should be given from the command line in such scenario, and the functions of the toolbox should them load as needed.
I am adding this change.

@aliobaibk hanks for the clarification!
Unfortunately, regarding my previous question/problem with the .m script, I still have issues actually:
it looks like the fact that the script is extremely long (probably because the channel file is copied in it as Francois mentioned (?)), makes Matlab Editor crash when trying to save it or run it from some machines.
Any idea or help on how to fix this?
image

I still have issues actually: it looks like the fact that the script is extremely long

Maybe there is another bug in the .m script generator but I can't reproduce your error.
Can you please post screen captures showing:

  1. the files you have in input (Brainstorm figure showing the files in the database explorer + selected in the Process1 tab) and
  2. the options used for the MEM process?

Thanks

Hello @eletamilia, @Francois,

BEst has been updated and the panel no longer returns a preloaded baseline file.
This may help too.

To update BEst, the easiest way is to install from the Brainstorm plugin manager.

Thanks for the reply; however, I am still having the same issue. I cannot generate a .m script, or rather: 1) after I click on generate .m code, it takes several minutes to display the pop-up window to save the code (like 10 minutes!)
2) once I save it, matlab editor does not allow to open it (java errors)

@Francois I am copying below the screenshots. Also it could be helpful to know that I am working on hd-eeg data (256 channels); since the m. code includes all the list of channels and their location, this may be relevant.
THANKS!

Input file
image

Options (wMEM)
image

Hello @eletamilia,
Your screenshots show that you are still using an older version of BEst, once you update it your issue will be gone.

mmhh thanks for letting me know. Actaully, I thought I updated it: a pop-up window came up asking me to update Best and I said yes, so I thought I was using the updated version. Could you recommend the best way to install the updated version?
Thanks!

Could you recommend the best way to install the updated version?

First update Brainstorm: menu Update > Update Brainstorm
Then update the plugin: menu Plugins > Inverse > brainentropy > Update.