[pymvpa] How to make the data like hyperalignment_tutorial_data.hdf5.gz

Yaroslav Halchenko debian at onerussian.com
Sun Jun 28 01:24:30 UTC 2015

On Sat, 27 Jun 2015, 孔令军 wrote:

>    Dear sir,

>    I'm a graduate student from Beijing Normal University.
>    I'm using your PyMVPA package for brain imaging
>    research----------(Hyperalignment for between-subject analysis).
>    I can get the same answer like the manual ,but I don't know how to make
>    the data like "hyperalignment_tutorial_data.hdf5.gz"  ,so I can use this
>    method for my own research.

>     http://dev.pymvpa.org/examples/hyperalignment.html?highlight=hyperalignment

>    I'll be appreciate it if you can offer your help.

there is nothing special about that file -- it is just a list of
datasets.  The only peculiarity is that each dataset was reordered so
chunks correspond to functional runs in the sequence so their trial order
is matching (so not in the sequence they were originally acquired).  What I mean
is:  for hyperalignment you need signals across subjects to correspond to the
same stimuli.  Imagine you had 2 stimuli (a and b) and you had 2 subjects which
acquired 3 functional runs each with following trial orders:

        run1    run2    run3
subj1   abaabb  baabab  bbabba
subj2   baabab  bbabba  abaabb  

so before hyperalignment you want to reorder runs so sequences

        chunk1  chunk2  chunk3
subj1   abaabb  baabab  bbabba
subj2   abaabb  baabab  bbabba  

then one peculiarity (what we don't show actually in the example, but it
is how it was done in Haxby 2011 paper), you want to crossvalidate not only
across subjects but also across runs, so that original sequence was not used:

split 1 (train on subj1, cv to subj2):

        chunk1  chunk2  chunk3
subj1           baabab  bbabba
subj2   abaabb  

split 2 (train on subj1, cv to subj2):

        chunk1  chunk2  chunk3
subj1   abaabb          bbabba
subj2           baabab

and so on.  

For that purpose, if you hyperalign on independent dataset (e.g. on subjects
watching a movie -- everything is in sync), we have an additional
construct in PyMVPA with a quite obscure name:
ExcludeTargetsCombinationsPartitioner.  Here is an extract from its docstring:

    While cross-validating across subjects (e.g. working with
    hyperaligned data), to avoid significant bias due to matching
    trial-order effects instead of categorical boundaries, it is
    important to exclude from training chunks with the order matching
    the ones in testing.

    >>> partitioner = ChainNode([NFoldPartitioner(attr='subject'),
    ...                          ExcludeTargetsCombinationsPartitioner(
    ...                             k=1,
    ...                             targets_attr='chunks',
    ...                             space='partitions')],
    ...                         space='partitions')

hope this helps.
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Research Scientist,            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