Created
June 14, 2024 15:20
-
-
Save rcassani/f484ea2f1c1a3ba515fce5fc78410260 to your computer and use it in GitHub Desktop.
[Brainstorm] Export frequency bands as CSV files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Example of how to export individual frequency bands (from a time-frequency file) as CSV files in Brainstorm | |
% See: https://neuroimage.usc.edu/forums/t/46834 | |
% Raymundo Cassani, 2024 | |
%% Paramters | |
% Input files | |
sFiles = {'Subject01/S01_AEF_20131218_01_600Hz_notch/timefreq_hilbert_240614_1018.mat'}; | |
% Folder to save CSV files | |
ExportDir = '/home/rcassani/Desktop/'; | |
% Brainstorm frequency bands | |
FreqBands = bst_get('DefaultFreqBands'); | |
%% Pipeline | |
% Start a new report | |
bst_report('Start', sFiles); | |
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 | |
% 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'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment