Why do bad channels still appear in correlation connectivity results?

Hello,

I’m running correlation-based connectivity analysis in Brainstorm. I noticed that even though I marked some channels as bad in the recordings, they still appear in my connectivity matrices.

My questions are:

  1. Are bad channels automatically excluded from the correlation connectivity computation, or are they included but their values set to zero?

  2. If they’re included, what’s the rationale?

  3. What is the recommended way to completely exclude bad channels from connectivity results if I don’t want them to appear at all?

Thanks !

In the connectivity processes, there is the option Include bad channels, was it selected?

If Include bad channels is checked, the data in those bad channels is included.
Else, the entire channel is not considered. This may lead to problems if computing the aggregated connectivity across multiple files, in the case where files have different bad channels.

To have connectivity matrices of the same size. E.g. on aggregating connectivity matrices across epoch when epochs have different bad/good channels.

If connectivity is computed for each epoch, unchecking the option Include bad channels is enough. If the connectivity is computed across epochs, you need to set the the bad channel as bad for all the epochs and unchecking the option Include bad channels. This can be done in the DB explorer: https://neuroimage.usc.edu/brainstorm/Tutorials/BadChannels#From_the_database_explorer

Thank you so much for your answer. I did not use GUI, I have my script:

%% Correlation Calculation in Brainstorm
ProtocolName = ‘…';
SubjectName = '…';
SensorTypes = 'ECOG'; % 'ECOG','SEEG','EEG'

% Start Brainstorm
if \~brainstorm('status'), brainstorm nogui; end

iProt = bst_get('Protocol', ProtocolName);
if isempty(iProt), error('Protocol not found: %s', ProtocolName); end
gui_brainstorm('SetCurrentProtocol', iProt);

% Sadece epok dosyalarını seç (BAD trial'lar hariç)
sAll = bst_process('CallProcess','process_select_files_data', [ ], [ ], ...
  'subjectname', SubjectName, ...
  'condition', '', ...
  'tag', 'HFO', ...
  'includebad', 1, ...
  'includeintra',0, 'includecommon',0);

if isempty(sAll)
  error('Hiç HFO etiketli epoch bulunamadı. (Tag="HFO", condition boş).');
end

% Bad trial’ları çıkar
sGood = bst_process('CallProcess','process_select_files_data', sAll, [ ], ...
  'subjectname', SubjectName, ...
  'condition', '', ...
  'tag', '', ...
  'includebad', 0, ...
  'includeintra',0, 'includecommon',0);

fprintf('HFO epok sayısı: toplam=%d, good=%d, bad=%d\n', ...
    numel(sAll), numel(sGood), numel(sAll)-numel(sGood));

if isempty(sGood)
  error('Good epok bulunamadı. (Muhtemelen tüm HFO epokları BAD ile çakışıyor ya da tag/subject eşleşmedi.)');
end

% Pearson correlation NxN (epoch bazında)
sConn = bst_process('CallProcess','process_corr1n', sGood, [ ], ...
  'timewindow', [ ], ...
  'sensortypes','ECOG', ...
  'includebad',0, ...
  'timeres','none', ...
  'scalarprod',0, ...
  'outputmode','input');

bst_report('Open', bst_report('Save', sConn));

Should I change/add something to remove bad channels from the matrix? I computed connectivity for each epoch. I assume they’re not included in the correlation calculation but maybe it does zero padding for those channels? So I removed those after the calculation, but in essence, I don’t want them in the first place.

No, the code is correct (I already tested on my side), when computing the correlation is doing it per epoch ('outputmode','input') and bad channels are excluded ('includebad',0).

Bad channels are not included. For epochs with bad channels, those bad channels will not appear in the connectivity matrix. If they do appear in the connectivity matrix, double-check that those channels are really labelled as bad. The quickest way to do so is in the GUI.

https://neuroimage.usc.edu/brainstorm/Tutorials/BadChannels#From_the_database_explorer