raphaelvallat / yasa

YASA (Yet Another Spindle Algorithm): a Python package to analyze polysomnographic sleep recordings.
https://raphaelvallat.com/yasa/
BSD 3-Clause "New" or "Revised" License
425 stars 115 forks source link

Question about the time value and filter edge artifacts in PAC #177

Open bettina77 opened 3 months ago

bettina77 commented 3 months ago

Dear Raphael,

This is a question about the purpose of the 2 second epochs around the negative peak of the detected slow-waves in the SO-sigma coupling algorithm. In the examplary text of the notebook it is specifically mentioned that "Only the time range from 2 to 2 s was considered, to avoid filter edge artifacts." So, do I understand correctly that this time value is specifically used to minimize or cap filter edge artifacts and act as a buffer to avoid filter-related signal distortion during the PAC process?

Again, sorry that this is a very basic question, I just wanted to double check that my understanding of this standard 2 sec value for the "time" variable is correct.

Best, Bettina

raphaelvallat commented 3 months ago

Hi @bettina77,

this time value is specifically used to minimize or cap filter edge artifacts and act as a buffer to avoid filter-related signal distortion during the PAC process?

In theory, yes. However, in YASA the filtering is applied on the raw, whole-night signal at once, and not separately for each slow-wave epoch as in the cited article, therefore the edge artefacts are not really an issue. I kept the 2-seconds because I think it provides a good trade-off between being too narrow or too wide around the negative peak of the slow-waves, while making sure that the selected window includes the full slow-wave oscillation. You could also set this parameter to 1-second if you wanted to be very specific. I would not recommend using values below 1-second or larger than 3 seconds though.

Best, Raphael

bettina77 commented 3 months ago

Hi Raphael,

This was very helpful, thank you for the super quick clarification!

Best, Bettina