[pymvpa] NFoldPartitioner

lasse.gueldener at gmail.com lasse.gueldener at gmail.com
Mon Mar 25 19:22:22 GMT 2019


Hi Yaroslav,

the snippet of code you posted works perfectly. Thanks a lot! 


Regards

Lasse 
>> On Wed, 20 Mar 2019, lasse.gueldener at gmail.com wrote:
>> 
>> Hi Folks,
> 
>> I’am quite new to pymvpa and am currently trying to implement searchlight analysis on group level. I ran an fMRI study where subjects had to discriminate the orientation (vertical versus non-Vertical) of a masked stimulus and rate their subjective awareness of the orientation (1-4 scale). So the targets/classes to be decoded are the orientations. However, I want to know whether orientation information persists on unaware trials.  So far I‘ve been able to run the analysis with an NFoldPartitioner  on a dataset that contains unaware trials only, but i actually want to train the classifier on all trials (awareness 1-4) in run 1-9 and test it on the tenth run only on unaware trials (awareness 1) in a leave-one-out fashion. So (I think) the crucial part that troubles me right now is to adjust the partitioner. I‘ve been looking at the sifter and the factorial partitioner documentation, but am still not sure about the implementation in such a case.
> 
> 
>    In [6]: FactorialPartitioner?
>    Init signature: FactorialPartitioner(cls, *args, **kwargs)
>    Docstring:     
>    Partitioner for two-level factorial designs
> 
>    Given another partitioner on a dataset containing two attributes that are
>    organized in a hierarchy, it generates balanced folds of the super-ordinate
>    category that are also balanced according to the sub-ordinate category.
> 
>    Example
>    --------
>    We show images of faces to the subjects. Subjects are familiar to some
>    identities, and unfamiliar to others. Thus, we have one super-ordinate
>    attribute "familiarity", and one sub-ordinate attribute "identity". We want
>    to cross-validate familiarity across identities, that is, we train on the
>    same number of familiar and unfamiliar identities, and we test on the
>    left-over identities.
> 
>    >>> partitioner = FactorialPartitioner(NFoldPartitioner(attr='identity'),
>    ...                                    attr='familiarity')
> 
> 
> so I think you need
>    
>    >>> partitioner1 = FactorialPartitioner(NFoldPartitioner(attr='chunks'),
>    ...                                    attr='awareness')
> 
> which should then do both aware -> unaware  and  unaware -> aware.  You can
> indeed combine with Sifter to just choose one if really desired (adjusting
> again from cut/pasted docs, so YMMV ;) )
> 
>>>> par = ChainNode([partitioner1,
>    ...                  Sifter([('partitions', 2),  # testing partition
>    ...                          ('awareness', ['unaware'])])
>    ...                 ], space='partitions')
> 
> for CVing into unaware condition, assuming that  you have sample
> attributes awareness with values 'unaware' and 'aware' (I would advise to not
> code them up into ints, but be explicit for readability etc)
> 
>> I appreciate any comment or suggestion.
> 
> Hope above helps
> 
> -- 
> Yaroslav O. Halchenko
> Center for Open Neuroscience     http://centerforopenneuroscience.org
> 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