[pymvpa] Found the problem (hopefully): suspicious results

Nynke van der Laan nynkevanderlaan at gmail.com
Wed Mar 2 12:51:46 UTC 2011


Dear Michael,
this is the last part of the script which does the actual analysis and
stores it into niftimaps: An additional thing possibly relevant to
mention is that reversemapping to img/hdr gives different results
compared to reversemapping to img/hdr (i.e., with img/hdr the
resulting map does not fit on the initial data/map because it's
shifted in 3d-space while with the reversemapped results to .nii it
fits exactly with the mask I used during importing the data (with
NiftiDataset).

Code:

"""Now it only takes three lines for a searchlight analysis."""

# setup measure to be computed in each sphere (cross-validated
# generalization error on odd/even splits)
print "Setting up analysis"
cv = CrossValidatedTransferError(
         TransferError(LinearNuSVMC()),
         OddEvenSplitter())

# setup searchlight with 1 mm radius and measure configured above
sl = Searchlight(cv, radius=1)


# run searchlight on dataset
print "Performing searchlight analysis"
sl_map = sl(dataset)

print 'Best performing sphere error:', min(sl_map)

orig_sl_map = dataset.mapReverse(N.array(sl_map))
masked_orig_sl_map = N.ma.masked_array(orig_sl_map,
                                           mask=orig_sl_map == 0)

# Save errormap
dataset.map2Nifti(sl_map).save('/home/brain/host/foodchoice/results/exp11_searchlight_testscript/error_wholebrain_'
+  pp + '.nii.gz')

# Calculate and save accuracymap (both as nifti as img/hdr file (for
subsequent spm analysis))
sl_map_accuracy = [1-x for x in sl_map]
dataset.map2Nifti(sl_map_accuracy).save('/home/brain/host/foodchoice/results/exp11_searchlight_testscript/accuracy_wholebrain_'
+ pp + '.nii.gz')
dataset.map2Nifti(sl_map_accuracy).save('/home/brain/host/foodchoice/results/exp11_searchlight_testscript/accuracy_wholebrain_'
+ pp + '.img', filetype = 'ANALYZE')



More information about the Pkg-ExpPsy-PyMVPA mailing list