<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="LINE-HEIGHT: 1.7; FONT-FAMILY: Arial; COLOR: #000000; FONT-SIZE: 14px">
<div><font face="Times New Roman">Hi all,</font></div>
<div><font face="Times New Roman">I have two tasks including two same conditions in the fMRI experiment. Now I want to train a clf(LinearCSVMC) in task1 and then to classify task2. Similarly, I will also train a clf in task2 then to classify task 2.  I want to achieve and test the signficance of prediction accuracy of both classifiers. My questions in the final.</font></div>
<div><font face="Times New Roman"><span style="FONT-SIZE: 18px"><em><strong>My script:</strong></em></span></font></div>
<div>import npumpy as np<br>from mvpa2.suite import *<br>from mvpa2.mappers.detrend import poly_detrend<br>from mvpa2.datasets.mri import fmri_dataset<br>from mvpa2.datasets.miscfx import remove_invariant_features</div>
<div>data = [0,1,2,3,4,5]<br>for i in data:<br>     #input<br>     clf = LinearCSVMC()<br>     FMRIFile1  = 'data/task1.nii.gz'<br>     FMRIFile2  = 'data/task2.nii.gz'<br>     LabelFile1 = 'attributes/task1.txt'<br>     LabelFile2 = 'attributes/task2.txt'<br>     maskFile   = 'mask/mask.nii.gz' <br>     MotionParameterFile1 = 'headmotion/task1.par' <br>     MotionParameterFile2 = 'headmotion/task2.par' <br> <br>     #load data<br>     attrs1 = SampleAttributes(LabelFile1)<br>     ds1 = fmri_dataset(samples=FMRIFile1, targets=attrs1.targets, chunks=attrs1.chunks, mask = maskFile)<br>     attrs2 = SampleAttributes(LabelFile2)<br>     ds2 = fmri_dataset(samples=FMRIFile2, targets=attrs2.targets, chunks=attrs2.chunks, mask = maskFile)<br>    <br>     # Detrend with motion correction parameter<br>     mc1 = McFlirtParams(MotionParameterFile1)<br>     for param in mc1:<br>          ds1.sa['mc_' + param] = mc1[param]<br>     mc2 = McFlirtParams(MotionParameterFile2)<br>     for param in mc1:<br>          ds2.sa['mc_' + param] = mc2[param]</div>
<div> </div>
<div>     # detrend some dataset with mc params as additonal regressors<br>     res = poly_detrend(ds1, opt_regs=['mc_x', 'mc_y', 'mc_z', 'mc_rot1', 'mc_rot2', 'mc_rot3'])<br>     res = poly_detrend(ds2, opt_regs=['mc_x', 'mc_y', 'mc_z', 'mc_rot1', 'mc_rot2', 'mc_rot3'])</div>
<div> </div>
<div>     # do chunkswise linear detrending on dataset<br>     poly_detrend(ds1, polyord=1, chunks_attr='chunks')<br>     poly_detrend(ds2, polyord=1, chunks_attr='chunks')<br><br>     # do z-score data - zscore dataset relative to baseline ('rest') mean<br>     zscore(ds1, chunks_attr='chunks')</div>
<div>     zscore(ds2, chunks_attr='chunks')<br><br>     # select classes for mvpa analysis<br>     ds1 = ds1[np.array([l%6 == i for l in ds1.sa.time_indices], dtype='bool')]<br>     ds1 = remove_invariant_features(ds1)<br>     ds2 = ds2[np.array([l%6 == i for l in ds2.sa.time_indices], dtype='bool')]<br>     ds2 = remove_invariant_features(ds2) </div>
<div>     </div>
<div>    #do classification<br>     clf.train(ds1)<br>     predictions1 = clf.predict(ds2.samples)<br>     acc1 = np.mean(predictions1 == ds2.sa.targets) </div>
<div>     clf.train(ds2)<br>     predictions2 = clf.predict(ds1.samples)<br>     acc2 = np.mean(predictions2 == ds1.sa.targets)</div>
<div> </div>
<div>
<div><font face="Times New Roman"><span style="FONT-SIZE: 18px"><em><strong>My Questions:</strong></em></span></font><br><span style="FONT-FAMILY: Times New Roman">(1)My frist goal is to train a clf in one task, and then used this clf to identify the other task. Can the script above realise this goal? </span></div>
<div><span style="FONT-FAMILY: Times New Roman">(2)My second is to test the significance of prediction accuracy. So I must fristly estimate the null-distribution using permutation testing for these prediction accuacy. However,<span style="FONT-FAMILY: Times New Roman"> the PyMVPA manual about this thesis is appropriate to estimate the null-distribution under those conditions that there is only one task and train a clf on some runs and then to use this trained clf to predict the remaining run. However, now I have two independent tasks and two independent data. So I can not use the script in the manual directly. However, I am new  to machine learning and do not know how to write the appropriate scirpt. </span>How should I modify and refresh my script to build the null-distribution using permutation testing for the current prediction accuracy? Any advise should be appreciated!<br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>
<style type="text/css">
body{font-size:14px;font-family:arial,verdana,sans-serif;line-height:1.666;padding:0;margin:0;overflow:auto;white-space:normal;word-wrap:break-word;min-height:100px}
td, input, button, select, body{font-family:Helvetica, 'Microsoft Yahei', verdana}
pre {white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}
th,td{font-family:arial,verdana,sans-serif;line-height:1.666}
img{ border:0}
header,footer,section,aside,article,nav,hgroup,figure,figcaption{display:block}
</style>

<style id="ntes_link_color" type="text/css">a,td a{color:#138144}</style>
</span></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>