Discussion:
[MayaVi-users] volume rendering with anisotropic, but regularly spaced pixels, (delz=2*delz=2*dely)
Christopher Snyder
2015-07-28 23:02:07 UTC
Permalink
Hi there,

My usual routine involves
ix,iy,iz=np.indices(Image)
s=mlab.pipeline.scalar_field(spacing[0]*ix,spacing[1]*iy,spacing[2]*iz,Image)
mlab.pipeline(volume(s))

However, I am strapped for memory. Actually forming the indices ix,iy,iz is
putting a burden on my code. Is there some workaround, perhaps through the
depths of vtk, that lets me specify this with just the scalar tuple (1,1,2)
???

Thanks in anticipation,
Chris Snyder
Gael Varoquaux
2015-07-29 05:59:03 UTC
Permalink
Replace the creationg of "s" by instanciating an ImageData:

http://docs.enthought.com/mayavi/mayavi/data.html#imagedata

That should do it,

G
Post by Christopher Snyder
Hi there,
My usual routine involves
ix,iy,iz=np.indices(Image)
s=mlab.pipeline.scalar_field(spacing[0]*ix,spacing[1]*iy,spacing[2]*iz,Image)
mlab.pipeline(volume(s))
However, I am strapped for memory. Actually forming the indices ix,iy,iz is
putting a burden on my code. Is there some workaround, perhaps through the
depths of vtk, that lets me specify this with just the scalar tuple (1,1,2) ???
 
Thanks in anticipation,
Chris Snyder
------------------------------------------------------------------------------
_______________________________________________
MayaVi-users mailing list
https://lists.sourceforge.net/lists/listinfo/mayavi-users
--
Gael Varoquaux
Researcher, INRIA Parietal
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone: ++ 33-1-69-08-79-68
http://gael-varoquaux.info http://twitter.com/GaelVaroquaux

------------------------------------------------------------------------------
Christopher Snyder
2015-07-31 21:56:05 UTC
Permalink
Hi Gael,

Thanks for your helpful comments. That method didn't work directly, but I
was able to work around. For some reason, it would like me to report the
x-dimension last to get a coherent image.

