-
Notifications
You must be signed in to change notification settings - Fork 67
Add detect_oscillatory_events
method
#485
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
eead83c
to
d3a25b9
Compare
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.
Mostly minor comments but everything else is good.
pynapple/process/filtering.py
Outdated
Parameters | ||
---------- | ||
lfp : Tsd | ||
Should be a single channel raw lfp |
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 necessary raw lfp. I would just say
Should be a single channel raw lfp | |
1-dimensional time series |
pynapple/process/filtering.py
Outdated
min_inter_duration : float | ||
The minimum duration between two events otherwise they are merged (in seconds) | ||
wsize : int, optional | ||
The size of the window for digitial filtering |
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.
The size of the window for digitial filtering | |
The size of the window for digital filtering |
pynapple/process/filtering.py
Outdated
the power, amplitude, and peak_time | ||
""" | ||
lfp = lfp.restrict(epoch) | ||
frequency = lfp.rate |
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 should be passed as a parameter 'fs' with default None.
If it's None, use tsd.rate
. If it's a Number, use the passed fs
.
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.
pynapple/process/filtering.py
Outdated
The interval set of detected events with metadata containing | ||
the power, amplitude, and peak_time | ||
""" | ||
lfp = lfp.restrict(epoch) |
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.
lfp = lfp.restrict(epoch) | |
tsd = tsd.restrict(epoch) |
It can be anything
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.
Changed to data
in 84fc658
pynapple/process/filtering.py
Outdated
peak_times = [] | ||
|
||
for s, e in osc_ep.values: | ||
seg = signal.restrict(nap.IntervalSet(s, e)) |
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.
Here you can be faster with :
seg = signal.restrict(nap.IntervalSet(s, e)) | |
seg = signal.get(s, e) |
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.
Fixed in 84fc658
tests/test_filtering.py
Outdated
"freq_band, thresh_band, start, end", | ||
[ | ||
((10, 30), (1, 10), 0, 2), | ||
((40, 60), (1, 10), 3, 5), |
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.
There should be one more case which is the absence of detected events.
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.
Added! I've noticed certain freq ranges seem to produce false positives though - going to keep testing a bit
Could you try to merge |
Summary
Adds a new method
detect_oscillatory_events
to thefiltering
module that allows for detection of ripple-like intervals in signals. Based on this EEG processing example.Example
Todo
Open questions
apply_bandpass
instead offiltfilt
but I think as written, both may be necessary unless we think it's ok to skip the smoothing step—or could useTsd.smooth
here?