Exporting scouts to MATLAB by scripting

Hello BST Team,
I have around 40 subjects resting state MEG data. I want to examine the resting state functional networks in different frequency bands. For this I followed the scripting tutorial and scripted most of what I want.

  1. However, I am unable to export scouts to MATLAB using script. I tried to search in forums but couldn't find good answers to this question. The reason I am requesting you is that, for every subject, every frequency band I can calculate functional connectivity (fc) using scouts and save scouts and fc matrix to hard disk rather than leaving it on RAM until all the patients get executed in pipeline.

  2. As I wanted to source reconstruct the time series for every frequency band, do I need to build the head model fro every frequency band. I followed this pipeline
    step 1) band pass the signal in desired freq band (say delta)
    step 2) build overlapping spheres head model
    step 3) compute nosie cov matrix
    step 4) compute sources
    step 5) extract scouts
    Again repeat from step 1 to step 5 in different frequency band (theta, alpha, beta, gamma)

Any help is much appreciated. I will be more than happy to give you my pipeline if you ask for it.
Regards,
Paddu.

Hello

However, I am unable to export scouts to MATLAB using script.. for every subject, every frequency band I can calculate functional connectivity (fc) using scouts and save scouts and fc matrix to hard disk rather than leaving it on RAM until all the patients get executed in pipeline.

I'm not sure I understand what processes you are chaining, and and which level you would need to export something, and you would like to have this something stored.
In general, use the process "Export scouts time series" to save the scouts signals to the database. Then you can runing most of the processes in the resulting "matrix" files.
If you need more help, please describe most specifically what you are doing, and what you try to do but don't manage to.

As I wanted to source reconstruct the time series for every frequency band, do I need to build the head model fro every frequency band . I followed this pipeline

This is probably the cleanest way to proceed, but relatively heavy.
Another solution, which would give different (but hopefully similar) results, is to compute the sources on the broadband signal, extract the scouts time series, and only then filter the time series in the frequency bands of interest.

Thanks for the response.

If you need more help, please describe most specifically what you are doing, and what you try to do but don't manage to.

As mentioned in the Question 2, I would like to extract the scout time series in every frequency sub-band and I am successfully doing it by using "process_extract_scout". However, I have to manually EXPORT these scouts to MATLAB's workspace using following procedure : Right click on scouts file in BST > File > Export to MATLAB. As I have many subjects (within each subject 5 frequency bands), I have to repeat the same procedure of exporting scouts to MATLAB which is tedious job. Is there a way I can program this so that BST exports it to MATLAB workspace?

This is probably the cleanest way to proceed, but relatively heavy.

I understand it is heavy, however, I ran this procedure using BST scripting on Cluster. It worked perfectly fine, it was bit slower to the end as it had many scouts (5 per patient) all of which are being available only on BST GUI but not in MATLAB workspace (in this case I could have stored them to hard-drive ).

This menu File > Export to MATLAB does one very simple thing: it uses the Matlab function "load" and copies the contents of the variable in the base workspace.

From a script, you just have to use the function load() to load the contents of the "matrix" files into a variable. You have the list of files in output of the call to process_extract_scout. You can use the function file_fullpath to convert a relative path to an absolute path.

% Process: Scouts time series: 1
sFiles = bst_process('CallProcess', 'process_extract_scout', sFiles, [], ...
    'timewindow',     [-0.1, 0.5], ...
    'scouts',         {'User scouts', {'1'}}, ...
    'scoutfunc',      1, ...  % Mean
    'isflip',         1, ...
    'isnorm',         0, ...
    'concatenate',    1, ...
    'save',           1, ...
    'addrowcomment',  1, ...
    'addfilecomment', 1);

ScoutMat = load(file_fullpath(sFiles(1).FileName));

Many thanks, Francois.