#Image.shape=(34,74,74)
s=tvtk.ImageData(dimensions=(34,74,74), spacing=(1,1,1),origin=(0,0,0)
#Volume filter creates nonsense
s=tvtk.ImageData(dimensions=(74,74,34), spacing=(1,1,1),origin=(0,0,0)
#Looks reasonable, may be rotated?
s.point_data.scalars=Image.ravel()

For those reading along, I follow this with
mlab.pipeline.volume(s)
or
self.scene.mlab.pipeline.volume(s) #in an object oriented script


Do you know what's going on? This reminds me of how when I call
skimage.io.imread(image_file), the 'x' coordinate of Image is usually what
I would think of as the 'z' coordinate in other viewers like imagej.

Thanks,
Chris

On Wed, Jul 29, 2015 at 12:59 AM, Gael Varoquaux <
Post by Gael Varoquaux
http://docs.enthought.com/mayavi/mayavi/data.html#imagedata
That should do it,
G
Post by Christopher Snyder
Hi there,
My usual routine involves
ix,iy,iz=np.indices(Image)
s=mlab.pipeline.scalar_field(spacing[0]*ix,spacing[1]*iy,spacing[2]*iz,Image)
Post by Christopher Snyder
mlab.pipeline(volume(s))
However, I am strapped for memory. Actually forming the indices ix,iy,iz
is
Post by Christopher Snyder
putting a burden on my code. Is there some workaround, perhaps through
the
Post by Christopher Snyder
depths of vtk, that lets me specify this with just the scalar tuple
(1,1,2) ???
Post by Christopher Snyder
Thanks in anticipation,
Chris Snyder
------------------------------------------------------------------------------
Post by Christopher Snyder
_______________________________________________
MayaVi-users mailing list
https://lists.sourceforge.net/lists/listinfo/mayavi-users
--
Gael Varoquaux
Researcher, INRIA Parietal
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone: ++ 33-1-69-08-79-68
http://gael-varoquaux.info http://twitter.com/GaelVaroquaux
Christopher Snyder
2015-07-31 22:38:33 UTC
Permalink
I've just noticed now, in addition to rendering what looks to be a correct
volume, I also get an error starting with :
ERROR: In
/home1/03176/csnyder/SourceCode/VTK5.10.1/Graphics/vtkAssignAttribute.cxx,
line 275
vtkAssignAttribute (0x3854160): Data must be point or cell for vtkDataSet

Chris
Post by Christopher Snyder
Hi Gael,
Thanks for your helpful comments. That method didn't work directly, but I
was able to work around. For some reason, it would like me to report the
x-dimension last to get a coherent image.
#Image.shape=(34,74,74)
s=tvtk.ImageData(dimensions=(34,74,74), spacing=(1,1,1),origin=(0,0,0)
#Volume filter creates nonsense
s=tvtk.ImageData(dimensions=(74,74,34), spacing=(1,1,1),origin=(0,0,0)
#Looks reasonable, may be rotated?
s.point_data.scalars=Image.ravel()
For those reading along, I follow this with
mlab.pipeline.volume(s)
or
self.scene.mlab.pipeline.volume(s) #in an object oriented script
Do you know what's going on? This reminds me of how when I call
skimage.io.imread(image_file), the 'x' coordinate of Image is usually what
I would think of as the 'z' coordinate in other viewers like imagej.
Thanks,
Chris
On Wed, Jul 29, 2015 at 12:59 AM, Gael Varoquaux <
Post by Gael Varoquaux
http://docs.enthought.com/mayavi/mayavi/data.html#imagedata
That should do it,
G
Post by Christopher Snyder
Hi there,
My usual routine involves
ix,iy,iz=np.indices(Image)
s=mlab.pipeline.scalar_field(spacing[0]*ix,spacing[1]*iy,spacing[2]*iz,Image)
Post by Christopher Snyder
mlab.pipeline(volume(s))
However, I am strapped for memory. Actually forming the indices
ix,iy,iz is
Post by Christopher Snyder
putting a burden on my code. Is there some workaround, perhaps through
the
Post by Christopher Snyder
depths of vtk, that lets me specify this with just the scalar tuple
(1,1,2) ???
Post by Christopher Snyder
Thanks in anticipation,
Chris Snyder
------------------------------------------------------------------------------
Post by Christopher Snyder
_______________________________________________
MayaVi-users mailing list
https://lists.sourceforge.net/lists/listinfo/mayavi-users
--
Gael Varoquaux
Researcher, INRIA Parietal
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone: ++ 33-1-69-08-79-68
http://gael-varoquaux.info
http://twitter.com/GaelVaroquaux
Christopher Snyder
2015-07-31 23:04:55 UTC
Permalink
Ignore that last email, but not the one before that. I figured out the
bug. scalars
needs a name
<http://permalink.gmane.org/gmane.comp.python.enthought.devel/28658>

I'm still confused why my data set is rotated and interprets the dataset in
a different way.

Also, in theory is there any difference between pipeline.volume(ImageData)
as described above and this method:

from vtk import vtkTIFFReader
reader=vtkTIFFReader()
reader.SetFileName(patchpath)
reader.Update()
image=reader.GetOutput()
mlab.pipeline.volume(tvtk.to_tvtk(image))

The second method with vtkTIFFReader seems to give me a dense block instead
of a volume that is mostly transparent, but maybe there is just some
opacity setting I am missing.

Thanks in anticipation,
Chris
Post by Christopher Snyder
I've just noticed now, in addition to rendering what looks to be a correct
ERROR: In
/home1/03176/csnyder/SourceCode/VTK5.10.1/Graphics/vtkAssignAttribute.cxx,
line 275
vtkAssignAttribute (0x3854160): Data must be point or cell for vtkDataSet
Chris
Post by Christopher Snyder
Hi Gael,
Thanks for your helpful comments. That method didn't work directly, but I
was able to work around. For some reason, it would like me to report the
x-dimension last to get a coherent image.
#Image.shape=(34,74,74)
s=tvtk.ImageData(dimensions=(34,74,74), spacing=(1,1,1),origin=(0,0,0)
#Volume filter creates nonsense
s=tvtk.ImageData(dimensions=(74,74,34), spacing=(1,1,1),origin=(0,0,0)
#Looks reasonable, may be rotated?
s.point_data.scalars=Image.ravel()
For those reading along, I follow this with
mlab.pipeline.volume(s)
or
self.scene.mlab.pipeline.volume(s) #in an object oriented script
Do you know what's going on? This reminds me of how when I call
skimage.io.imread(image_file), the 'x' coordinate of Image is usually what
I would think of as the 'z' coordinate in other viewers like imagej.
Thanks,
Chris
On Wed, Jul 29, 2015 at 12:59 AM, Gael Varoquaux <
Post by Gael Varoquaux
http://docs.enthought.com/mayavi/mayavi/data.html#imagedata
That should do it,
G
Post by Christopher Snyder
Hi there,
My usual routine involves
ix,iy,iz=np.indices(Image)
s=mlab.pipeline.scalar_field(spacing[0]*ix,spacing[1]*iy,spacing[2]*iz,Image)
Post by Christopher Snyder
mlab.pipeline(volume(s))
However, I am strapped for memory. Actually forming the indices
ix,iy,iz is
Post by Christopher Snyder
putting a burden on my code. Is there some workaround, perhaps through
the
Post by Christopher Snyder
depths of vtk, that lets me specify this with just the scalar tuple
(1,1,2) ???
Post by Christopher Snyder
Thanks in anticipation,
Chris Snyder
------------------------------------------------------------------------------
Post by Christopher Snyder
_______________________________________________
MayaVi-users mailing list
https://lists.sourceforge.net/lists/listinfo/mayavi-users
--
Gael Varoquaux
Researcher, INRIA Parietal
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone: ++ 33-1-69-08-79-68
http://gael-varoquaux.info
http://twitter.com/GaelVaroquaux
Loading...