Scripting pipeline - process_select_tag doesnt give expected restults

I have two subfolders in every subject. I want to run a script in every subfolder but without getting files from these subfolders together. My scripts should be run in a folder " "S001_ISRASSR_20170220_01_resample" (I use the name of a subfolder as a condition name) with 160 files, and then start once again in a folder "S001_ISRASSR_20170220_02_resample"
but instead, it selects the data from these 2 folders together (And I have 318 files in the list ).
Also, it should remove from list files with "average" tag, but it doesn't do that (there are still files with "average" in the name).
It works with files with "notch" tag - the files are removed.

SubjectNames = {'Subject01_A', 'Subject01_B'};
% condition is used to pick and differentiate between resampled items
% subfolders contained within foldsers 
tag =  "FFT_Destrieux";
% Tag is used to easier iodentification of the resulting file 

search_term = '*ISRASSR*';

for iSubj = 1:size(SubjectNames) %SubjectNames = SubjectNamesGlobal
    FolderWithData = fullfile( DataDir, '/data/', SubjectNames{iSubj}, search_term)
    % construct path for the folder
    CheckIfExists(FolderWithData)
    S = dir(FolderWithData );
    conditions = {S(:).name};
    SubjectName= SubjectNames{iSubj}
    for condition = conditions
        %RunPSDonSubject(SubjectNames, tag, condition)
         sFiles = get_sFiles(SubjectName, tag, condition)
    end;
end;

function [] =  CheckIfExists(Path)
    if ~exist(Path, 'dir')
       'There is a problem with the folder'
    end

end

function sFiles = get_sFiles(SubjectName, tag, condition)
    bst_report('Start');
    % Reset colormaps
    bst_colormaps('RestoreDefaults', 'meg');
    condition = string(condition)
    sFiles = [];
    sFiles = bst_process('CallProcess', 'process_select_files_data', sFiles, [], ...
        'subjectname',   SubjectName, ...
        'condition',     condition, ...
        'tag',           'Sound_adj', ...
        'includebad',    0, ...
        'includeintra',  0, ...
        'includecommon', 0);

    % Process: Ignore file names with tag: notch
    sFiles = bst_process('CallProcess', 'process_select_tag', sFiles, [], ...
        'tag',    '*average*', ...
        'search', 2, ...  % Search the file names
        'select', 2);  % Ignore the files with the tag

    % Process: Ignore file names with tag: notch
    sFiles = bst_process('CallProcess', 'process_select_tag', sFiles, [], ...
        'tag',    'notch', ...
        'search', 2, ...  % Search the file names
        'select', 2);  % Ignore the files with the tag
end

sFiles.mat (28.6 KB)

None of the functions you are using here supports wildcars (*).
Your searches '*ISRASSR*' and '*average*' can't work. Check your error reports after execution.
Search for 'average' instead.

I recommend you use the search features instead, it will allow you to preview your search instead of losing time to fix your scripts manually for hours. Then you can reuse directly the search string with the process File > Select files: Search query.
https://neuroimage.usc.edu/brainstorm/Tutorials/PipelineEditor#Search_Database

1 Like