[Insight-users] runtime error !

Charl P. Botha c.p.botha at ewi.tudelft.nl
07 Apr 2004 10:42:43 +0200


On Wed, 2004-04-07 at 04:35, xujf wrote:
> Hi,Charl P.Botha and Rodrigo Truiillo:
>     with your help, my code had no syntax errors.
>     when I finished my code,I ran it.an error dialog appeared:
>     "Rumtime Error!
>     Program:C:\\python23\\python.exe
>     This application has requested the Runtime to terminate it in an unusual way.
>     Please connact the application \'s support team for more information "

The problem is that the ITK wrappings propagate C++ exceptions to
Python, but you're driving the pipeline from the VTK side, so the
exceptions aren't being handled and cause your application to stop
without a usable message.  I've made changes recently in VTK so that VTK
also catches exceptions when a vtkImageImport is used, but you're
probably using a non-CVS version.

Until then, always call Update() on the last ITK class in your ITK
pipeline before you make any VTK calls which might update the whole
pipeline.  This way you'll see what error is making your app stop.

Good luck,
Charl

> 
> my code is as follow:
> 
> import sys,os
> import paths
> import InsightToolkit as itk
> from vtkMINCReader  import *
> import ConnectVTKITK as connect
> 
> reader=vtkMINCReader()
> vtkexport=vtkImageExport()
> 
> vtkexport.SetInput(reader.GetOutput())
> reader.SetFileName("E:/atamai/2003-01-27/atamai/examplesPmw/sbrain.mnc")
> 
> itkimport=itk.itkVTKImageImportF3_New()
> 
> connect.ConnectVTKToITKF3(vtkexport,itkimport.GetPointer())
> 
> itkcurfilter=itk.itkCurvatureAnisotropicDiffusionImageFilterF3F3_New()
> itkbinfilter=itk.itkBinaryThresholdImageFilterF3US3_New()
> itkgradfilter=itk.itkGradientMagnitudeRecursiveGaussianImageFilterF3F3_New()
> itksigfilter=itk.itkSigmoidImageFilterF3F3_New()
> itkfastmarchingfilter=itk.itkFastMarchingImageFilterF3F3_New()
> 
> itksigfilter.SetOutputMinimum(0.0)
> itksigfilter.SetOutputMaximum(1.0)
> itksigfilter.SetAlpha(1.5)
> itksigfilter.SetBeta(0.5)
> 
> itkgradfilter.SetSigma(1)  
> seeds=itk.itkNodeContainerF3_New()
> 
> seedPosition=itk.itkIndex3()
> seedPosition.SetElement(0,0)
> seedPosition.SetElement(1,0)
> seedPosition.SetElement(2,0)
> 
> node=itk.itkLevelSetNodeF3()
> node.SetValue(0.0)
> node.SetIndex(seedPosition)
> seeds.Initialize()
> seeds.InsertElement(0,node)
> itkfastmarchingfilter.SetTrialPoints(seeds.GetPointer())
> itkfastmarchingfilter.SetSpeedConstant(1.0)
> itkfastmarchingfilter.SetStoppingValue(2.0)  
> 
> itkgradfilter.SetInput(itkimport.GetOutput())
> itksigfilter.SetInput(itkgradfilter.GetOutput())
> itkfastmarchingfilter.SetInput(itksigfilter.GetOutput())
> itkbinfilter.SetInput(itkfastmarchingfilter.GetOutput())
> 
> vtkimport=vtkImageImport()
> itkexport=itk.itkVTKImageExportF3_New()
> itkexport.SetInput(itkfastmarchingfilter.GetOutput())
> 
> connect.ConnectITKF3ToVTK(itkexport.GetPointer(),vtkimport)
> 
> ren = vtkRenderer()
> renWin = vtkRenderWindow()
> renWin.AddRenderer(ren)
> iren = vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
> 
> mapper=vtkDataSetMapper()
> mapper.SetInput(vtkimport.GetOutput())
> 
> actor=vtkActor()
> actor.SetMapper(mapper)
> 
> ren.AddActor(actor)
> 
> iren.Initialize()
> renWin.Render()
> iren.Start()
> 
> Best Regards!     
-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/