-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ENH, MRG] Add compute_csd function #10986
Conversation
Failed tests are because this depends on #10979 |
@wmvanvliet if you have a minute to review this one too that would be really great :) |
Needs to check that it gives the same results as |
Okay, so this passes tests locally that calling
I think question 1 should be addressed before merging but questions 2 and 3 are more long-term trying to figure out how best to do this kind of thing. |
I took a bit more of a look at it appears that |
Okay to merge? This follows the definition of CSD here (From @britta-wstnr et al. 's 2022 Neuroimage paper and pointed out by her) |
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.
@drammock @larsoner @wmvanvliet ok for you?
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.
Just marking as changes requested until my comments above are addressed. CI failure is unrelated and should be fixed by #11034 eventually
Thanks for the review @larsoner, I added those changes. Now, https://github.com/mne-tools/mne-python/blob/main/mne/time_frequency/csd.py#L1344-L1345 is done the old none-einsum way (thanks for figuring that out by the way, I was pretty close actually but just didn't get the right combination of the first index being the only different one, I had the first and second and both the same but now that you wrote the correct one, it seems so easy) but it's done per channel so it's a bit more refactoring than should probably go in this PR. |
Looks good to go unless I missed anything |
Thanks @alexrockhill ! |
Part of #10920.
This uses power to compute the cross-spectral density. It would be nice if this could be done on complex numbers but that's causing issues with positive semi-definite matrices. It might be nice to just go ahead with this version and then improve it later since it matches how other functions like
csd_morlet
do CSD and then modify all the functions to be consistent in a followup PR.