Thank you both! This was very helpful.
In case it help someone else, I adapted my script such that it now reads a table formatted as follow (this is an example) :
and gives the following (expected) result in Brainstorm:
Here is the script :
% Get the electrode(s) to mark as bad in specific trials
trial_chan = readtable(BadTrialChan) ;
% Get channel file
channelFile = bst_get('ChannelFileForStudy', sFiles.FileName) ;
sChannel = in_bst_channel(channelFile);
fileNames = {sFilesEpochs.FileName} ;
% List of bad channels per file
for iFile = 1 : length(trial_chan.TrialID)
% Reads epoch in which there are one or several channels to mark as bad
sFile = in_bst_data(fileNames{trial_chan.TrialID(iFile)}, 'ChannelFlag', 'Comment');
% Process: Set bad channels
chan_sFiles = bst_process('CallProcess', 'process_channel_setbad', sFilesEpochs(trial_chan.TrialID(iFile)), [], ...
'sensortypes', trial_chan.ChannelList{iFile});
end
Cheers,
AnneSo