-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG, ENH: Add autobad detection like MF #6940
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
Conversation
|
tutorial LGTM. I didn't really have time for more than a skim of the code changes. |
Codecov Report
@@ Coverage Diff @@
## master #6940 +/- ##
==========================================
+ Coverage 89.92% 89.96% +0.04%
==========================================
Files 453 451 -2
Lines 82111 81731 -380
Branches 12999 12968 -31
==========================================
- Hits 73840 73531 -309
+ Misses 5445 5374 -71
Partials 2826 2826 |
|
@larsoner did you test on a number of datasets to which point this implementation matches with maxfilter output? |
|
@olafhauk maybe you can give it a try? |
|
I tried it on
If I tweak |
|
I can test on cam-can data but I would need the bads found by original maxfilter program. @olafhauk @dengemann @SherazKhan do you know where I can find this? |
wmvanvliet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool PR!
|
@wmvanvliet if you have access to original maxfilter code can you test this PR on some of your dataset? thanks |
|
What procedure do you want me to use to check maxwell vs mne output? Here is my first attempt, giving me different bad channels: https://gist.github.com/wmvanvliet/a3944ad425f28e33fba836315f78169d |
|
yes I would like a public quantified evaluation of the differences so we
know where we stand
… |
|
Here are some results: https://pastebin.com/KafKgLH3 |
|
For flats you need to use |
|
@wmvanvliet you might also find that changing the |
|
With |
|
can you cook a summary figure of this? fraction of time where they agree?
summary of average overlaps between sets?
… |
|
How's this? https://pastebin.com/vcKwRbSf |
|
A 12% absolute match is not so great :( I'll ping Jukka and see if he has any insight into why things might be different. It's possible that it's the filtering. Are these European / 50 Hz data? The line noise might be messing things up, and if they use a brick wall FFT that stops at 49 Hz, that will be very different from what If it's easy enough to re-run, you could try |
|
Powerline is at 50Hz, yes |
|
Also did you make sure the params were the same like |
|
I've just come back from another trip. You want me to test the autobad option in maxfilter? |
|
|
That improved things a little: https://pastebin.com/M1tdsz6f |
80 hits, 14 misses, 46 false alarms (and 9958 correct rejections) -- getting better at least! I emailed Jukka to see if he has some insight into where other potential differences may arise, but it might take a bit for him to get back to me. I'll mark this WIP in the meantime
@olafhauk no we do not have this info yet |
If you have already applied for access to CamCan MEG data via the CamCan web-site, you should be able to find the log-files with bad channel information on your temporary CBU account. Otherwise you need to apply for access to these data. I don't work with CamCan data myself at the moment I'm afraid. For queries it's probably best for the person who applied for CamCan access to write to rik.henson@mrc-cbu.cam.ac.uk directly. |
|
@wmvanvliet I don't have any lines that look like |
|
I have $Revision: 2.2.15 Neuromag maxfilter Dec 11 2012 14:48:36 $
… On 21 Oct 2019, at 19:06, Eric Larson ***@***.***> wrote:
@wmvanvliet I don't have any lines that look like Detected 2 flat channels what MaxFilter version are you using? I have Revision: 2.2.15
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
|
So it turns out that MaxFilter does some stuff that we can and probably should avoid. The reading, filtering, and downsampling is tied to the number of tags and number of samples per tag, which we don't need to do because of our reading abstractions. Moreover, we can just load and filter all data at once to avoid edge artifacts. It seems like the hits/misses/false alarms are now most strongly tied to how the filtering is done (windowing, steepness, corner frequency) and I think we should just make a sensible choice (probably low-pass below the line freq) and go with that, noting that MF behavior will be different. For now I've pushed something that gets me 53/6/14/7271 for hit/miss/FA/CR on 32 files, with the numbers bouncing around depending mostly on how I change our filtering choices. @wmvanvliet can you try re-running on your data? You can remove any flat or bad marking steps at the Python end, e.g. you no longer need to |
|
ping @wmvanvliet :
See my explanation above, but I think at this point even with some mismatches we are doing about as well as we should try to do in matching what MaxFilter does. See if you agree with my reasoning above. With this and #7290 I'll finally be able to have everything in Python (no need for pushing files to a MaxFilter workstation)... |
|
ping @wmvanvliet, it would be nice to move forward on this if possible |
|
Updated script: https://gist.github.com/wmvanvliet/a3944ad425f28e33fba836315f78169d |
|
@wmvanvliet I think that's pretty good! It's not perfect, but based on what I wrote above I think this is expected. Are you (sufficiently) convinced? |
|
At the very least, it's a useful addition :) It's ok for me if things are not 100% MF compatible, as other portions such as the head position tracking also vary a little. |
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have a
def find_outliers(X, threshold=3.0, max_iter=2):
in a file called preprocessing/bads.py
maybe we could APIs between functions that aim to find bad channels?
find_outliers -> find_bads_zscore
here then find_bads_maxwell ?
thinking out loud...
This looks like it's supposed to be a private function -- it's undocumented in That frees us up from worrying about that function at all. I'm fine with |
|
Pushed a commit to rename to |
|
+1 for find_bad_channels_maxwell and to deprecate find_outliers
|
|
CI failures are unrelated |
|
awesome @larsoner ! |
* ENH: Add autobad detection like MF * API: Rename to find_bad_channels_maxwell * DOC: Missed a few omissions [ci skip]
* ENH: Add autobad detection like MF * API: Rename to find_bad_channels_maxwell * DOC: Missed a few omissions [ci skip]
At the sprint @olafhauk mentioned that not having
-autobadsupport was what he was missing in his Python pipeline. This adds support for it.