[pymvpa] Masking a dataset after loading it

Yaroslav Halchenko debian at onerussian.com
Thu Aug 20 18:51:42 UTC 2009

> I'm trying to apply a mask to a dataset after loading it - this is
> useful for an ROI analysis where I don't want in-script ROI definition
> to fail because the centre voxel has ended up outside the mask... So
so, you just need a dataset consisting of features around some voxel,
and if some features are outside of the global mask (brain) then you
don't want to have them (ie have lower number of features), right?

that is exactly what searchlight relies upon, so functionality is
readily available for any mapped dataset where mapper had distance
metric assigned (which is the case of NiftiDataset)

so, to get dataset consisting only of voxels in sphere around some other
voxel/feature, you should just use piece which is in searchlight code:

            sphere = dataset.selectFeatures(
                dataset.mapper.getNeighbors(f, self.__radius),
where f is the index of the feature around which you want to take sphere...

for any particular voxel coordinates you can use

dataset.mapper.getOutId(voxel_coord) to get id of the feature

or did I miss the question?

 also why do you want to invert the mapping with

>     lmap = dict(zip(ds.labels_map.values(),ds.labels_map.keys()))
whenever creating a new dataset? (may be I got confused...)

> There are 2 problems here: 1) I lose the ability to map2Nifti, should
> I ever want to,

yeah -- to have that feature you need to talk to NiftiDataset (not just a
generic MaskedDataset)

in your code instead of MaskedDataset you could use NiftiDataset where
samples... but before getting in details lets first figure out if above snippet
was what you were looking for

=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]

More information about the Pkg-ExpPsy-PyMVPA mailing list