<p>Hi Yaroslav,</p><p>Thank you very much for your extremely helpful and detailed response to my questions!</p><p>Best regards,</p><p>Bin Liu</p><div id="origbody"><div style="background: #f2f2f2;">----- 原始邮件 -----<br>发件人:Yaroslav Halchenko <debian@onerussian.com><br>收件人:pkg-exppsy-pymvpa <pkg-exppsy-pymvpa@lists.alioth.debian.org><br>主题:Re: [pymvpa] 回复:Re:  pymvpa help<br>日期:2016年02月16日 10点41分<br></div><br><br>On Tue, 16 Feb 2016, ibinliu@sina.com wrote:<br>>    ''how many tries for each of those 2 conditions do you have?<br>>    how many subjects do you have?''<br>>    There are 30 trials for each condition and I have 48 subjects.<br>>    ''what was design (block or even-related, ISI, randomized how)?''<br>>    It was a variable-ISI ranging from 4-6 sec event-related<br>>    design experiments. <br>ok, so no block design and if your designs were randomized across subjects then<br>may be it could all still be kosher ;-)  If they weren't randomized -- I<br>wouldn't trust results a bit...<br>>    ''is that bold.nii.gz already those beta maps or original data?''<br>>    Yes, the bold.nii.gz is already the beta maps. <br>>    How could I set the partitioner for 5 fold or leave one out cross-validation?<br>leave one out -- simple, just assign each sample into individual<br>'chunk':<br>ds.sa['chunks'] = np.arange(len(ds))<br>if ds is your dataset.  Then note that you shouldn't zscore within<br>chunks, so do<br>zscore(ds, chunks_attr=None)<br>when normalizing your data.   And then use regular NFoldPartitioner(1)<br>The caveat I would expect, unlikely since you have 30 trials per each<br>category but still possible in some cases, that then classifier might<br>still learn the 'majority' class (since you would have 1 class with 29<br>samples and the other  with 30) leading to strong<br>'anti-classifications'.  Thus you might prefer to do as below for 5 fold<br>but with '30-fold'<br>5 fold:  since you have 30 divisible by 5, you can indeed get balanced<br>groups of trials.  The most logical would be to group all of your 30<br>trials per each category into 5 chunks, 6 samples each, i.e. something<br>like below (I also generated dummy dataset which would mimic yours)<br>In [10]: ds = mv.Dataset(np.arange(60), sa=dict(targets=np.repeat([1,2], 30), chunks=np.arange(60)))<br>In [11]: for t in ds.UT: ds.chunks[ds.T == t] = np.repeat(np.arange(5), 6)<br>In [12]: print ds.summary()<br>Dataset: 60x1@int64, <sa: chunks,targets><br>stats: mean=29.5 std=17.3181 var=299.917 min=0 max=59<br>Counts of targets in each chunk:<br>  chunks\targets  1   2<br>                 --- ---<br>        0         6   6<br>        1         6   6<br>        2         6   6<br>        3         6   6<br>        4         6   6<br>Summary for targets across chunks<br>  targets mean std min max #chunks<br>    1       6   0   6   6     5<br>    2       6   0   6   6     5<br>Summary for chunks across targets<br>  chunks mean std min max #targets<br>    0      6   0   6   6      2<br>    1      6   0   6   6      2<br>    2      6   0   6   6      2<br>    3      6   0   6   6      2<br>    4      6   0   6   6      2<br>Sequence statistics for 60 entries from set [1, 2]<br>Counter-balance table for orders up to 2:<br>Targets/Order O1     |  O2     |<br>      1:      29  1  |  28  2  |<br>      2:       0 29  |   0 28  |<br>Correlations: min=-1 max=0.93 mean=-0.017 sum(abs)=29<br>so just check your ds.summary()  if everything is balanced alright.  And then,<br>again, just use NFoldPartitioner(1), so it will first take out samples of one<br>chunk, than another, etc.<br>You could have also done 5 fold using NFoldPartitioner(6*2) + Sifter  to cross<br>validate across all possible combinations of 6 samples out for each of the 2<br>categories, but I don't think that you need such a hassle ;)<br>-- <br>Yaroslav O. Halchenko<br>Center for Open Neuroscience     http://centerforopenneuroscience.org<br>Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755<br>Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419<br>WWW:   http://www.linkedin.com/in/yarik        <br>_______________________________________________<br>Pkg-ExpPsy-PyMVPA mailing list<br>Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org<br>http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa<br></div>