[pymvpa] Dataset with multidimensional feature vector per voxel

Ulrike Kuhl kuhl at cbs.mpg.de
Thu Nov 5 14:08:40 UTC 2015


Dear Yaroslav,

thanks a lot for your reply.

With your snipped it was really easy for me to set up the matrix as you described it. :-)
For those interested, this is the code that works for me:

####################################
sub_list = [list of subjects]
param_list = [list of parameters]
dss = []

for sub_index, sub in enumerate(sub_list):
    for suf_index, suf in enumerate(param_list):
        ds = fmri_dataset('/path/to/image/file',mask='/path/to/mask/file')
        ds.fa['modality'] = [suf] * ds.nfeatures             # for each feature, set the modality attribute
        ds.fa['modality_index'] = [suf_index] * ds.nfeatures # this as numeric might come handy for searchlights later
    if sub.startswith('L'):
        learn = 1
    elif sub.startswith('N'):
        learn = 0
        ds.sa['targets'] = [learn]                           
        ds.sa['chunks'] = [sub_index]
        dss.append(ds)
dsall = hstack(dss)

####################################

As expected, 'dsall' is a numpy.ndarray of dimensions 


----- Original Message -----
From: "Yaroslav Halchenko" <debian at onerussian.com>
To: "pkg-exppsy-pymvpa" <pkg-exppsy-pymvpa at lists.alioth.debian.org>
Sent: Wednesday, 4 November, 2015 17:27:51
Subject: Re: [pymvpa] Dataset with multidimensional feature vector per voxel

On Wed, 04 Nov 2015, Ulrike Kuhl wrote:

> Dear PyMVPA experts,

> first of all: thank you so much for the great work on providing such a nice and handy toolbox!

thank you for the thank you!

> I started working with PyMVPA less than a week ago and while the tutorial provides a great overview on how to set up one's fMRI data, I am kind of stuck on how to proceed with my structural data.

> What's my story?
> I plan to perform an MVPA analysis on structural MRI data. To be exact, I have several maps of parameters derived from diffusion weighted MRI per subject, like fractional anisotropy (FA), mean diffusivity (MD) and the like. Eventually I want to train a classifier on the combination of these parameters per voxel in order to see which voxels (using a searchlight approach) predict best whether the corresponding subject belongs to group A or group B (groups derived based on behavioural measure).

> I would like to set up my data in the following way:

> * one sample = one participant
> * features per sample = 2D-data of the form: numberOfVoxels X numberOfDiffusionDerivedParameters

> That is, for each voxel that is encoded in the feature dimension, I want a vector containing the respective diffusion-derived parameters for that voxel.

> What's the best way to set up data this way using PyMVPA? 
> Is it even possible to do it and then train a classifier on this parameter-vector instead single voxel values?

Sure!

I would say that the easiest way is to hstack those together so you
still have subject x features  2d matrix, but where per each feature you
would have some descriptor on what is the "modality" of that value. e.g.
smth like (just typing, might not work as is)

dss = []
for suf_index, suf in enumerate(('anat', 'fa', 'md')):
  ds = fmri_dataset('file_%s.nii.gz' % suf, mask='mask.nii.gz')
  ds.fa['modality'] = suf
  ds.fa['modality_index'] = suf_index  # this as numeric might come handy for searchlights later
  dss.append(ds)
dsall = hstack(dss)

then you would have all the information  you need to later on even do a
searchlight across the brain while picking up all modalities for that
voxel (would need a bit more of glue though... if interested -- will
show whenever you get the basic code running)

Cheers,

-- 
Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        

_______________________________________________
Pkg-ExpPsy-PyMVPA mailing list
Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa
-- 
Max Planck Institute for Human Cognitive and Brain Sciences 
Department of Neuropsychology (A219) 
Stephanstraße 1a 
04103 Leipzig 

Phone: +49 (0) 341 9940 2625 
Mail: kuhl at cbs.mpg.de 
Internet: http://www.cbs.mpg.de/staff/kuhl-12160



More information about the Pkg-ExpPsy-PyMVPA mailing list