-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyPREP interpolates more channels than MATLAB PREP during re-referencing #91
Comments
It seems like there is no bottom to this pit! Thanks for digging on :)
😱 agreed, it looks like a mistake. I think you should open an issue about that on MatPREP.
I am not sure either to be honest. |
Hopefully apart from CleanLine this is the bottom: with this issue addressed along with #92, the final post-interpolation reference signal matches the one from the MatPREP artifacts within a tolerance of 1e-4 (think there's maybe a minor rounding difference somewhere in the interpolation code), and all of the pre-interpolation and post-interpolation noisy channels match up exactly 🎉
I'll bring it up whenever Dr. Robbins gets back to me about #54 (I pinged her about it a week or so ago, she said she's currently deep in another project but will respond as soon as she has a chance to pull herself out of that headspace). In the meantime, I guess we could wrap it in
I guess it hinges on whether a channel originally flagged as bad-by-SNR is a channel we'd want to exclude from the estimated robust reference no matter what: if a channel is initially bad by both HF noise and low inter-channel correlation, but after initial average referencing is no longer bad by either, I can't think of an a-priori reason to permanently exclude it from the average reference while still leaving in any channels bad by RANSAC/deviation/correlation/noise/dropout detected during that first pass (see #78). The only way that SNR channels are different from those is that they're excluded from the initial reference signal along with bad-by-NaN/flat channels, which are always excluded due to NaN and rank deficiency issues (respectively). |
agreed 👍 regarding opening an issue: your choice of course, but I recommend to keep as much as possible on public channels instead of Emails (which only very few people can profit from/help with) :)
that sounds reasonable to me. |
Another difference I caught trying to unit-test my code for #77: during re-referencing, after the initial pass that detects and removes bad-by-NaN/flat/low-SNR channels from the initial average reference, MATLAB PREP's rereferencing loop doesn't interpolate channels that are bad by SNR or dropout (including any bad-by-SNR channels that were flagged on the first pass).
Basically, in PyPREP we always update the list of total bad channels after each re-reference iteration using
NoisyChannels.get_bads()
, which returns all bad channel types. In MatPREP, it's updated by the following function:As you can see,
ref.all
andnoisy.all
. This means that any bad-by-SNR channels flagged during the first pass don't get carried over into theref.all
for future iterations if they aren't flagged bad by some other metric.ref.all
, possibly by mistake (see: the duplicate bad-by-RANSAC at the end).Looking back at the MatPREP commit where that function was introduced, it looks like this function replaces simple updating of the full set of noisy channels so at least some of it seems to be deliberate?
Anyway, I'm not entirely sure how to best fix this because I can't easily tell whether PyPREP's logic or MatPREP's makes the most sense, and thus whether this should be fully or partly wrapped in
matlab_strict
. 3 certainly seems to be undesirable, since you probably wouldn't want a channel with intermittent flat regions being included in your estimated clean reference signal. What do you think?The text was updated successfully, but these errors were encountered: