[pymvpa] Searchlight / feature selection crash
Johan Carlin
jdc55 at cam.ac.uk
Wed Sep 2 11:00:07 UTC 2009
Hi guys,
I keep getting a strange crash with my searchlight analysis. This only seems
to happen for certain subjects out of a large sample, and only happens when
I combine the searchlight with sensitivity-based feature selection. The
searchlight starts to run, and then crashes with:
TypeError Traceback (most recent call last)
/imaging/jc01/Becky01/MVPA/B01_MVPA.py in <module>()
121 print 'run finished without errors.'
122 except: print 'run finished with some errors.
Re-run?'
--> 123 else: map(sl_run,tasklist)
124
125
/imaging/jc01/UtilityScripts/Python/JohansMVPA.py in sl_run(T)
1078 print 'running %s' % T['out']
1079 set_trace()
-> 1080 sl_map = sl(ds)
1081 # 1-(1/nconds) - error
1082 sl_map_r = [(1.-(1./len(T['conds']))) - i for i in sl_map] #
chance = 0
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/measures/base.pyc
in __call__(self, dataset)
103
104
--> 105
106
107
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/measures/searchlight.pyc
in _call(self, dataset)
106
107
--> 108
109
110
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/measures/base.pyc
in __call__(self, dataset)
103
104
--> 105
106
107
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/algorithms/cvtranserror.pyc
in _call(self, dataset)
171
172
--> 173
174
175
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/clfs/transerror.pyc
in __call__(self, testdataset, trainingdataset)
1281
1282
-> 1283
1284
1285
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/clfs/transerror.pyc
in _precall(self, testdataset, trainingdataset)
1237
1238
-> 1239
1240
1241
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/clfs/base.pyc
in train(self, dataset) 352
353
--> 354
355
356
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/clfs/meta.pyc
in _train(self, dataset)
1056
1057
-> 1058
1059
1060
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/featsel/base.pyc
in __call__(self, dataset, testdataset)
106
107
--> 108
109
110
/imaging/jc01/PythonInstall/lib/python2.5/site-packages/mvpa/featsel/helpers.pyc
in __call__(self, seq)
400
401
--> 402
403
404
TypeError: object of type 'numpy.float64' has no len()
WARNING: Failure executing file: <B01_MVPA.py>
----
These empty code snippets are a bit hard to decipher. :) Relevant bits of
code:
# Configure classifier, crossvalidation, searchlight
clfcmd = eval(T['clf']+'()') # CSVMC
if T['FS']:
clfcmd = FeatureSelectionClassifier(clfcmd,
SensitivityBasedFeatureSelection(
clfcmd.getSensitivityAnalyzer(transformer=abs),
FixedNElementTailSelector(T['FS_limit'],
mode='select',tail='upper'))) # select 50 features
cv = CrossValidatedTransferError(TransferError(clfcmd),
NFoldSplitter(), #OddEvenSplitter(),
enable_states = ['results'])
sl = Searchlight(cv,radius=T['radius']) # 10 mm
# Rescore labels
new_labels = []
for l in T['labels']:
if not l in T['conds']: new_labels.append(0.5)
else: new_labels.append(l)
# Load data
ds = NiftiDataset(samples=T['sub4D'],
labels=new_labels,
chunks=T['chunks'],
mask=T['submask'])
# Remove irrelevant labels
zerocheck = array([v != 0.5 for v in new_labels],dtype='bool')
ds = ds.selectSamples(zerocheck)
# Preprocessing
ds = removeInvariantFeatures(ds)
zscore(ds,perchunk=False)
# Run, rescale, and save
print 'running %s' % T['out']
#set_trace()
sl_map = sl(ds)
--------
For the analysis that crashes, the dataset looks like this:
ds
Out[87]: <Dataset / float32 8 x 21583 uniq: 4 chunks 2 labels>
(Pdb) ds.C
Out[87]: array([ 1., 2., 3., 4., 1., 2., 3., 4.])
(Pdb) ds.L
Out[87]: array([ 60., 60., 60., 60., 300., 300., 300., 300.])
(Pdb) shape(ds.S)
Out[87]: (8, 21583)
-------
Once again, the exact same classification problem works fine for all other
subjects. I assume the problem comes in with feature selection because a
previous run without it finished with no errors.
I'm a bit stumped by this. Let me know if anyone has any ideas!
Johan
--
Johan Carlin
Graduate Student
MRC Cognition & Brain Sciences Unit
15 Chaucer Road
Cambridge CB2 7EF
UK
johan.carlin at mrc-cbu.cam.ac.uk
+44 (0)1223 355294 ext 593
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20090902/41716f70/attachment.htm>
More information about the Pkg-ExpPsy-PyMVPA
mailing list