[Insight-users] Update() on a Resampling Pipeline does not work

Allon Shahar AShahar at micromri.com
Fri Aug 31 15:08:45 EDT 2007


The problem was solved by doing a resample->Modified() after the
SetTransform(). Apparently (and unintuitively!), updating the
transformation parameters doesn't qualify as a modification change.
Since the input image remains the same for every iteration, the filter
doesn't recompute its output when Update() is called. Forcing a change
in the modification time through Modified() does the trick.

FYI,

Allon

 

________________________________

From: insight-users-bounces+ashahar=micromri.com at itk.org
[mailto:insight-users-bounces+ashahar=micromri.com at itk.org] On Behalf Of
Allon Shahar
Sent: Thursday, August 30, 2007 5:55 PM
To: insight-users at itk.org
Subject: [Insight-users] Update() on a Resampling Pipeline does not work

 

Hello all,

 

In my application, I'm trying to transform the same image (unionMask)
multiple times, each time with a different set of parameters (previously
collected), and write the result to file. The fixed image is saved fine,
but the loop just generates multiple copies of the same transformed
image. The cout's show that the parameters of invTransform do change in
every iteration, so I'm suspecting that the pipeline doesn't get updated
after the first iteration for some reason. As you can see, I tried
performing an Update() after updating every filter, but the result is
the same. I'd appreciate if someone could point me to whatever step I'm
missing...

 

Thanks,

Allon Shahar

 

------------------------------------------------------------------------
----------------------------

The filters are using are all versions of the common ITK filters:

 

typedef itk::ResampleImageFilter<InImageType, InImageType >
ResampleFilterType;

      ResampleFilterType::Pointer resampler = ResampleFilterType::New();

 

typedef itk::ThresholdImageFilter< InImageType >  ThreshFilterType;

ThreshFilterType::Pointer thresher = ThreshFilterType::New();

 

CastFilterType::Pointer  caster =  CastFilterType::New();

  

typedef itk::ImageFileWriter< OutImageType >  WriterType;

WriterType::Pointer      writer =  WriterType::New();

  

----------------------------------------------------

The problematic pipeline code is:

 

  // Write the union mask to the reference file.

  writer->SetFileName( fixedPrefix+outMaskSuffix );

  caster->SetInput( unionMask );

  writer->SetInput( caster->GetOutput()   );

  writer->Update();

 

  // Inverse transform to the individual test's plane.

  resampler->SetInput( unionMask );

        

  for ( i=0; i<numTests; i++ )

  {     

        for ( j=0; j<numParams; j++ ) finalParameters[j] =
collectParameters[i*numParams+j];

        transform->SetParameters( finalParameters );    

 

        movingPrefix = argv[i+2];

        transform->GetInverse( invTransform );

 

        matrix = invTransform->GetMatrix();

        offset = invTransform->GetOffset();

        std::cout << "Inverse Matrix = " << std::endl << matrix <<
std::endl;

        std::cout << "Inverse Offset = " << std::endl << offset <<
std::endl;

 

        resampler->SetTransform( invTransform );

        //resampler->Update();

        

        thresher->SetInput( resampler->GetOutput() );   

        //thresher->Update();

        

        caster->SetInput( thresher->GetOutput() );

        //caster->Update();

 

        //Write to file

  writer->SetFileName( movingPrefix+outMaskSuffix );

        writer->SetInput( caster->GetOutput()   );

        writer->Update();

  }

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070831/5844d6fa/attachment.htm


More information about the Insight-users mailing list