[Insight-users] Re: on wrap_itk
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Wed Apr 18 15:46:06 EDT 2007
It is still possible to get it somewhere - in the source package of
your favorite distro for example :-)
Le 18 avr. 07 à 09:38, anirudh vij a écrit :
> that is what i would love to do,except that pyqt3 requires qt
> 3.17,and the source for that seems to have disappeared from the
> web.i am on a system where i cn install only by building from source.
>
> On 4/18/07, Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr> wrote:
> Le 15 avr. 07 à 11:02, anirudh vij a écrit :
>
> > hi gaetan,
> > i had to modify the
> > import qt
> > line in ../itkExtras/itkvtkExtras.py and /usr/lib/python/site-
> > packages/vtk/qt/QVTKRenderWindow to:
> > import PyQt4.Qt as qt
> > before i got the following error:
> >
> >
> > In [5]: itk.show r
> > ------> itk.show(r)
> >
> ----------------------------------------------------------------------
> > -----
> > exceptions.TypeError Traceback
> > (most recent call last)
> >
> > /home/hackman/<ipython console>
> >
> > /usr/local/lib/InsightToolkit/WrapITK/Python/itkExtras/__init__.py
> > in show(input, **kargs)
> > 239 img = image(input)
> > 240 if img.GetImageDimension() == 3 and "show3D" in dir(itk):
> > --> 241 return itk.show3D(input, **kargs)
> > 242 else :
> > 243 # print "2D not supported yet, use the 3D viewer."
> >
> > /usr/local/lib/InsightToolkit/WrapITK/Python/itkExtras/
> > itkvtkExtras.py in __init__(self, input, MinOpacity, MaxOpacity)
> > 11 self.__app__ = qt.QApplication (['itkviewer'])
> > 12 # create the widget
> > ---> 13 self.__widget__ = QVTKRenderWindowInteractor()
> > 14 self.__ren__ = vtk.vtkRenderer()
> > 15 self.__widget__.GetRenderWindow().AddRenderer
> > (self.__ren__)
> >
> > /usr/lib/python2.4/site-packages/vtk/qt/
> > QVTKRenderWindowInteractor.py in __init__(self, parent, name,
> > *args, **kw)
> > 136 # You cannot pass kw anymore, you'll a TypeError:
> > keyword arguments are not supported
> > 137 # http://goldenspud.com/webrog/archives/2004/07/20/
> > pyqt-platform-inconsistencies/
> > --> 138 apply(qt.QWidget.__init__, (self,parent,name) +
> args)
> > 139
> > 140 if rw: # user-supplied render window
> >
> > TypeError: argument 2 of QWidget() has an invalid type
> >
> >
> > my knowledge of qt is non-existent,so i cannot go any further
> > without your help.
> > In case this helps,the following is a list of python modules with
> > the name "qt" on my computer:
> >
> > PIL.ImageQt
> > PyQt4.Qt
> > PyQt4.QtAssistant
> > PyQt4.QtCore
> > PyQt4.QtDesigner
> > PyQt4.QtGui
> > PyQt4.QtNetwork
> > PyQt4.QtOpenGL
> > PyQt4.QtSql
> > PyQt4.QtSvg
> > PyQt4.QtTest
> > PyQt4.QtXml
> > PyQt4 (package)
> > PyQt4.elementtree.ElementPath
> > PyQt4.elementtree.ElementTree
> > PyQt4.elementtree (package)
> > PyQt4.pyqtconfig
> > PyQt4.uic.Compiler (package)
> > PyQt4.uic.Compiler.compiler
> > PyQt4.uic.Compiler.indenter
> > PyQt4.uic.Compiler.qobjectcreator
> > PyQt4.uic.Compiler.qtproxies
> > PyQt4.uic.Loader (package)
> > PyQt4.uic.Loader.loader
> > PyQt4.uic.Loader.qobjectcreator
> > PyQt4.uic (package)
> > PyQt4.uic.exceptions
> > PyQt4.uic.objcreator
> > PyQt4.uic.properties
> > PyQt4.uic.pyuic
> > PyQt4.uic.uiparser
> > matplotlib.backends.backend_qt
> > matplotlib.backends.backend_qt4
> > matplotlib.backends.backend_qt4agg - Render to qt from agg
> > matplotlib.backends.backend_qtagg - Render to qt from agg
> > pytz.zoneinfo.Asia.Aqtau
> > pytz.zoneinfo.Asia.Aqtobe
> > vtk.qt.QVTKRenderWidget - A simple VTK input file for PyQt, the qt
> > bindings for python.
> > vtk.qt.QVTKRenderWindowInteractor - A simple VTK input file for
> > PyQt, the qt bindings for python.
> > vtk.qt (package) - pyQt widgets for VTK.
> > ImageQt
> >
> > observe the large number with the prefix PyQt4....the pyqt
> > designers seem to have split up the functionality of pyqt,though as
> > i said earlier,i do no knoq anything of qt :)
> >
>
> I don't know much about PyQt 4, but it doesn't seem to be supported
> yet by VTK.
> Can't you simply install PyQt 3 ?
>
> Gaëtan
>
>
> > On 4/15/07, Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr> wrote:
> > Le 15 avr. 07 à 00:49, anirudh vij a écrit :
> >
> > > just found out a new problem:
> > > using qt-4.2.3 and pyqt 4,itk.show3D() cannot work because the
> file
> > > itkvtkextras.py in /usr/local/lib/InsightToolkit/Wrap_Itk/Python/
> > > itkExtras has a line
> > >
> > > import qt
> > >
> > > now,in pyqt4,the import syntax is
> > >
> > > import PyQt4
> > >
> > > so all code using the earlier syntax is broken.i fixed it in 1-2
> > > files,but this problem will keep coming up.is it possible to
> make a
> > > symlink in python's site-packages 'qt' to point to 'PyQt4'?
> >
> > can you try to replace
> >
> > import qt
> >
> > by
> >
> > try:
> > import qt
> > except ImportError:
> > import PyQt4 as qt
> >
> > if it work for you, I'll put it in cvs.
> >
> > Thanks,
> >
> > Gaëtan
> >
> >
> > >
> > > On 4/15/07, anirudh vij < anirudhvij at gmail.com> wrote:
> > > >ItkVtkGlue is not properly installed on your system :-)
> > > that was indeed the problem.maybe i installed in the wrong prefix
> > > the last 2 times.
> > > >If you are interested by getting some infos on labelized
> > objects, you
> > > >can install one of my contributions to ITK:
> > >
> > > >http://voxel.jouy.inra.fr/darcsweb/darcsweb.cgi ?
> > > >r=binaryAttributeMorphology;a
> > > >=summary
> > >
> > > >you can get it with darcs ( www.darcs.net):
> > >
> > > >darcs get http://voxel.jouy.inra.fr/darcs/contrib-itk/
> > > >binaryAttributeMorphology/
> > >
> > >
> > > unfortunately ,the proxy which i connect to has blocked the ports
> > > used by svn ,cvs,and darcs :(
> > > guess will have to wait till your contrib makes it to the itk
> > source .
> > >
> > > On 4/15/07, Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr > wrote:
> > > Le 14 avr. 07 à 21:25, anirudh vij a écrit :
> > >
> > > > >You didn't sent me the content of your /usr/local/
> InsightToolkit/
> > > > >WrapITK/Python/itkExtras/ directory. Can you do that ?
> > > >
> > > > this directory contains an __init__.py file.the reference to
> > show3d
> > > > () in this is:
> > > >
> > > > def show(input, **kargs) :
> > > > """display an image
> > > > """
> > > > import itk
> > > > img = image(input)
> > > > if img.GetImageDimension() == 3 and "show3D" in dir(itk):
> > > > return itk.show3D(input, **kargs)
> > > > else :
> > > > # print "2D not supported yet, use the 3D viewer."
> > > > return show2D(input, **kargs)
> > > >
> > >
> > > ItkVtkGlue is not properly installed on your system :-)
> > > Please go back to Wrapping/WrapITK/ExternalProjects/ItkVtkGlue/
> and
> > > reinstall it. Be sure to set the same prefix than the one you used
> > > for ITK itself.
> > >
> > >
> > > > >Are you using PyBuffer to pass data from ITK to scipy ?
> > > >
> > > > afraid had'nt heard of it till now.was using the most primitive
> > > > way,temp files :)
> > > > but will try now for sure.
> > > >
> > > > there's something new thats come up in the meanwhile.the best
> way
> > > > to explain would be to paste ipython's output:
> > > >
> > > >
> > > > In [159]: bbox=lab_stat.GetBoundingBox(1)
> > > >
> > > > In [160]: bbox
> > > > Out[160]:
> > > > '_e0b9c208_p_std__vectorTlong_int_std__allocatorTlong_int_t_t'
> > > >
> > > > In [161]: type(bbox)
> > > > Out[161]: <type 'str'>
> > > >
> > > > here lab_stat is a itk.LabelStatisticsImageFilter
> instance.why is
> > > > bounding box being returned as string instead of std::vector?
> > > > is'nt std::vector wrapped by default?the wrap_itk paper mentions
> > > > that vector_double wrapping is off by default.is that so for
> > > > vector_long and vector_unsignedshort also?
> > >
> > > std::vector and itk::Vector are not the same classes.
> > > Some instantiations of itk::Vector are available, but sadely,
> there
> > > is no instantiation of std::vector available with wrapitk.
> > > If you are interested by getting some infos on labelized objects,
> > you
> > > can install one of my contributions to ITK:
> > >
> > > http://voxel.jouy.inra.fr/darcsweb/darcsweb.cgi?
> > > r=binaryAttributeMorphology;a=summary
> > >
> > > you can get it with darcs ( www.darcs.net):
> > >
> > > darcs get http://voxel.jouy.inra.fr/darcs/contrib-itk/
> > > binaryAttributeMorphology/
> > >
> > > an example which use that contrib can be found at:
> > >
> > > http://voxel.jouy.inra.fr/darcs/agrobi/agrobi.py
> > >
> > > The bounding box is provided by the method GetRegion() of the
> > > LabelObject.
> > > There is not much doc for now I'm afraid.
> > >
> > > Gaëtan
> > >
> > > >
> > > > >Can you send a short script which reproduce
> > > > >the problem ?
> > > > this problem happens for all filters.i will send the script
> > file in
> > > > a next post.
> > > >
> > > > On 4/14/07, Gaëtan Lehmann < gaetan.lehmann at jouy.inra.fr >
> wrote:
> > > > Hi,
> > > >
> > > > Please keep the discussions about wrapitk on the user list:
> it can
> > > > help others to fix there problems in the future :-)
> > > >
> > > > Le 14 avr. 07 à 11:09, anirudh vij a écrit :
> > > >
> > > > > hi gaetan,
> > > > > kudos once again for creating wrap itk.It has speeded up my
> > work a
> > > > > lot.Prototyping is truly horrible in cpp.
> > > > >
> > > > > in course of my use i faced some problems.hope you'll be
> able to
> > > > > guide towards the solution.
> > > > >
> > > > > 1)still could'nt get show3d() working.my versions of qt and
> pyqt
> > > > > are both 4.2.3. maybe thats the problem.
> > > >
> > > > it shouldn't prevent you to see the show3D class in the itk
> > module.
> > > >
> > > >
> > > > > anyway,i installed mayavi which has excellent python
> > > > > compatibility.i would like to write a wrapper for show3d()
> which
> > > > > would make a call to mayavi whenever show3d() is called,maybe
> > with
> > > > > some extra options.where should i place the .py file give
> > that no
> > > > > show3d.py currently exists in /usr/local/lib/
> > InsightToolkit.maybe
> > > > > you could consider moving the itk.show framework entirely to
> > > mayavi
> > > > > in the future .it would mean fewer dependencies on one
> > hand,and a
> > > > > unified show2d() and show3d() interface on the other(sice
> mayavi
> > > > > can show 2d images with extra options of visualization)
> > > >
> > > > I'm still looking for a good interface for python and ITK.
> I'm not
> > > > sure that mayavi is what I exactly what I want though, but
> have an
> > > > interface for it would be a great feature :-)
> > > > The best way to go, IMHO, is to create a mayavi function or
> > class to
> > > > display the image, and to put that function in a module in the
> > > > itkExtras dir, so its content will automatically appear in
> the itk
> > > > module - show3D is made that way.
> > > >
> > > > >
> > > > > 2)whenever a filter is incorrectly initialized and an
> update is
> > > > > triggered,wrap_itk stops working for that session.subsequent
> > > > > imports produce the error:module swig not defined.
> > > > >
> > > > > 3)after succesfully triggering an update on a filter,if some
> > > > > parameters are changed subsequently,and an update is again
> > > > > triggered,there is no change.for example.
> > > > > dil= itl.BinaryDilateImageFilter.IFUS3US3.New()
> > > > > dil.SetKernel(se) #se is some strel
> > > > > dil.Update() #works fine
> > > > > dil.SetKernel(se2)
> > > > > dil.Update() #no change :(
> > > > >
> > > > > is it a problem with my installation or is this the way it is
> > > > > supposed to behave.
> > > >
> > > > it looks like a problem. Can you send a short script which
> > reproduce
> > > > the problem ? It would help a lot to reproduce it and to debug.
> > > >
> > > > >
> > > > > currently i am trying to extend wrap_itk using scipy
> ( i.e . make
> > > > > calls cleaner,add routines that directly do common tasks etc).
> > > >
> > > > Are you using PyBuffer to pass data from ITK to scipy ?
> > > >
> > > > > i will report any major successes.
> > > > >
> > > >
> > > > Please, do :-)
> > > >
> > > > Gaëtan
> > > >
> > > >
> > > > --
> > > > Gaëtan Lehmann
> > > > Biologie du Développement et de la Reproduction
> > > > INRA de Jouy-en-Josas (France)
> > > > tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
> > > > http://voxel.jouy.inra.fr
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > > --
> > > Gaëtan Lehmann
> > > Biologie du Développement et de la Reproduction
> > > INRA de Jouy-en-Josas (France)
> > > tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
> > > http://voxel.jouy.inra.fr
> > >
> > >
> > >
> > >
> > >
> > >
> >
> > --
> > Gaëtan Lehmann
> > Biologie du Développement et de la Reproduction
> > INRA de Jouy-en-Josas (France)
> > tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
> > http://voxel.jouy.inra.fr
> >
> >
> >
> >
> >
>
> --
> Gaëtan Lehmann
> Biologie du Développement et de la Reproduction
> INRA de Jouy-en-Josas (France)
> tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
> http://voxel.jouy.inra.fr
>
>
>
>
>
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: =?ISO-8859-1?Q?Ceci_est_une_signature_=E9lectronique_PGP?=
Url : http://public.kitware.com/pipermail/insight-users/attachments/20070418/f22ada58/PGP.pgp
More information about the Insight-users
mailing list