Re: mayavi scalar_field
On Sun, Feb 28, 2010 at 05:06:07PM -0800, M Trumpis wrote:
> > On Fri, Feb 26, 2010 at 01:14:07AM -0800, M Trumpis wrote:
> >> > So, ImageData cannot be in diagonal. As you point out in a later email,
> >> > StructuredGrid can, but you have to slice it with a 'ScalarCutPlane'
> >> > which is much slower than the ImagePlaneWidget. You cannot 'Coerce it
> >> > into an ImageData without sampling it to a non diagonal grid. However, if
> >> > you want to do this, the 'ImageDataProbe', called 'Probe on image data'
> >> > in the filter menu of Mayavi, should do the trick.
> >> This is great! It did work, except the dimensions for the filter seem
> >> to be calculated wrong starting off, giving this VTK error:
> >> ERROR: In ../../Filtering/vtkStreamingDemandDrivenPipeline.cxx, line 818
> >> vtkStreamingDemandDrivenPipeline (0x216d7480): The update extent
> >> specified in the information for output port 0 on algorithm
> >> vtkAssignAttribute(0x216d3130) is 0 0 0 96 0 60, which is outside the
> >> whole extent 0 93 0 89 0 66.
> > OK, that's probably something that we can fix. I'll try and have a look
> > at the code of the ImageDataProbe when I have time (unless you beat me to
> > it, of course).
> I've given it a look (in _setup_probe_data(), unless I'm mistaken). So
> in this filter we're creating a new ImageData object with the grid
> aligned on the spatial axes. I don't know the underlying filter
> mechanics, but one would think that the extents and dimension sizes
> may be different for the input and output data. Maybe this is a case
> of making an initial assumption about the output dimension extents,
> and failing to update it later?
Sounds plausible. That's probably the sort of thing that should be
updated on update_data.
> >> I had another problem, which I never solved but did work around. The
> >> following sequence of commands fail with another VTK error (pasted
> >> further below). I get back a filter that seems uninitialized. However,
> >> if I add something like a structured_grid_outline to the pipeline
> >> before creating the ImageDataProbe filter, then I'm back in business
> >> (at least to the point above, with the wrong dimensions). So what's
> >> changes when I add a vis module to the data first?
> >> r = tvtk.StructuredGrid(dimensions=map_img.shape)
> >> r.points = xyz_coords
> >> r.point_data.scalars = np.asarray(map_img).flatten().copy()
> >> md = mlab.pipeline.add_dataset(r)
> >> idp = mlab.pipeline.image_data_probe(md)
> > OK, I suspect that it is a pipelining bug. Can you try to add:
> > md.update_pipeline()
> > before the image_data_probe.
> Actually, md is
> In [23]: md
> Out[23]: <enthought.mayavi.sources.vtk_data_source.VTKDataSource
> object at 0x20cef9c0>
> and doesn't have an update_pipeline() member. Is there another way to do it?
Does it have an update_data()? or a render? Try these.
Gaël