Exporting PSD files as one combined CSV file

Hello
I am using the script below to extract PSD frequency bands, and I am having trouble getting them to save in one total CSV file rather than one CSV file per PSD file. Do you have any advice on how I could go about adding that to this script?

for iFile = 1 : length(sFiles)
    sBandFiles = [];

    for iFreqBand = 1 : size(FreqBands, 1)
        % Process: Extract values: [all] 2-4Hz
        sFileBand = bst_process('CallProcess', 'process_extract_values', sFiles(iFile), [], ...
            'timewindow', [], ...
            'freqrange',  str2num(FreqBands{iFreqBand, 2}), ...
            'rows',       '', ...
            'isabs',      0, ...
            'avgtime',    0, ...
            'avgrow',     0, ...
            'avgfreq',    0, ...
            'matchrows',  0, ...
            'dim',        1, ...  % Concatenate signals (dimension 1)
            'Comment',    '');

        % Process: Add tag: delta
        sFileBand = bst_process('CallProcess', 'process_add_tag', sFileBand, [], ...
            'tag',            FreqBands{iFreqBand, 1}, ...
            'output',         'name_path');  % Add to file name and file path

        % Concatenate band files
        sBandFiles = [sBandFiles, sFileBand];
    end

    % Process: Export to file: Timefreq
    bst_process('CallProcess', 'process_export_file', sBandFiles, [], ...
        'exporttimefreq', {ExportDir, 'ASCII-CSV-HDR'});

    % Process: Delete selected files
    bst_process('CallProcess', 'process_delete', sBandFiles, [], ...
        'target', 1);  % Delete selected files
end

Hello @mlabax,

Can you provide a bit more on context?

  1. What as user for the Frequency definition in the input PSD file?

  2. Are the frequency bands to export contiguous?
    If so, you may want to export them all together using just the lowerst freq and the highest freq
    If not, there is no function in Brainstorm to concatenate in the frequency domain. Doing so, would lead to confusion results as the frequency vector will not be continuous

  3. What is the expected outcome?