I can compute patterns on my data when using Logistic Regression model, as in the example. I would like however to compute patterns from an LDA model. I see that MNE creates the patterns_ attribute only for logistic regressions mne-python/base.py at main · mne-tools/mne-python · GitHub. Are you are going to implement this feature also for LDA in future versions of MNE? Or is there a particular reason why this is available for Logisitc Regression and not for LDA?

I decided to give it a try and calculate the patterns myself, by using the coef_ covariance_ attributes stored in sklearn.discriminant_analysis.LinearDiscriminantAnalysis:

for i in range(timepoints):
patterns.append(cov[:,:,i].dot(coef[:,i]))

patterns = np.array(patterns).T

This runs okay, but when I then plot the resulting patterns, they do not look nice and smooth as in the logistic regressions, but are “spiky” and do not make much sense. So there is definitely something I am doing wrong. Could you help me with this?

I had the feeling that the reason why get_coef was not working for in LDA (neither filters_ nor patterns_, while I could get attributes such as coef_ and covariance_) is that logistic regression is part of sklearn.linear_model, while LDA is part of sklearn.discriminant_analysis and somehow MNE was including just the first when transforming coef_. However I might be completely wrong.