Remove or delete tag

Hi

After running the process to standardize channels the subjects with additional unused channels now have a tag '| stdchan |' on their epoch filenames. I tried using the below script to find these files so I can delete this tag from the filenames of the 4 types of imported epochs. After running it I get the below error message. I tried reloading the protocol but same result. Could you advise what function is needed to find these files?

% Process: Select files using search query
sFiles = bst_process('CallProcess', 'process_select_search', sFiles, [], ...
'search', '([name CONTAINS "11_right"] OR [name CONTAINS "12_right"] OR [name CONTAINS "21_right"] OR [name CONTAINS "22_right"])');

for iFile = 1:length(sFiles)
DataMat = in_bst_data(sFiles(iFile).Comment)
MyData = find(strcmpi({DataMat}, ' | stdchan'))
end

Error using in_bst_data (line 43)
Data file was not found:
E:\Brainstorm_db\VSTMB_task\Protocol01\data\11_right (#1)
Please reload this protocol (right-click > reload).

Error in Working_file (line 14)
DataMat = in_bst_data(sFiles(iFile).Comment)

Hi David,

You get an error because you try to read the file from its name in the database (Comment field) rather than its file name (FileName field).

I would recommend using the Set Name / Set Comment process to do this:

for iFile = 1:length(sFiles)
    OldComment = sFiles(iFile).Comment;
    NewComment = strrep(OldComment, ' | stdchan', '');
    if ~strcmp(OldComment, NewComment)
        bst_process('CallProcess', 'process_set_comment', sFiles(iFile), [], ...
            'tag',           NewComment, ...
            'isindex',       0);
    end
end

Best,
Martin

Thank you Martin