Extract scout times series folder different times

Dear community,
I intend to obtain the sLORETA scout times series of a series of files taht belong to the same folder with different time ranges. So I have one EEG and I import to database into blocks of 100ms. I want to obtain the amount of scouts series I have in that EEG. I tried with the GUI I'm afraid that's not possible. If I could try with code. I tried but I don't know how to folow from here brainstorm3/toolbox/process/functions/process_extract_scout.m at master · brainstorm-tools/brainstorm3 · GitHub

Thank you for all the help in advance!!

What you describe is possible in the GUI. If you already EEG signals imported in 100ms blocks, and have their sources with them, just place those source files (iconResult or iconResultLink ) in the Process1 tab, click on [Run] and select the process Extract > Scout time series.

When data is imported as blocks, they have the original time definition, so you need to either:

  1. Check the option All file in the process Extract > Scout time series, or

  2. Make uniform their time axis as shown in here:
    https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence#Epoching

If you want to write scripts to automate some task in Brainstorm, all the information you need is in this tutorial:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

may be the error was because I haven't made them uniform. That is interpolation rigth? Does it change anything in the data that could be relevant?

I have obtained the data. But I would like to see instead of one file with all the matrices. One matrix for each file of the EEG. So I have 600 EEG and I obtain 600 matrices not just one. Is it technically possible with brainstorm or do I need to rely on coding for that?

This is done with the process Standardize > Uniform epoch time
If it interpolates or it does not, it depends on the number of samples in your data:
image

You can drang-and-drop all your epoch files, and when using the Extract scout value , do not check the option Concatenate output in one unique matrix. Then you will have one matrix per epoch.

1 Like

thank you so much! I didn't check for that option so I didn't know.

I need to export the files to excel. When I try with all the matrices it give me this error.


That doesn't happen with CSV format. Also I cannot get it to save in different files. It concatenates them after having the matrices.

I think what happens is that I have 60 files with the same name the difference is in the tag which is not considered then different names for the files. Therefore it doesn't concatenate but it adds the information to the previous same name file.

What is a probable solution is to rename. Is there anyway to rename in having the same name with different indexes considered in the name. Like A1 A2 A3 etc.

That would be the perfect solution if there is anyway to do it automatically is better.

What is the result of running the following commands in Matlab's Command Window?

which('writecell', 'all')
which('writematrix', 'all')

Yes, when exporting multiple files with the process Export to file, the output file has the same name as the input file. If you multiple input files have the same file name, the output file is overwritten. To avoid you could try one if these options.

  1. Make a script that loops over your files names, then uses the process Export file for1 each of the files, by doing so, you can indicate the desired name for the output file for each file.

  2. Make a script that loops over your files names, then uses the process Add tag with one of the options that add to file path for each of the input files. Then you can run the process Export file, for all the files that were renamed.

1 Like

I did the first option

I get this code

% Start a new report
bst_report('Start', sFiles);

