[pymvpa] Nifti Datasets & Masking

Yaroslav Halchenko debian at onerussian.com
Mon Jul 28 20:23:51 UTC 2008


let me give a quickie answers, but now you could find Michael himself
somewhere near by -- he is at Dartmouth now -- somewhere in Haxby's lab
;-) I guess he would provide much more insights 'online' ;-)


> If I import a NiftiDataset that has a mask applied to it (from AFNI),  
> does this mask persist when I import the data (using NiftiImage from  
> the PyNifti package) and then NiftiDataset in PyMVPA?
To say the truth I am not clear on the workflow here since 'import
NiftiDataset' in python terms is just bringing you the class (thus no
mask is applied or even assigned)


> How is masking  
> actually achieved (i.e. are feature values set to 0 or are they  
> excluded entirely)?
NiftiDataset is a subclass of MaskedDataset, which indeed selects only
those elements which have non-0 value in provided mask. In NiftiDataset
you usually want to provide samples and mask, where they could be 

ndarray

string to point to nifti/analyze files to contain data/mask

or I believe NiftiImage object? (not sure on that one from top of my
hand)


So whenever you creating and instance of NiftiDataset, it actually loads
the data and the mask (if provided, otherwise all voxels are considered
to be in the mask) and selects only those features which are in the mask
(which is already done within parent MaskedDataset class)

> I'm a little concerned since this of course has  
> direct bearing on RFE, etc., if it's not working with the right  
> features to begin with (i.e. doesn't take a priori masking into  
> account).
hm... if it is NiftiDataset and mask was provided, you should be left
only with those (prior to RFE) which were in the mask. you can see if
that is true by dataset.nfeatures which should correspond to number of
features in the mask), also you can feed it with smth like

dataset.map2nifti(dataset.samples).save('/tmp/11.nii.gz')
and then visualize that /tmp/11.nii.gz in your favorite nifti viewer
(e.g. fslview) to see if that is what you wanted really to have there
;-) -- ie it is original volume(s) with only those voxels present which
were in the mask


> Also, what is the easiest way to obtain the SVM weights used to rank  
> features before elimination (i.e. the last snapshot of those weights  
> when feature selection was finished)?
actually there is no way (afaik) to get just the last one ;-) BUT you
can get all of them if you enable state variable

sensitivities

of the RFE. It will store a list of all sensitivities -- 1 per each
step. Hopefully you have sufficient amount of RAM to store them all. and
then 

rfe.sensitivities[-1] should be the one you were looking for I guess ;-)

> I'd like to be able to rank the  
> voxels selected in order of their importance for determining the  
> classification boundary.

FWIW there is a RankOrder and ReverseRankOrder transformers so you could
easily rank order features by their sensitivities (instead of working on
pure sensitivity). For RFE RankOrder I guess should provide the same result if you
eliminate by the percentage of most active voxels (you might need to
combine transformer with Absolute which I guess you've used for the
sensitivity for RFE though via 
transformer=lambda *args:RankOrder(Absolute(*args))
instead of pure
transformer=Absolute()

> Thanks for any insights --

> James.

> _______________________________________________
> Pkg-ExpPsy-PyMVPA mailing list
> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa


-- 
Yaroslav Halchenko
Research Assistant, Psychology Department, Rutgers-Newark
Student  Ph.D. @ CS Dept. NJIT
Office: (973) 353-5440x263 | FWD: 82823 | Fax: (973) 353-1171
        101 Warren Str, Smith Hall, Rm 4-105, Newark NJ 07102
WWW:     http://www.linkedin.com/in/yarik        



More information about the Pkg-ExpPsy-PyMVPA mailing list