[pymvpa] Time resolved decoding and classifier customization.
Roberto Guidotti
robbenson18 at gmail.com
Thu Jul 2 15:24:13 UTC 2015
Dear all,
Suppose I have two conditions, n runs with m trial and each trial is
composed by t volumes (frames). I would like to do a time-wise
(time-resolved) decoding to have the decoding accuracy curve for each time
frame.
I saw several approaches to do this:
1) the first is to train the classifier using t datasets one for each time
frame using volumes belonging to the same time frame thus I will have t
accuracies
2) the second is to train the classifier using the within-trial averaged
dataset (mean of t frames) and then test using each time-frame so having
also t accuracies.
Q1: Which approach will you use? Are there other approaches?
I would like to implement the second one in PyMVPA, so that the classifier
needs to average in the training step on the training chunk of the dataset.
I made a little test extending LinearCSVM class overriding the _train
function:
def _train(self, ds):
avg_mapper = mean_group_sample(['trial']) # I build my ds with this
attr
ds = ds.get_mapped(avg_mapper)
return LinearCSVMC._train(self, ds)
Moreover I implemented an error class to compute time wise test error, to
be passed to the CrossValidation:
class ErrorPerTrial(BinaryFxNode):
def _call(self, ds):
[...same code of the parent class...]
err = [self.fx(values[ds.sa.frame == i], targets[ds.sa.frame ==
i])
for i in np.unique(ds.sa.frame)] # I compute a list of fx
values
I think that maybe the ErrorPerTrial class is almost good (but if you have
a more elegant solution is well-accepted :)), while extending every
classifier is the worst solution, maybe a decorator or a wrapper is a
possible solution.
Q2: How to implement this (if not yet implemented in pymvpa)? Could be a
solution build an TrialAverager class that extends Learner with a
classifier as input parameter and perform averaging?
Sorry for the tricky and long post.
Thank you,
Roberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20150702/9fc0a47b/attachment.html>
More information about the Pkg-ExpPsy-PyMVPA
mailing list