[pymvpa] selecting features by mask
Michael Hanke
michael.hanke at gmail.com
Fri Aug 28 00:09:50 UTC 2009
Hi,
On Thu, Aug 27, 2009 at 07:22:03PM -0400, John Clithero wrote:
> Hi all,
>
> Another relatively simple question (I think).
> I can load/create a dataset as follows:
>
> dataset_wb = NiftiDataset((wb_file),
> labels=attr.labels,
> chunks=attr.chunks,
> mask=os.path.join(roidir,'wb.nii.gz'))
>
> And then, after this, I want to use SelectFeatures based on a mask I
> have to run some additional classifiers on a subset of the features
> using a new mask, say:
>
> roi_mask=os.path.join(roidir,'vmpfc.nii.gz')
>
> It is advantageous for me to create the dataset_wb as wholebrain using
> the 'wb.nii.gz' mask and then after analyses, use this other mask on
> the dataset (I want to detrend etc. at the whole-brain, not the ROI
> level).
> It seems like something that used to exist,
> "selectFeaturesByMask(mask, plain=False)"
> would have been perfect for this. It seems that now, based on a post
> earlier, a list of Ids from my roi_mask is needed for selectFeatures.
>
> My question then, is given all of my fMRI data are in the same 3D
> space (or, each timepoint is in the same 3D space as my masks), there
> must be some way to use getOutId to get a list of Ids (say, Z) from
> roi_mask to plug into
>
> new_dataset_roi=dataset_wb.selectFeatures(Z).
Congrats, you fell into a pit we digged out for construction works and
never closed ;-)
The quickest way for you is probably to take a look at
MaskedDataset.selectFeaturesByMask(). That is a 3-liner that should to
what you need. It should be relatively straightforward to apply that to
any NiftiDataset without having to subclass it.
HTH,
Michael
--
GPG key: 1024D/3144BE0F Michael Hanke
http://apsy.gse.uni-magdeburg.de/hanke
More information about the Pkg-ExpPsy-PyMVPA
mailing list