Skip to content

Commit

Permalink
Inverse: Check for bad-channel agreement in noise/data cov and record…
Browse files Browse the repository at this point in the history
  • Loading branch information
rcassani committed Mar 19, 2024
1 parent d66c0f3 commit 91b65cc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions toolbox/process/functions/process_inverse_2018.m
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,12 @@
errMessage = [errMessage 'The noise covariance contains NaN values. Please re-calculate it after tagging correctly the bad channels in the recordings.' 10];
break;
end
% Check that bad channels in noise covariance are the same as bad channels in recordings
badChNoiseCov_goodChRecs = intersect(find(and(~any(NoiseCovMat.NoiseCov,1), ~any(NoiseCovMat.NoiseCov,2)')), GoodChannel);
if ~isempty(badChNoiseCov_goodChRecs)
errMessage = [errMessage 'Bad channels in noise covariance are different from bad channels in recordings.' 10 'Please re-calculate it after tagging correctly the bad channels in the recordings.' 10];
break;
end
% % Divide noise covariance by number of trials (DEPRECATED IN THIS VERSION)
% if ~isempty(nAvg) && (nAvg > 1)
% NoiseCovMat.NoiseCov = NoiseCovMat.NoiseCov ./ nAvg;
Expand All @@ -512,6 +518,11 @@
errMessage = [errMessage 'The data covariance contains NaN values. Please re-calculate it after tagging correctly the bad channels in the recordings.' 10];
break;
end
badChDataCov_goodChRecs = intersect(find(and(~any(DataCovMat.NoiseCov,1), ~any(DataCovMat.NoiseCov,2)')), GoodChannel);
if ~isempty(badChDataCov_goodChRecs)
errMessage = [errMessage 'Bad channels in data covariance are different from bad channels in recordings.' 10 'Please re-calculate it after tagging correctly the bad channels in the recordings.' 10];
break;
end
% % Divide data covariance by number of trials
% if isempty(nAvg) && (nAvg > 1)
% DataCovMat.NoiseCov = DataCovMat.NoiseCov ./ nAvg;
Expand Down

0 comments on commit 91b65cc

Please sign in to comment.