[pymvpa] how to fslmerge data and generate attributes file

cfygj cfygj at 126.com
Sat Aug 23 14:27:54 UTC 2014


Hi all,
I m really new to machine learning and have just collected some fMRI data for analysis with PyMVPA.

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 conditions respectively, and each condition corresponded to 16 different trials respectively. So these two tasks were completely same except the special difference in participants' response.

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.  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.
My Script:
import numpy as N
import numpy.matlib as M
import scipy.io as sio
from mvpa2.suite import *
from mvpa2.mappers.detrend import poly_detrend
from mvpa2.datasets.mri import fmri_dataset
from mvpa2.datasets.miscfx import remove_invariant_features
# inputs
NumPerm=10000
clf = LinearNuSVMC()
LabelFile='my label file.txt'
FMRIFile='my fmri nifti file.nii.gz
MaskFile='my mask.nii.gz' #
MotionParameterFile='my motion parameter file.par'
attrs = SampleAttributes(LabelFile, literallabels=False)
ds = fmri_dataset(samples=FMRIFile, targets=attrs.targets, chunks=attrs.chunks, mask=MaskFile)
mc = McFlirtParams(path.join('mvpa', 'data', MotionParameterFile))
for param in mc:
    ds.sa['mc_' + param] = mc[param]
res = poly_detrend(ds, opt_regs=['mc_x', 'mc_y', 'mc_z', 'mc_rot1', 'mc_rot2', 'mc_rot3'])
poly_detrend(ds, polyord=1, chunks_attr='chunks')
zscore(ds, chunks_attr='chunks')
ds = ds[N.array([l in ClassList for l in ds.sa.targets], dtype='bool')]
ds=remove_invariant_features(ds)
partitioner = NFoldPartitioner()
repeater = Repeater(count=NumPerm)
permutator = AttributePermutator('targets', limit={'partitions': 1}, count=1)
null_cv = CrossValidation(
    clf,
    ChainNode(
        [partitioner, permutator],
        space=partitioner.get_space()),
    postproc=mean_sample())
distr_est = MCNullDist(repeater, tail='left', measure=null_cv, enable_ca=['dist_samples'])
cv_mc_corr = CrossValidation(clf,
              partitioner,
              postproc=mean_sample(),
              null_dist=distr_est,
              enable_ca=['stats'])
error = cv_mc_corr(ds)
 
 
Any advise or pointers would be much appreciated!
cheers,

Cai Fei



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20140823/e825203d/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list