[vtkusers] [Q] Pipeline problem: double executes (tcl code)

Stoutjesdijk Mark J. mark.stoutjesdijk at gmail.com
Fri Sep 17 17:25:28 EDT 2010


Hello,

I have written a rudimentary VTK image filter that performs a meanshift filtering on a vtkImage that has multiple components. When I have this filter in a pipeline, it is sometimes executed TWICE without any apparent changes uplink. To debug, I would like to know why VTK thinks it should execute my filter again. Is there a way to monitor the update flag of an object?

After this first question, let me try to briefly describe when this double-execute occurs. The meanshift filter has a multi-component vtkImageData as its input. This input object is generated from several regular, single-component vtkImageData objects. Some of these have a different transform than the others (due to voxel size variation), and these are scaled. If no scaling is necessary (i.e. there are no differences in voxel sizes), my filter gets executed only once. As soon as scaling occurs, it is executed twice. The scaling script, in TCL, follows at the end of this mail.

I've been banging my head on this one for weeks. I hope somebody can point me in the right direction!

Best regards,
Mark


 method ScaleInputs {} {
     if { [GetVerbosity] > 5 } {
         puts  "Resampling parameters: $Parameters\n"
     }
     foreach p $Parameters {
         if {$p == [lindex $Parameters 0]} {
             puts "Resample everything to $p"
             # p is the first input, so resample everything to this transform.
             set T0 [[[DataFactory::Instance] GetData $p] GetTransform]
             set Img0 [[[DataFactory::Instance] GetData $p] GetVolume]
         } else {
             set T [[[DataFactory::Instance] GetData $p] GetTransform]
             set DifferentTransforms "FALSE"
             for {set i 0} {$i<4} {incr i} {
                 for {set j 0} {$j<4} {incr j} {
                     set elemT  [[$T  GetMatrix] GetElement $i $j]
                     set elemT0 [[$T0 GetMatrix] GetElement $i $j]
                     if { $elemT != $elemT0 } { set DifferentTransforms "TRUE" }
                 }
             }
             if { $DifferentTransforms == "TRUE" } {
                 if { [[DataFactory::Instance] GetData "Scaled$p"]=="" } {
                     log "Resampling $p."
                     # Initialize a resampler so that input images can be resampled if needed. This is done when
                     # the configuration file is read.
                     ImgResampler ${this}resampler($p)

                     set Img [[[DataFactory::Instance] GetData $p] GetVolume]
                     # Different transform, so resample:
                     ${this}resampler($p) AddInput1 $Img0 $T0
                     ${this}resampler($p) AddInput2 $Img  $T
                     ${this}resampler($p) SetInterpolationModeTo Cubic
                     [${this}resampler($p) GetOutput] Update
                     # Make a new ImageData object and submit to factory as Scaled$p.
                     ImageData Scaled($p)
                     Scaled($p) SetVolume [${this}resampler($p) GetOutput]
                     Scaled($p) SetTransform $T0
                     [MRCADDataFactory::Instance] AddData "Scaled$p" Scaled($p)
                     # Change the name in the parameterlist from $p to Scaled$p, so the
                     # resampled version is used from here on.
                     lset Parameters [lsearch -exact $Parameters $p] "Scaled$p"
                 }
                 # Add the resampled images as overlay (FG):
                 log "Parameter list is now: $Parameters."
                 puts "Parameter list is now: $Parameters."
             } else {
                 log "No reampling needed for $p."
             }
         }
     }
 }



More information about the vtkusers mailing list