[pymvpa] dataset.selectFeatures again
Susanne Greiner
susanne.greiner at gmail.com
Fri Mar 27 14:22:19 UTC 2009
Dear all,
just a short syntax question: why is it not possible to select Samples
and Features the same way when using nifti datasets? In my opinion
someone new to pyMVPA who has a look at the example files gets across
the dataset.selectSamples function. This function is used in almost all
examples with a boolean N.array and looks very intuitive.
Why can't selecting features with boolean arguments be easy in exactly
the same way? If you try it with a Dataset, it works fine, but when
using a MappedDataset the analogon does not work any more :-( and the
''array is not broadcastable to correct shape''
Is that really wanted (or needed for some reason)?
code showing the precise problem below,
lg
Susanne
-------------------------------
from mvpa.suite import *
import numpy as N
# load PyMVPA example dataset or any other NiftiDataset
#
attr = SampleAttributes('data/attributes.txt')
dataset = NiftiDataset(samples='data/bold.nii.gz',
labels=attr.labels,
chunks=attr.chunks,
mask='data/mask.nii.gz')
# only considering 10 samples and 10 features
dataset = dataset.selectSamples(range(10))
dataset = dataset.selectFeatures(range(10))
# this works
dataset =
dataset.selectSamples(N.array([True,False,True,False,False,True,False,True,False,False],dtype='bool'))
# this does not work but produces: array is not broadcastable to correct
shape
dataset =
dataset.selectFeatures(N.array([True,False,True,False,False,True,False,True,False,False],dtype='bool'))
# this works and intuitivly the line above should do the same thing or
why not
#dataset = dataset.selectFeatures([0,2,5,7])
# this works but the dataset is not mapped any more :-(
#dataset =
dataset.selectFeatures(N.array([True,False,True,False,False,True,False,True,False,False],dtype='bool'),plain=True)
# this works and everything is fine, but it seems not very straight
forward to me
#dataset =
dataset.selectFeatures(where(N.array([True,False,True,False,False,True,False,True,False,False],dtype='bool'))[0])
More information about the Pkg-ExpPsy-PyMVPA
mailing list