question about sw_slope in sw_detect
Hi,
I was trying to duplicate slow wave detection (sw_detect) function.
https://github.com/raphaelvallat/yasa/blob/f76f63541ae1dc10e645cdb9be9fa4b0f5eadda5/src/yasa/detection.py#L1762C1-L1763C58
I'm wondering whether the sw_slope calculation is correct. Since sw_ptp is measured from the negative peak to the positive peak, I think the denominator should be sw_idx_pos - sw_idx_neg instead of sw_midcrossing - sw_idx_neg?
Thanks for opening the issue. You are right that the current implementation does not match what is written in the doc:
Slope between NegPeak and MidCrossing
https://github.com/raphaelvallat/yasa/blob/v0.6.5/docs/pictures/slow_waves.png
The calculation should be adjusted to use the amplitude of the negative half-wave instead of the peak-to-peak amplitude.
I have added a PR #220 to fix this issue.