[Nipy-devel] Visualization code refactor

Matthew Brett matthew.brett@gmail....
Thu Jan 14 14:55:09 CST 2010


> Am slowly getting better ;)
> I had a first look - I'll look more tomorrow.

Still slow, but had a quick look.  Just small thoughts.

It's very nice, the demos scattered around, a la Mayavi.

I ran into this:

In [1]: import nipy.neurospin.viz.maps_3d as maps3d

In [2]: maps3d.demo_plot_map_3d()
NameError                                 Traceback (most recent call last)

/home/mb312/nipy/<ipython console> in <module>()

in demo_plot_map_3d()
    270     map = map.T
    271     plot_map_3d(map, mni_sform, cut_coords=(x, y, z), threshold=0.5,
--> 272                                 figure_num=512)

in plot_map_3d(map, affine, cut_coords, anat, anat_affine, threshold,
figure, mask, **kwargs)
    242     # Display the map using volume rendering

    243     map_src = affine_img_src(map, affine)
--> 244     vol = mlab.pipeline.volume(map_src, vmin=vmin, **kwargs)
    246     if not anat is False:

NameError: global name 'vmin' is not defined

and it wasn't clear to me how to fix it, sorry to say.

Attempting to run ortho_slicer.py as a script gave me the relative
import errors that Mike noticed.

Trying to replicate the __main__ example there gave me:

In [1]: import nipy.neurospin.viz.ortho_slicer as orths

In [2]: a = orths.OrthoSlicer()
TypeError                                 Traceback (most recent call last)

/home/mb312/<ipython console> in <module>()

TypeError: __init__() takes at least 2 arguments (1 given)

It looks like the call signatures changed:

In [1]: import nipy.neurospin.viz.ortho_slicer as orths

In [2]: from nipy.neurospin.viz.anat_cache import _AnatCache

In [3]: map, affine, _ = _AnatCache.get_anat()

In [4]: oslicer = orths.OrthoSlicer((0,0,0))

In [6]: import pylab as pl

In [7]: oslicer.plot_map(map, affine, cmap=pl.cm.gray)

In [8]: pl.show()

produces a nice plot.

It seems like a good feature to allow cut_coords to the plot_map call,
but I didn't look hard to see why that might not work.

Your use of _AnatCache in the demo routine made me think this nice
feature should be promoted.  I had previously (in matlab) played with
a 'template' object to encapsulate different templates:


- the idea being something like this:

mni_2mm = nipy.templates.MNI2mm()

t1_img = mni_2mm['t1']['raw']
t1_brainmask = mni_2mm['t1']['brainmask']

maybe not that interface, but you get the idea.

Thanks for putting it up for review,

See you,


More information about the Nipy-devel mailing list