[pymvpa] array is not broadcastable to correct shape on featureSelect
James Kyle
jameskyle at ucla.edu
Wed May 6 23:12:54 UTC 2009
Greetings,
I'm walking my way through some tutorials to get a feel for the pymvpa
API and flow. I'm not concerned with statistically significant results
yet.
I've modified the comp_smlr_svm.py example script to read in a set of
NiftiImages (some zstats I had laying around).
Everything ticks along nicely until the selectFeatures mask is applied
> newtrainpat = trainpat.selectFeatures(keepInd, sort=False)
At this point I get a an error:
> *** ValueError: array is not broadcastable to correct shape
I'm probably doing something embarrassingly silly as I don't quite
have a good feel for the work flow. Here's a link to the full script: http://pastie.org/470532
And here is some output from the python debugger that shows the shape
of the NiftiDataset, the keepInd mask, etc. The point of confusion for
me is that the keepInd mask is the same shape as each of the ndarrays
in my NiftiDataset.
>
> Evaluating Linear SVM classifier with SMLR's features...
> (/Users/jkyle/Projects/APOE/scripts/comp_smlr_svm.py:101): <module>
> 101 keepInd = (N.abs(smlr.weights).mean(axis=1) != 0)
> (Pydb) p keepInd
> *** NameError: keepInd
> (Pydb) n
> (/Users/jkyle/Projects/APOE/scripts/comp_smlr_svm.py:102): <module>
> 102 print(keepInd.shape)
> (Pydb) p keepInd
> array([False, False, False, ...e, False, False], dtype=bool)
> (Pydb) p trainpat
> <Dataset / float32 18 x 902629 uniq: 1 chunks 2 labels>
> (Pydb) p keepInd
> array([False, False, False, ...e, False, False], dtype=bool)
> (Pydb) keepInd.shape
> (902629,)
> (Pydb) trainpat.selectFeatures(keepInd, sort=False)
> *** ValueError: array is not broadcastable to correct shape
> (Pydb) trainpat
> <Dataset / float32 18 x 902629 uniq: 1 chunks 2 labels>
> (Pydb) trainpat[0]
> <Dataset / float32 1 x 902629 uniq: 1 chunks 1 labels>
> (Pydb) trainpat[0].selectFeatures(keepInd, sort=False)
> *** ValueError: array is not broadcastable to correct shape
> (Pydb) trainpat[0].shape
> *** AttributeError: 'NiftiDataset' object has no attribute 'shape'
> (Pydb) trainpat[0].data.shape
> *** AttributeError: 'NiftiDataset' object has no attribute 'data'
> (Pydb) trainpat[0]
> <Dataset / float32 1 x 902629 uniq: 1 chunks 1 labels>
More information about the Pkg-ExpPsy-PyMVPA
mailing list