[pymvpa] Matrices per Searchlight

Yaroslav Halchenko debian at onerussian.com
Tue Nov 26 02:28:02 UTC 2013


On Mon, 25 Nov 2013, Hanson, Gavin Keith wrote:

> @ Dr. Halchenko
> I already tried to do what you suggest: that is, set up CrossValidation with BayesConfusionHypothesis, as you show below, and use that as the data measure within a sphere_searchlight. However, I do not get the results on a per-feature level. It's possible that it's there, and I cannot figure out how to access it, but a look at res.sa.hypothesis doesn't give me results per feature, which is what I'm after.

eventually we might I guess add some candy to searchlighting to also
aggregate  output  .sa and/or .fa per searchlight into .sa or .fa of the
total result.  For now you might need to just add your custom
postprocessing node which would keep those of interest for you
"manually", e.g. here how I would have expanded that example:

# original CV but with chainnode elements in a list not in a tuple so I
could append

    cv = CrossValidation(
        clf, NFoldPartitioner(),
        errorfx=None,
        postproc=ChainNode([Confusion(labels=ds.UT),
                            BayesConfusionHypothesis()]))

    from mvpa2.base.node import Node
    from mvpa2.measures.searchlight import sphere_searchlight

    class KeepBothPosteriorAndHypothesis(Node):
        def _call(self, ds):
            out = np.zeros(1, dtype=object)
            out[0] = (ds.samples, ds.sa.hypothesis)
            return out
    cv.postproc.append(KeepBothPosteriorAndHypothesis())
    sl = sphere_searchlight(cv)
    res = sl(ds)

should return both posteriors and hypothesis... at a performance/storage
cost since handling those object arrays is a bit more "costly"

-- 
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Senior Research Associate,     Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        



More information about the Pkg-ExpPsy-PyMVPA mailing list