<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><span style="FONT-FAMILY: Times New Roman">Hi all, </span><br><span style="FONT-FAMILY: Times New Roman">I m really new to machine learning and have just collected some fMRI data for analysis with PyMVPA.</span></div><span style="FONT-FAMILY: Times New Roman"></span>
<div><br><span style="FONT-FAMILY: Times New Roman">The design is simple. Each participant was asked to complete two tasks. And each task included four similar runs respectively, and each run included two similar </span><span style="FONT-FAMILY: Times New Roman">conditions respectively, and each condition corresponded to 16 different trials respectively. So these two tasks were completely same except the special </span><span style="FONT-FAMILY: Times New Roman">difference in participants' response.</span></div><span style="FONT-FAMILY: Times New Roman"></span>
<div><br><span style="FONT-FAMILY: Times New Roman">Now I want to probe whether the neural mechanisms distinguishing between condition a and condition b of different tasks are same. And I want to train a SVM classifier to discriminate conditions a & b in task 1 and then test it on the independent dataset from the task 2</span><span style="FONT-FAMILY: Times New Roman">.  However, I do not know how to fslmerge my data and to generate the texts of the attributes file to realize this plan. In addition, I do not know how to modify my script to appeal to this plan.</span></div>
<div><span style="FONT-FAMILY: Times New Roman"><strong>My Script:</strong></span></div>
<div><span style="FONT-FAMILY: Times New Roman">import numpy as N<br>import numpy.matlib as M<br>import scipy.io as sio<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</span></div>
<div><span style="FONT-FAMILY: Times New Roman"># inputs<br>NumPerm=10000<br>clf = LinearNuSVMC()<br>LabelFile='my label file.txt'<br>FMRIFile='my fmri nifti file.nii.gz<br>MaskFile='my mask.nii.gz' # <br>MotionParameterFile='my motion parameter file.par' </span></div>
<div><span style="FONT-FAMILY: Times New Roman">attrs = SampleAttributes(LabelFile, literallabels=False)<br>ds = fmri_dataset(samples=FMRIFile, targets=attrs.targets, chunks=attrs.chunks, mask=MaskFile)</span></div>
<div>mc = McFlirtParams(path.join('mvpa', 'data', MotionParameterFile))<br>for param in mc:<br>    ds.sa['mc_' + param] = mc[param]<br>res = poly_detrend(ds, opt_regs=['mc_x', 'mc_y', 'mc_z', 'mc_rot1', 'mc_rot2', 'mc_rot3'])<br>poly_detrend(ds, polyord=1, chunks_attr='chunks')<br>zscore(ds, chunks_attr='chunks')<br>ds = ds[N.array([l in ClassList for l in ds.sa.targets], dtype='bool')]<br>ds=remove_invariant_features(ds)<br>partitioner = NFoldPartitioner()<br>repeater = Repeater(count=NumPerm)<br>permutator = AttributePermutator('targets', limit={'partitions': 1}, count=1)<br>null_cv = CrossValidation(<br>    clf, <br>    ChainNode(<br>        [partitioner, permutator],<br>        space=partitioner.get_space()),<br>    postproc=mean_sample())<br>distr_est = MCNullDist(repeater, tail='left', measure=null_cv, enable_ca=['dist_samples'])<br>cv_mc_corr = CrossValidation(clf,<br>              partitioner,<br>              postproc=mean_sample(),<br>              null_dist=distr_est,<br>              enable_ca=['stats'])<br>error = cv_mc_corr(ds)<br> </div>
<div> </div>
<div>Any advise or pointers would be much appreciated!</div><span style="FONT-FAMILY: Times New Roman"></span>
<div><span style="FONT-FAMILY: Times New Roman">cheers,</span></div>
<p><span style="FONT-FAMILY: Times New Roman">Cai Fei<br></span></p></div><br></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>