Skip to content
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

K-complex detection #184

Open
remrama opened this issue Dec 8, 2024 · 6 comments
Open

K-complex detection #184

remrama opened this issue Dec 8, 2024 · 6 comments
Labels
question 🙋 Further information is requested

Comments

@remrama
Copy link
Collaborator

remrama commented Dec 8, 2024

Hi Raphael,
Sorry to disturb. One more stupid question. Is yasa also supportable in detecting k-complexes and vertex sharp waves?
Or I should switch to other tools to achieve this aim?

Thank you very much!
Zixiao

Originally posted by @zixiao-yin in #40 (comment)

@remrama
Copy link
Collaborator Author

remrama commented Dec 8, 2024

Hi @zixiao-yin,

You should be able to detect k-complexes with the yasa.sw_detect function. Make sure that you limit the detection to N2 sleep. Detection of sharp waves is not implemented.

Thanks! Raphael

Originally posted by @raphaelvallat in #40 (comment)

@remrama
Copy link
Collaborator Author

remrama commented Dec 8, 2024

Thanks for the great package :)

Reviving the question on K-complexes, are there consensus to say that K-complexes are simply N2 slow oscillations? while I do find some papers supporting this point, there are many others saying otherwise. There are also definitions for the KC waveform to be of complete reverse shape i.e. strong surface positive followed by strong surface negative) I have attached some screengrab from papers

GetImage (1)

image

Halasz1998_Hierarchy_of_micro_arousals_and_the_microstructure_of_sleep.pdf

GetImage

https://www.scientificbulletin.upb.ro/rev_docs_arhiva/full782_186975.pdf

of course they could easily be montage choices etc, but would be great if the detection could also take the reverse shaped waveform into accounrt. Happy to contribute of course

Originally posted by @Jhanyi in #40 (comment)

@remrama
Copy link
Collaborator Author

remrama commented Dec 8, 2024

Sorry for the barrage here, but I wanted to move the conversation about K-complexes over here from Issue #40 because there were two separate conversations going on there simultaneously.

Hi @Jhanyi and sorry for moving your post, but maybe we can address it here. I can't speak to consensus, but if you were wanting to try and detect the "reverse" shaped waveform, maybe you could hack it through YASA by setting the negative-peak and positive-peak amplitudes to negative values? I don't know if YASA would accept this (I haven't worked on the sw_detection), but since it seems to look for the negative-peak first and positive-peak second, maybe flipping the signs of those would just do the opposite. Not sure, but let me know if you've already played around with the sw_detection parameters.

@remrama remrama added the question 🙋 Further information is requested label Dec 8, 2024
@Jhanyi
Copy link

Jhanyi commented Dec 10, 2024

@remrama no problem, thanks for creating a separate issue. So I did have a play around switching the postive and negative peak, and it does seem to work well on my suspected KCs with that reverse waveform. I also thought of just inverting the data array (simply data*-1) and apply yasa.sw_detect on this. Both seem to agree quite well on N2, but poorly on N3, which is expected as it should follow the SW morphology. I also loosened both parameters a bit
N2
KC_rev_detect_eg2
KC_rev_detect_eg5

N2 but poor agreement and some misses
KC_rev_detect_eg1

N3 - not great, but expected?
KC_rev_detect_eg7
KC_rev_detect_eg8

@remrama
Copy link
Collaborator Author

remrama commented Dec 10, 2024

Great! Thanks @Jhanyi for giving this a shot and providing a detailed summary. Good idea on the inverted data as well.

So if I understand correctly, the plots titled reverse peak sequence on raw data are also using sw_detect, just by inverting the detection parameters as opposed to the data (please correct me if I'm wrong). Again, I can't speak to the details of the SW detection algorithm, but my intuition would be to prefer the parameter-manipulation bc it only impacts how the algorithm works and doesn't influence the raw data in any way.

@Jhanyi
Copy link

Jhanyi commented Dec 10, 2024

So if I understand correctly, the plots titled reverse peak sequence on raw data are also using sw_detect, just by inverting the detection parameters as opposed to the data (please correct me if I'm wrong).

yep :) so finding positive peak first, then the following negative peak, and the data remains untouched

but my intuition would be to prefer the parameter-manipulation bc it only impacts how the algorithm works and doesn't influence the raw data in any way

Agreed - so I guess this shall just be a temporary solution for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🙋 Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants