ICA projectors & scripting

Hello,

to speed-up my analysis process, I am trying to perform some steps automatically with scripting.
I am now at a point where I would basically like to generate some files from on the ICA projectors, to help me select the components to remove.

Following instructions found on this forum, what I did manually, recording by recording, was:

  • To save IC topoplots: select active projectors > select all projectors > topoplot > Save file.
  • To get the PSDs and ERPs of the ICs: select active projectors > select all projectors > time series > Edit montage > Duplicate montage > Rename montage > Save. Then Import in database > Standardize > Apply montage. And finally compute PSDs and ERPs normally from the file I got from the "Apply montage" process.

Now, since I have a lot of recordings, I would like to do this with a script. I have started to think about it and thought about using the channel file, where the projectors information are stored. However, I still haven't found a way to:

  • display/save the ICs topoplots like I do manually. It seems the function "view_topography" is not meant to display ICs topoplots.
  • create an imported file containing the ICs time series from which I could compute PSDs and ERPs. The only way I thought about is by applying the projectors to the data with matrix computation directly in the script, then import this new data in the database in some way.

Would you have a solution on how to perform those steps?

Thank you in advance for your help.

Best,

François

display/save the ICs topoplots like I do manually. It seems the function "view_topography" is not meant to display ICs topoplots.

Indeed, there is no simple function call to do this, and it is not trivial to do.
Displaying the IC topography was not intended to be a scriptable feature, but only part of the interactive exploration of the data.
If you want to code something for your specific objectives, you can maybe find some inspiration in the function that displays the spatial components:

create an imported file containing the ICs time series from which I could compute PSDs and ERPs. The only way I thought about is by applying the projectors to the data with matrix computation directly in the script, then import this new data in the database in some way.

The function linked above also creates the appropriate montages for displaying the time series of the IC.
You should be able to use the process "Apply montage" to save the IC as new data files that you can process. Is there anything that doesn't work here?

1 Like

Hello François,

thank you for your reply and please excuse me for the delayed answer, I've been working on something else and then away for some time.

I'm trying to understand how the function PlotComponents() works. To do so, I've so far called manually (from command) the function panel_ssp_selection('OpenRaw') which opens the projectors selection panel.
However, I am then having issues trying to call the function PlotComponents().

When calling it manually, I get the error that the function does not exist, even though I called the function panel_ssp_selection('OpenRaw') first. I then tried to run the whole script first hoping it would create the functions implemented in it, and then called the function PlotComponents() function, but I got the same error saying that the function does not exist.

I know I am missing something, I guess in the way the function PlotComponents() is normally called, but I don't know what exactly.

Could you please give me some precisions about it ?

Thank you in advance.

Best,

François

PlotComponents() is a "subfunction" of panel_ssp_selection.m. In Matlab, the default behavior is that you from the command line or a script, you can only call a function that has the same name as the file name it is saved in. Therefore, Matlab will never be able to file a function "PlotComponents" defined inside the file panel_ssp_selection.m, it is only available from the functions defined within panel_ssp_selection.m.

In Brainstorm, all panels and process functions include a call to "macro_method" at the beginning, which allow to call these local functions from the command line with the syntax panel_xxx('LocalFunction', arg1, arg2...).

If you want to call PlotComponents() from your scripts, you need to use the syntax:
panel_ssp_selection('PlotComponents', UseSmoothing, isPlotTopo, isPlotTs);

1 Like

Hello François,

ok that works well, thank you very much for your clear answer and help overall!

Best,

François