Brainstrom skips first epoch in script

Hello dear expert,

so I want to split continuous recording into 7 epochs for numerous subjects and then compute PSD and various connectivity matrices. It seems something's wrong because it keeps skipping the first epoch. Continuous file is 300 sec long and after filtering and for the sake of epoch length in whole seconds I've made 7*40 epochs. And they start from 8 sec to 288 sec. After making them uniform (which BS asks me to do if I want to compute PSD and stuff on them), it refuses to make an operation on first epoch. sEpochs is 1x7 Struct and sEpochsUniform is 1x6 struct. It then follows that PSD and stuff is not computed for the first epoch. It should be noted that when I do the exact same process in BS UI, it works well.

Please, what is wrong?

Thank you very much.

Here's my code of how I treat those epochs.

% Process: Import MEG/EEG: Time
        sEpochs = bst_process('CallProcess', 'process_import_data_time', sFile, [], ...
            'subjectname', SubjectNames{iSubject}, ...
            'condition',     '', ...
            'timewindow',    [8, 288], ...
            'split',         40, ...
            'ignoreshort',   0, ...
            'usectfcomp',    1, ...
            'usessp',        1, ...
            'freq',          [], ...
            'baseline',      [0, 299.998], ...
            'blsensortypes', '');

 % Process: Uniform epoch time
  sEpochsUniform = bst_process('CallProcess', 'process_stdtime', sEpochs, [], ...
       'method',    'spline', ...  % spline
       'overwrite', 1);

Hi @kubicra3, thanks for reaching out.
It seems there is a problem with the process description and semantics. Let me expand.

In the GUI, the Uniform epoch time process indicates:

Apply the time vector of the first file to all the other files

So, the first file is not modified at all, it is used as reference, so, this is what you experience in the scripting. The input is 7 files, but the output is all the modified files (epoch2 to epoch 7).

This is exactly what also happens in the GUI. But it is not easy to see if the Overwrite option is checked, because only the time vector of the epoch2 to epoch7 is update, not their file name, so they seem to be together with epoch1. You can appreciate that only 6 epochs are returned in the GUI, if you add another process, e.g., File > Add tag, so the tag will be applied to the files epoch2 to epoch7.

So, in your code, after running both processes, just add back the first epoch:

sEpochsUniform = [sEpochs(1); sEpochsUniform];

Thank you very much Raymundo.

Take care!