[pymvpa] ANOVA sensitivity map

Anaelia Ovalle anaeliaovalle at gmail.com
Wed Mar 29 08:51:05 UTC 2017

Hello folks!

I'd like to view some sensitivities using ANOVA and am having some issues
with output. I keep getting:

'TypeError: Invalid dimensions for image data'

This is the code I am using (taken from the sensitivity measure
example script: http://www.pymvpa.org/examples/sensanas.html). I
tweaked it to just use the OneWayAnova analyzer and my dataset (which
is a concatenated dataset of 10 chunks, verified that it's properly
built using vstack) of shape 1900 x 180708. Once I run Anova and view
the dimensions of the result, orig_smap's shape is then (180708,).

>From the stacktrace, I know the error is coming from pl.imshow....

Any ideas/suggestions as to how to figure this out would be great, thank you!


fig = 0
pl.figure(figsize=(14, 8))

sana = OneWayAnova(postproc=absolute_features())

# tell which one we are doing
print "Running %s ..." % (sana)

# compute sensitivies
sens = sana(dataset)

smap = sens.samples[0] + 0.00001

# map sensitivity map into original dataspace
orig_smap = dataset.mapper.reverse1(smap)

print 'map: ',  orig_smap
print 'shape: ', orig_smap.shape

masked_orig_smap = np.ma.masked_array(orig_smap, mask=orig_smap == 0)

print 'map: ', masked_orig_smap
print 'shape: ', masked_orig_smap.shape

# make a new subplot for each classifier
fig += 1
pl.subplot(3, 3, fig)


print masked_orig_smap[..., 0].T

pl.imshow(masked_orig_smap[..., 0].T,

# uniform scaling per base sensitivity analyzer
## if s.count('ANOVA'):
##     pl.clim(0, 30)
## elif s.count('SVM'):
##     pl.clim(0, 0.055)
## else:
##     pass


Stack trace:

                                Traceback (most recent call
last)<ipython-input-74-42f45537efc9> in <module>()     34
interpolation='nearest',     35          aspect=1.25,---> 36
cmap=pl.cm.autumn)     37      38 # uniform scaling per base
sensitivity analyzer
.../lib/python2.7/site-packages/matplotlib/pyplot.pyc in imshow(X,
cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent,
shape, filternorm, filterrad, imlim, resample, url, hold, data,
**kwargs)   3027                         filternorm=filternorm,
filterrad=filterrad,   3028                         imlim=imlim,
resample=resample, url=url, data=data,-> 3029
**kwargs)   3030     finally:   3031         ax.hold(washold)
.../lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax,
*args, **kwargs)   1817                     warnings.warn(msg %
(label_namer, func.__name__),   1818
RuntimeWarning, stacklevel=2)-> 1819             return func(ax,
*args, **kwargs)   1820         pre_doc = inner.__doc__   1821
if pre_doc is None:
.../lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in
imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax,
origin, extent, shape, filternorm, filterrad, imlim, resample, url,
**kwargs)   4920                               resample=resample,
**kwargs)   4921 -> 4922         im.set_data(X)   4923
im.set_alpha(alpha)   4924         if im.get_clip_path() is None:
.../lib/python2.7/site-packages/matplotlib/image.pyc in set_data(self,
A)    451         if (self._A.ndim not in (2, 3) or    452
    (self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):--> 453
          raise TypeError("Invalid dimensions for image data")    454
   455         self._imcache = None
TypeError: Invalid dimensions for image data

Thank you,

Anaelia Ovalle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20170329/a4695f4d/attachment-0001.html>

More information about the Pkg-ExpPsy-PyMVPA mailing list