Removing sub matrix from 3d matrix, if any values in the matrix exceed a certain min/max value

1 view (last 30 days)
I am currently trying to do artifact rejection on my EEG.data. I have three sets of epoched data (in 3D matrices, for example 64(channels)x250(samplingtimes)x98(trials)).
I need to create a loop that runs through my EEG.data files and removes the trials containing values over/under 100 uV. For example, eye blink artifacts are easily detected in the Fp1 and Fp2 channels, which correspond to row 1 and 2 of the first dimension of my matrix. So if EEG.data(1:2, : , trial) >= 100, delete the trial. I am very new to matlab and would really appreciate any help.
for a=size(epochs_CG,3) % for the size of my
if epochs_CG(1:2, :, a)> 100
epochs_CG(:,:,a) = [];
elseif epochs_CG (1:2, :, a)< 100
epochs_CG(:,:,a) = [];
end
end
This did not work :P

Accepted Answer

Matt J
Matt J on 18 Mar 2019
Edited: Matt J on 18 Mar 2019
discard=any( any( epochs_CG(1:2, :, :)>=100 ,2) ,1);
epochs_CG(:,:,discard)=[];

More Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!