[pymvpa] RSA - PDistTargetSimilarity

Charlotte Murphy cem552 at york.ac.uk
Tue May 26 09:48:40 UTC 2015

Dear PyMVPA experts,

I am trying to run RSA in a searchlight, where I want to use
PDistTargetSimilarity() to see where in the brain dissimilarity structures
are similar to a predefined model. However, I am having difficulty creating
a model dissimilarity structure that is the correct size to call into this

I have six experimental conditions. The 6x6 dissimilarity model I want to
feed into this analysis looks like this:

from mvpa2.tutorial_suite import *
input_model =
labels = ['SA', 'SV', 'SN', 'WA', 'WV', 'WN']
def plot_mtx(mtx, label, title):
    pl.imshow(mtx, interpolation='nearest')
    pl.xticks(range((len(mtx))),label, rotation=-45)
    pl.yticks(range(len(mtx)), label)
plot_mtx(input_model, labels, 'Input modality model')

#### Relevant code ######

# Load in dataset
ds = fmri_dataset(samples = samples, mask = mask, chunks = sa['chunks'],
targets = sa['targets'])
ds = remove_invariant_features(ds)

# mean condition samples
from mvpa2.mappers.fx import mean_group_sample
mtgs = mean_group_sample(['targets'])
mtds = mtgs(ds)

# dissimilarity matrix done in searchlight form
from mvpa2.measures.searchlight import sphere_searchlight
dsm = rsa.PDist(square=False)
sl = sphere_searchlight(dsm,3)
slres = sl(mtds)

# Use PDistTargetSimilarity to see where in the brain we find dissimilarity
structures similar to the predefined model
tdsm = rsa.PDistTargetSimilarity(input_model)
#using a searchlight
from mvpa2.base.learner import ChainLearner
from mvpa2.mappers.shape import TransposeMapper
sl_tdsm = sphere_searchlight(ChainLearner([tdsm, TransposeMapper()]),2)
slres_tdsm = sl_tdsm(mtds)

###### Error message ######
ValueError: operands could not be broadcast together with shapes (15) (6,6)

I realise this is because I have a vector vs. 6x6 matrix. I assume I need
to create a vector that reflects the off diagonal dissimilarity structure
for my input_model? If so, is there a simple way to do this? If this is not
the correct answer, how do I create a compatible model?

Thanks in advance,

Charlotte Murphy
PhD Student
Department of Psychology
University of York,
Heslington, York, YO10 5DD, UK
Email: cem552 at york.ac.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20150526/60f38a07/attachment.html>

More information about the Pkg-ExpPsy-PyMVPA mailing list