mne-tools / mne-features

MNE-Features software for extracting features from multivariate time series
https://mne-tools.github.io/mne-features/
BSD 3-Clause "New" or "Revised" License
142 stars 32 forks source link

CSP.fit_transform() throws LinALgError #50

Closed akatav closed 5 years ago

akatav commented 5 years ago

Dataset consists of some 20 files, 10 control and 10 typical/healthy individuals. Each file is read and the raw data is epoched (With overlap) and squashed into one huge array of dimension (n_epochs, n_channels, n_times). For instance, if a certain file is read in using read_raweeg(), it is subsequently epoched using make_fixed_length_events() into a matrix of dimension - (n_epochs, n_channels, n_times). Each file is epoched in this manner and n_epochs and n_times vary for each file. We select the min(n_times) (of all files) and truncate the epochs. What we have left is a list of epochs for each file where n_times is the same across all epochs. We prepare a corresponding 'y' binary variable whose length is (sum(n_epochs),). We aim to call csp.fit_transform(all_epochs, y) to classify between control and healthy subjects and to plot the respective patterns.

On doing so, we get the following error: LinAlgError: the leading minor of order 4 of 'b' is not positive definite. The factorization of 'b' could not be completed and no eigenvalues or eigenvectors were computed.

How should this be handled?

jbschiratti commented 5 years ago

Unless I am mistaken, this issue does not seem related to mne-features. If you are using the mne.decoding.CSP estimator, you'd better post this on the mne-python issue tracker. In your case, the problem might be that you do not have enough time points per epochs (as you crop all your epochs using the length of the smallest one).