spolsley / common-spatial-patterns

General CSP algorithm implementation for spatial filter construction
MIT License
30 stars 12 forks source link

Two class EEG data, get two csp matrix, which should I use? #2

Closed ZhangHanN1 closed 5 years ago

ZhangHanN1 commented 5 years ago

When I run the program, I got two csp matrix ( filters ), and they are reverse in row, beyond that no any difference. So I want know which matrix should I use? And should I use all of them that the first one corresponds to the class 1 and the second one corresponds to the class 2? Thanks for your help!

spolsley commented 5 years ago

Yes, as I recall, you'll want both. The CSP function will return a spatial filter for each of the classes you pass to the function, returned in the order they were passed.

For example, consider a sensorimotor study in which the user imagined moving their left and right arms 30 times apiece. You might window and filter the EEG readings and then wish to build a spatial filter to amplify relevant signals. You could call:

Spatial_Filter_Left, Spatial_Filter_Right = CSP(left_trials,right_trials)

where the input arrays contain 30 rows (the 30 trials) and maybe 200 samples (let's say 100 Hz, 2 second windows). The output filters could both be used, with one ideally boosting the left imagined signal and the other boosting the right.

I'm not sure about the reverse row order you're describing, but it may be something to do with your data. At any rate, I hope this helps!

ChadChen68 commented 2 months ago

Hello, I recently analyzed ERP EEG signals. I have 8 channels, and after applying CSP, I obtained two 8x4 spatial filters, one for class 1 and one for class 2. After that, I get 8 components, where components 1 to 4 are for class 1, and components 5 to 8 are for class 2. When I use these for classification, should I use components 1 and 4 or components 1 and 8?