-
Notifications
You must be signed in to change notification settings - Fork 241
Make peak detection (locally_exclussive, matched_filtering) faster and more accurate. #4341
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
base: main
Are you sure you want to change the base?
Make peak detection (locally_exclussive, matched_filtering) faster and more accurate. #4341
Conversation
|
Great, this is cool, looking forward to try it out ! But what about the matched filtering ? |
yger
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.
Looks good to me!
| templates=None, | ||
| peak_sign="neg", | ||
| exclude_sweep_ms=0.1, | ||
| exclude_sweep_ms=0.8, |
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.
You're using 0.8 for all the internal sorters, but 1.0 for the defaults in detect_peaks. Is this deliberate?
| # if inside spatial zone ... | ||
| if abs(samples_inds[i] - samples_inds[j]) <= exclude_sweep_size: | ||
| # ...and if inside tempral zone ... | ||
| value_i = abs(traces[samples_inds[i], chan_inds[i]]) / abs_thresholds[chan_inds[i]] |
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.
So here, the abs_threshold is proportional to the noise on the channel. What's the advantage of using the noise normalised value? Is this to avoid peaks on very noisy channels?
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.
This avoid that a peak is eliminated even if the snr is higher.
It was not the case before. This is a marjor change in this PR when the noise_levels is different over channel.
I think this is more correct
| if peak_sign == "both": | ||
| peak_mask_pos = peak_mask.copy() | ||
| if samples_inds[i] - exclude_sweep_size > samples_inds[j]: | ||
| next_start = j |
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.
| next_start = j | |
| next_start = j+1 |
shave off those nanoseconds ;)
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.
not sure. why ?
The following j will do it if nessecary.
After playing a bit with the rust language, and trying to reimplement the peak detection algo using "locally_exclussive"
I discover that the actual impelmentation could be fasten a lot (at least 3X faster on my machine).
"matched_filtering" has also beeb changed in this PR.
Also the new implementation is is more accurate for corener cases :
Also I change the
exclude_sweep_ms=0.1at many place in the code this was a bad value by default it has to be half on the peak waveforms or a bit more.