[pymvpa] SampleGroupMapper question

Matthias Ekman Matthias.Ekman at nf.mpg.de
Tue Jun 30 12:06:49 UTC 2009


Hi,

may be you could help me with this issue: For some reasons I want to 
apply a mapper to my dataset which yields to one sample of each label 
per chunk. As explained in the FAQs this could be easily performed with 
the SampleGroupMapper:

# load dataset
attr = SampleAttributes(os.path.join(pymvpa_dataroot, 'attributes.txt'))
dataset = NiftiDataset(samples=os.path.join(pymvpa_dataroot, 'bold.nii.gz'),
                       labels=attr.labels,
                       chunks=attr.chunks,
                       mask=os.path.join(pymvpa_dataroot, 'mask.nii.gz'))


from mvpa.mappers.samplegroup import SampleGroupMapper
from mvpa.misc.transformers import FirstAxisMean

m = SampleGroupMapper(fx=FirstAxisMean)
mapped_data = ds.applyMapper(samplesmapper=m)


Its also possible to save the mapped Data like this:

m_img = ds.map2Nifti(mapped_data)
m_img.save(os.path.join(pymvpa_dataroot, 'bold_samples_mapped.nii'))


So far so good :-) Is it also possible to apply the same mapping to the 
SamplesAttributes? Something like:

mapped_attr = attr.applyMapper(samplesmapper=m)

I just want a new txt-file with the corresponding (mapped) attributes. 
If nothing like this exists, it should be very easy to recode my 
existing attributes file externally (bash, python whatever)... but... I 
was not able to find out how the mapper works internally. Especially 
what the the 'new sample' order looks like. Is it depending on the first 
appearance of a sample in each chunk?


e.g.

Sample    Chunk
cat    1
cat    1
cat    1
dog    1
dog    1
dog    1
face    1    
face    1
dog    2
dog    2
dog    2
face 2
face 2
face 2
. .
. .
. .

would be (after mapping)
Sample    Chunk
cat    1
dog    1
face    1    
dog    2
face 2

Would be very nice to hear your opinion on the following questions:
Would you perform the detrending before or after mapping?
The samplemapping really improves my decoding accuracy very much. I 
assume this is because of noise reduction? Could you think of another 
reason which might be not intended?

I really appreciate your help.

Bests,
Matthias




More information about the Pkg-ExpPsy-PyMVPA mailing list