You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifopt.startprob >5&&maxiter<8% don't decrease and startover more than 8 times
fprintf('Decreasing probability limits for final pruning...######\n');
opt.startprob =opt.startprob -0.5; numrej =1; maxiter =maxiter+1; % repeat process back to 5 stds
else
ifmaxiter>8
opt.maxrej =15; % go through last round with a high threshold
else
repeat =0;
end
Dear EEGLab Team,
we are currently looking through the pop_autorej function because we are trying to imitate the process in python.
While doing so, we have run into a question regarding the trial rejection iteration flow.
We noticed that the maximum percentage of allowed rejected trials (opt.maxrej) is supposed to increase to 15 in line 216 for a final run through.
However, it is necessary that the variable maxiter increases to a minimum of 9 for this to happen.
maxiter is only increased in line 213, and due to the criterion in line 211, it can only ever reach a value of 8.
Unless we are missing something, we currently believe that this makes line 216 unreachable.
Furthermore, if it could be reached, subsequent runs would not be able to reach the break criterion in line 218 due to maxiter always being larger than 8.
We are now wondering if the increase of opt.maxrej is worth implementing at all, or if this is simply a piece of obsolete code that we should ignore.
We appreciate any help!
Thanks for the careful read, you are right on both counts. maxiter tops out at 8, so the opt.maxrej = 15 branch could never run, and if it ever had, nothing inside it set repeat = 0, so the loop would have spun forever. It is leftover code from the 2008 version, not a hidden feature.
We removed it in #962, now merged into develop. So for your Python version, the documented behavior is all you need: reject when the flagged epochs are under maxrej (5% by default), otherwise raise the threshold by 0.5 s.d., then once nothing is flagged walk the threshold back down in 0.5 s.d. steps for at most 8 rounds. No 15% pass.
Activity
arnodelorme commentedon Sep 9, 2026
Thanks for the careful read, you are right on both counts. maxiter tops out at 8, so the opt.maxrej = 15 branch could never run, and if it ever had, nothing inside it set repeat = 0, so the loop would have spun forever. It is leftover code from the 2008 version, not a hidden feature.
We removed it in #962, now merged into develop. So for your Python version, the documented behavior is all you need: reject when the flagged epochs are under maxrej (5% by default), otherwise raise the threshold by 0.5 s.d., then once nothing is flagged walk the threshold back down in 0.5 s.d. steps for at most 8 rounds. No 15% pass.
Also, since you are porting this to Python: we are doing the same for all of EEGLAB in sccn/eegprep (https://github.com/sccn/eegprep), and there is already a pop_autorej port at https://github.com/sccn/eegprep/blob/develop/src/eegprep/functions/popfunc/pop_autorej.py. Feel free to compare notes with yours, and issues or PRs over there are very welcome. Happy to join forces rather than have two ports.