<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><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(ds, polyord=1, chunks_attr='chunks')<br> <br> # do z-score data - zscore dataset relative to baseline ('rest') mean<br> zscore(ds, chunks_attr='chunks')<br> <br> # select classes for mvpa analysis<br> ds1 = ds[N.array([l%6 == i for l in ds1.sa.time_indices], dtype='bool')]<br> ds1 = remove_invariant_features(ds1)<br> ds2 = ds[N.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. How should I modify and refresh my script to build the null-distribution using permutation testing for these prediction accuracy?</span></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>