[pymvpa] between-subject classification
Anna Manelis
anna.manelis at gmail.com
Tue Sep 26 17:02:00 UTC 2017
Dear PYMVPA experts,
I plan to use PYMVPA to classify 2 groups of subjects (patients and
controls). The inputs are betas that come from the FSL- based analysis
(i.e., cope.nii.gz). I use the SVM classifier in a specific mask on 100
selected features.
Could you please confirm that a short script below is correct:
# copes are taken from /subject/feet/reg_standard/stats/ folder for each
subject. For this example, they were copied to sub001, sub002, etc
folders. There is a total of N=10 subjects (in this example).
# I assume that each subject in a group is a chunk. Is that correct?
##################################
from glob import glob
import os
import numpy as np
from mvpa2.suite import*
labels=['hc','hc','hc','hc','hc','pt','pt','pt','pt','pt']
chunks=[1,2,3,4,5,1,2,3,4,5] # Subject numbering within each group
copes=sorted(glob('/path/to/data/sub0*/cope14.nii.gz')) # Collect file
names
mask_fname="/path/to/data/my_mask.nii.gz"
db=fmri_dataset(copes, targets=labels, chunks=chunks, sprefix=None,
tprefix=None, mask=mask_fname, add_fa=None)
ds_mni = vstack(db)
# Setup classifier - is in the Hyperalignment example
clf = LinearCSVMC()
# feature selection helpers
nf = 100
fselector = FixedNElementTailSelector(nf, tail='upper',
mode='select', sort=False)
sbfs = SensitivityBasedFeatureSelection(OneWayAnova(), fselector,
enable_ca=['sensitivities'])
# create classifier with automatic feature selection
fsclf = FeatureSelectionClassifier(clf, sbfs)
cv = CrossValidation(fsclf,
NFoldPartitioner(),
enable_ca=['stats'])
results = cv(ds_mni)
print results
##################################
Thank you,
Anna.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20170926/77f5f641/attachment.html>
More information about the Pkg-ExpPsy-PyMVPA
mailing list