Automatic Loading of sFiles for source based hilbert transform

Hello there!

I'd like to write some code to automatically load and save the sFiles for a source based whole brain hilbert transform. The files links are complex and I'm not sure the ideal way to get them for each subject/condition/tag combination in an efficient manner.

An example of a subject/condition/tag sFiles list is:

sFiles = {...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial001.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial002.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial003.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial004.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial005.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial006.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial007.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial010.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial011.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial012.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial013.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial014.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial017.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial018.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial019.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial020.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial021.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial022.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial023.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial025.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial026.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial027.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial028.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial029.mat', ...
    'link|JM001/BR30/results_PNAI_MEG_KERNEL_240718_1446.mat|JM001/BR30/data_R1_trial030.mat'};

Is thera command I can use to automatically get this information or must I manually go through each subject/condition/tag combination and generate a matlab script in order to get this?

You can get all the TimeFreq files that have as parent a given Source file using it FileName (even if it is a link) with this:

[sStudy, iStudy, iTimefreq] = bst_get('TimefreqForFile', 'link|..... .mat');
sTimfreq = sStudy.Timefreq(iTimefreq);

After this you may want to filter those TimeFreq files by their FileName to ensure only the desired Hilbert Transform files are kept, they will have the name timefreq_hilber_YYMMDD_HHMM.mat

Check these links for more info about the Brainstorm database for files and methods to access it: