I am dealing with a classification problem (Linear SVMs) in EEG data. I am
a new-comer in Python and also in the MNE community, so what I am going to
ask might sound silly.
I am trying to estimate the patterns using the LinearModel and get_coef().
I was looking in the documentation ( http://martinos.org/mne/stable/auto_examples/decoding/plot_linear_model_patterns.html),
and saw that the LinearModel() class is not cross-validated. I was
wondering it would make sense to retrieve cross-validated spatial patterns?
Indeed, in theory it's probably best to report the patterns that match the
decoding scores, and thus use cross-validation:
e.g.
X=epochs.get_data()
y=epochs.events[:, 2]
pipeline = make_pipeline(StandardScaler(), LogisticRegression())
patterns = list()
for train, test in cv.split(X, y):
lm = LinearModel(pipeline)
lm.fit(X, y)
pattern = get_coef(lm, 'patterns_')
patterns.append(pattern)
patterns= np.mean(patterns, axis=0)
However, in practice this CV is an overkill because the patterns (and
spatial filters) correspond to the model, and thus depend on the training
data. Since the training splits are not independent with one another, the
patterns across splits should be very similar - and in fact converge
towards the patterns of the non-cv fit.