Cross-validated RSA with pyMVPA (what am I doing wrong?)

I’m hoping someone can help me troubleshoot this code. As might be obvious from my previous pyMVPA post, I’m a pyMVPA novice, and my basic sanity check is failing.

What I’m trying to do – Given 4 runs with 4 conditions, I’d like to create a cross-validated Euclidean DSM.

The sanity check – I’d expect the distance between the identical conditions (the “diagonal” to be the smallest)

Implementation:
cds = fmri_dataset(samples=
[’/om/group/saxelab/RSAtest/data/EMO/sub-SAXEEMOfd28_run1_cgd_cope.nii.gz’,
…snip…
‘/om/group/saxelab/RSAtest/data/EMO/sub-SAXEEMOfd28_run3_tgn_cope.nii.gz’,
‘/om/group/saxelab/RSAtest/data/EMO/sub-SAXEEMOfd28_run4_tgn_cope.nii.gz’],
targets=[‘cgd’,‘cgd’,‘cgd’,‘cgd’,‘cgf’,‘cgf’,‘cgf’,‘cgf’,‘cgn’,‘cgn’,‘cgn’,‘cgn’,
‘tgn’,‘tgn’,‘tgn’,‘tgn’],
mask=’/om3/group/saxelab/EMOfd/ROI_MASKS/disgust_meta_190611_C05_1k_ALE.nii’)

cds.sa[‘oddeven’] = [‘odd’,‘even’,‘odd’,‘even’,‘odd’,‘even’,‘odd’,‘even’,
‘odd’,‘even’,‘odd’,‘even’,‘odd’,‘even’,‘odd’,‘even’]

cds_split1 = cds[cds.sa.oddeven == ‘odd’]
cds_split2 = cds[cds.sa.oddeven == ‘even’]

dsm = rsa.CDist(pairwise_metric = ‘Euclidean’)
dsm.train(cds_split1)
cres = dsm(cds_split2)

The problem: The smallest distances are not, in fact, along the diagonal.

Thoughts? It’s possible the first-level model was wrong, but since this is the piece I’m least familiar with, I thought I’d start here.

Thanks!
Todd

Hi @toddt!

this thread is a bit dated, but I still wanted to ask if you managed to solve your problem? I have a similar problem, where I can’t get CDist to work with searchlight.

Best,
Johannes