mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.72k stars 1.32k forks source link

CSP questions #7482

Closed zhoudapeng1234 closed 1 year ago

zhoudapeng1234 commented 4 years ago

I don't understand some steps in the CSP calculation process, maybe someone could answer these questions:

  1. Why there is no "whitening transformation" in the fit process? It is different from the calculate steps in the references 《Optimizing Spatial Filters for Robust EEG Single-Trial Analysis》and 《Multiclass common spatial patterns and information theoretic feature extraction》.

  2. Why the eigen_values need to subtract 0.5 before being sorted? image

agramfort commented 4 years ago

ping @alexandrebarachant @cbrnr

cbrnr commented 4 years ago

@mbillingr I think you wrote some of the CSP code - can you answer these two questions?

mbillingr commented 4 years ago

Amazing how the most "obvious and self-explanatory" code turns into "WTF did I think?" after a couple of years...

  1. I can't answer the first question; it has been too long that I have read the papers. Do the papers say anything about why the whitening transform is required?

  2. This is an obscure way of rearranging the sorted eigenvalues. I believe it was meant to separate the patterns associated with the two classes.

larsoner commented 3 years ago

Looks like (2) was fixed by #8151, the whitening issue I'm not sure about

catalinamagalvan commented 3 years ago

About (1), the calculation steps are here very similar to the ones in 《Optimizing Spatial Filters for Robust EEG Single-Trial Analysis》. The only difference I see is that in this function the generalized eigenvalue problem solved is:

eigen_values, eigen_vectors = linalg.eigh(covs[0], covs.sum(0))

instead of

eigen_values, eigen_vectors = linalg.eigh(covs[0], covs[1])

that would be strictly the same of the papers, but both are equivalent and lead to the same result.

larsoner commented 1 year ago

I think the questions have been answered and if not, nowadays https://mne.discourse.group/ is the place to go to discuss them (and then maybe open a PR to improve our docs)