% Process: Scout time series: [157 scouts]
sFiles = bst_process('CallProcess', 'process_extract_scout', sFiles, [], ...
    'timewindow',     [], ...
    'scouts',         {'Volume 14961: AAL3', {'Left Amygdala', 'Left Angular gyrus', 'Left Anterior cingulate cortex-pregenual', 'Left Anterior cingulate cortex-subgenual', 'Left Anterior cingulate cortex-supracallosal', 'Left Anterior orbital gyrus', 'Left Calcarine fissure and surrounding cortex', 'Left Caudate nucleus', 'Left Crus I of cerebellar hemisphere', 'Left Crus II of cerebellar hemisphere', 'Left Cuneus', 'Left Fusiform gyrus', 'Left Gyrus rectus', 'Left Heschls gyrus', 'Left Hippocampus', 'Left IFG pars orbitalis', 'Left Inferior frontal gyrus-opercular part', 'Left Inferior frontal gyrus-triangular part', 'Left Inferior occipital gyrus', 'Left Inferior parietal gyrus-excluding supramarginal and angular gyri', 'Left Inferior temporal gyrus', 'Left Insula', 'Left Intralaminar', 'Left Lateral geniculate', 'Left Lateral orbital gyrus', 'Left Lateral posterior', 'Left Lenticular nucleus-Pallidum', 'Left Lenticular nucleus-Putamen', 'Left Lingual gyrus', 'Left Lobule III of cerebellar hemisphere', 'Left Lobule IV-V of cerebellar hemisphere', 'Left Lobule IX of cerebellar hemisphere', 'Left Lobule VI of cerebellar hemisphere', 'Left Lobule VIIB of cerebellar hemisphere', 'Left Lobule VIII of cerebellar hemisphere', 'Left Lobule X of cerebellar hemisphere', 'Left Medial Geniculate', 'Left Medial orbital gyrus', 'Left Mediodorsal lateral parvocellular', 'Left Mediodorsal medial magnocellular', 'Left Middle cingulate & paracingulate gyri', 'Left Middle frontal gyrus', 'Left Middle occipital gyrus', 'Left Middle temporal gyrus', 'Left Nucleus accumbens', 'Left Olfactory cortex', 'Left Paracentral lobule', 'Left Parahippocampal gyrus', 'Left Postcentral gyrus', 'Left Posterior cingulate gyrus', 'Left Posterior orbital gyrus', 'Left Precentral gyrus', 'Left Precuneus', 'Left Pulvinar anterior', 'Left Pulvinar inferior', 'Left Pulvinar lateral', 'Left Pulvinar medial', 'Left Red nucleus', 'Left Rolandic operculum', 'Left Substantia nigra-pars compacta', 'Left Substantia nigra-pars reticulata', 'Left Superior frontal gyrus-dorsolateral', 'Left Superior frontal gyrus-medial', 'Left Superior frontal gyrus-medial orbital', 'Left Superior occipital gyrus', 'Left Superior parietal gyrus', 'Left Superior temporal gyrus', 'Left Supplementary motor area', 'Left SupraMarginal gyrus', 'Left Temporal pole: middle temporal gyrus', 'Left Temporal pole: superior temporal gyrus', 'Left Ventral anterior', 'Left Ventral lateral', 'Left Ventral posterolateral', 'Left Ventral tegmental area', 'Lobule I-II of vermis', 'Lobule III of vermis', 'Lobule IV-V of vermis', 'Lobule IX of vermis', 'Lobule VI of vermis', 'Lobule VII of vermis', 'Lobule VIII of vermis', 'Lobule X of vermis', 'Right Amygdala', 'Right Angular gyrus', 'Right Anterior cingulate cortex-pregenual', 'Right Anterior cingulate cortex-subgenual', 'Right Anterior cingulate cortex-supracallosal', 'Right Anterior orbital gyrus', 'Right Calcarine fissure and surrounding cortex', 'Right Caudate nucleus', 'Right Crus I of cerebellar hemisphere', 'Right Crus II of cerebellar hemisphere', 'Right Cuneus', 'Right Fusiform gyrus', 'Right Gyrus rectus', 'Right Heschls gyrus', 'Right Hippocampus', 'Right IFG pars orbitalis', 'Right Inferior frontal gyrus-opercular part', 'Right Inferior frontal gyrus-triangular part', 'Right Inferior occipital gyrus', 'Right Inferior parietal gyrus-excluding supramarginal and angular gyri', 'Right Inferior temporal gyrus', 'Right Insula', 'Right Intralaminar', 'Right Lateral geniculate', 'Right Lateral orbital gyrus', 'Right Lateral posterior', 'Right Lenticular nucleus-Pallidum', 'Right Lenticular nucleus-Putamen', 'Right Lingual gyrus', 'Right Lobule III of cerebellar hemisphere', 'Right Lobule IV-V of cerebellar hemisphere', 'Right Lobule IX of cerebellar hemisphere', 'Right Lobule VI of cerebellar hemisphere', 'Right Lobule VIIB of cerebellar hemisphere', 'Right Lobule VIII of cerebellar hemisphere', 'Right Lobule X of cerebellar hemisphere', 'Right Medial orbital gyrus', 'Right Mediodorsal lateral parvocellular', 'Right Mediodorsal medial magnocellular', 'Right Middle cingulate & paracingulate gyri', 'Right Middle frontal gyrus', 'Right Middle occipital gyrus', 'Right Middle temporal gyrus', 'Right Nucleus accumbens', 'Right Olfactory cortex', 'Right Paracentral lobule', 'Right Parahippocampal gyrus', 'Right Postcentral gyrus', 'Right Posterior cingulate gyrus', 'Right Posterior orbital gyrus', 'Right Precentral gyrus', 'Right Precuneus', 'Right Pulvinar anterior', 'Right Pulvinar inferior', 'Right Pulvinar lateral', 'Right Pulvinar medial', 'Right Red nucleus', 'Right Rolandic operculum', 'Right Substantia nigra-pars compacta', 'Right Substantia nigra-pars reticulata', 'Right Superior frontal gyrus-dorsolateral', 'Right Superior frontal gyrus-medial', 'Right Superior frontal gyrus-medial orbital', 'Right Superior occipital gyrus', 'Right Superior parietal gyrus', 'Right Superior temporal gyrus', 'Right Supplementary motor area', 'Right SupraMarginal gyrus', 'Right Temporal pole: middle temporal gyrus', 'Right Temporal pole: superior temporal gyrus', 'Right Thalamus-Anteroventral Nucleus', 'Right Ventral anterior', 'Right Ventral lateral', 'Right Ventral posterolateral'}}, ...
    'flatten',        1, ...
    'scoutfunc',      'mean', ...  % Mean
    'pcaedit',        struct(...
         'Method',         'pca', ...
         'Baseline',       [0, 0.998], ...
         'DataTimeWindow', [0, 0.998], ...
         'RemoveDcOffset', 'file'), ...
    'isflip',         1, ...
    'isnorm',         0, ...
    'concatenate',    0, ...
    'save',           1, ...
    'addrowcomment',  1, ...
    'addfilecomment', []);

% Save and display report
ReportFile = bst_report('Save', sFiles);
bst_report('Open', ReportFile);
% bst_report('Export', ReportFile, ExportDir);
% bst_report('Email', ReportFile, username, to, subject, isFullReport);

% Delete temporary files
% gui_brainstorm('EmptyTempFolder');

Then I get this error.

>> extract_modified_2
Error: File: extract_modified_2.m Line: 69 Column: 8
Unsupported use of the '=' operator. To compare values for equality, use '=='. To specify name-value arguments,
check that name is a valid identifier with no surrounding quotes.

I don't understand because it had worked before. But it concatenated everything in one file and it was with PCA not Mean (scout time function).

EDIT: Edited for readability

You may want to check the indicated file extract_modified_2, at the specified line to check the error.
As the error message indicates, the seems to be a problem that the comparison of values is done with one = sign rather than two.

The script above indicates that mean is used as scout function:
'scoutfunc', 'mean', ... % Mean
If you want PCA, it needs to be indicated. You can do it in the GUI and the generate the script that correspond to the GUI options.

About concatenation, it is the same, the scrip above indicate that results will not be concatenated:
'concatenate', 0, ...

I had tried with both == or = it doesn't change much.

About Mean or PCA I know it is different and I can obtain them from the generate script.

The issue is that I obtained a file concatenated with PCA and then after that none Mean or PCA seemed to work.

I will try again and I will let you know my errors or results.