Closed FarnoodF closed 4 years ago
The traceback is quite explicit here. There's something wrong with the data that causes the covariance matrices to not be SPD.
This can happen if:
If you can not fix the root cause of the problem, then we will need to add regularization inside ASR.transform()
. I'll try to provide an option to do that shortly.
Note that in general, Matlab is a bit more flexible that Python and handles these edge cases more gracefully. In Python we have to take care of each scenario explicitly...
The EEG data looks normal: no flat or nan areas, and the number of samples is significantly more than number of channels. I also have not applied any component analysis beforehand. I think the issue arises from the CAR (Common Average Reference) as you mentioned. But CAR is a very common practice in BCI systems to lower the common noise in multiple channels.
At this point I don't think I can do anything on the input side. It would be better if we had the regularization option.
I also looked at your asr_process code and it is implemented differently from its EEGLAB counterpart, is there a reason for that?
At this point I don't think I can do anything on the input side. It would be better if we had the regularization option.
I will try to add an option to perform regularization.
I also looked at your asr_process code and it is implemented differently from its EEGLAB counterpart, is there a reason for that?
The original EEGLAB code is not the cleanest I've ever seen (that's an understatement).
And there are many utilities in Matlab that are not available in numpy or scipy natively so I had to come up with alternatives.
I've done my best to make a working implementation, but I've also taken the liberty to A) clean things up when I deemed it necessary B) deviate from the Matlab code when it made no sense to me.
Can you try https://github.com/nbara/python-meegkit/pull/18 to see if it fixes your problem? You can now specify a covariance estimator with regularization.
@nbara Thanks, it works! But the ASR.transform()
output is complex now with very small imaginary values. Probably add np.real()
?
Can you check #18 again? This should be solved and I'm now properly testing that the output is real-valued.
I run into this error for some of my EEG inputs when I run the
meegkit.asr.asr_process()
:Complete error message:
Running the same code on Matlab using the same EEG does not give me the error.