[pymvpa] Extracting a part of dataset for a re-selection of voxels in the already selected features

Nick Oosterhof nikolaas.oosterhof at unitn.it
Tue Mar 25 09:24:11 UTC 2014


On Mar 25, 2014, at 2:58 AM, akama.h.aa <akama.h.aa at m.titech.ac.jp> wrote:

> Dear PyMVPA people
> 
> I'd like to extract from a Dataset only a corresponding part of some newly re-selected voxels which should be a subset of (already) selected features.
> Is the following one I've made is good? Or did you already implemented a similar one in the package? (I am not so self-confident)
> 
> def getNewEventDatasetWithOnlyReselectedVoxels(OriginalEventDataset,ReslectedVoxelsIndices):  [...]

Your code may work (I did not see anything wrong in particular), but it can be implemented in an easier and faster fashion.

For example:

def select_subset(ds, reselected_indices):
    ds_indices_tuple=map(tuple, ds.fa.voxel_indices)
    reselected_indices_tuple=map(tuple, reselected_indices)

    ds_keep_indices=[i for i, index in enumerate(ds_indices_tuple)
                    if index in reselected_indices_tuple]
    return ds[:,ds_keep_indices]

I hope that helps.

Nick





More information about the Pkg-ExpPsy-PyMVPA mailing list