[ITK] [ITK-users] FW: ExtractImageFilter.Update() inside loop works until 24th iteration

D'Isidoro Fabio fisidoro at ethz.ch
Sun Jan 1 17:40:00 EST 2017


Update: generalizing the problem, I figured out that any time the final filter is updated inside a loop, after a certain number of iterations the Update() does not work anymore and filter.GetOutput() returns always the same image as the last working iteration. I guess it's a memory issue. This issue happens no matter what the final filter of the pipeline is (I tried with ResampleImageFilter, Writer, ExtractImageFilter), and even when using the filter.InPlaceOn() when possible. This issue happens even if I split the pipeline and avoid connecting its components with SetInput( GetOutput() ).

Are filters of a pipeline not supposed to be used in a loop (where, in my case, the given transform changes at any loop)?

I guess the issue formulated this way is a common issue.

Thank you for your help.

Fabio.

From: D'Isidoro Fabio
Sent: Sonntag, 1. Januar 2017 19:48
To: insight-users at itk.org<mailto:insight-users at itk.org>
Subject: ExtractImageFilter.Update() inside loop works until 24th iteration

Hallo,

I work with ITK Python. I need to explore the domain of an image metric (like in MeanSquaresImageMetric1.cxx) for 2D/3D registration (using RayCastInterpolator). Since the metric works only between 2D/2D or 3D/3D images, I need to convert the generated DRR (SizeX, SizeY, 1) into a 2D image (SizeX, SizeY) with ExtractImageFilter, before metric evaluation. I then pass to the metric the converted 2D DRR as moving image and the 2D fixed image for similarity metric evaluation (with IdentityTransform, and NearestNeighbourInterpolator set for the metric). Metric evaluation is done in a loop within a range of the domain for the transform parameters. For each iteration of the loop (that is, different transforms used for generation of the DRR) the ExtractImageFilter is updated with Update().

The code runs but mysteriously stops working properly at the 24th iteration of the loop for the domain range. After the 24th iteration I figured no new DRR is generated and the metric value keeps constant at the value of the 24th iteration. I tried with input 3D volumes of different sizes and with different ranges for the transform parameters, but the code stops generating new DRRs always after the 24th iteration.

The important parts of the code are:

interpolatorRayCast = itk.RayCastInterpolateImageFunction[MovingImageType, ScalarType].New()
filterRayCast = itk.ResampleImageFilter[MovingImageType, MovingImageType].New()
filterRedim = itk.ExtractImageFilter[MovingImageType, FixedImageType].New()
...
filterRayCast.SetInput( movingImageReader.GetOutput() )
filterRayCast.SetInterpolator( interpolatorRayCast )
...
filterRedim.SetInput(filterRayCast.GetOutput())
...
for dx in translation_range_x:
    for dy in translation_range_y:
        for dz in translation_range_z:
...
transformDRR.SetParameters( transform_parameters )

                               filterRedim.Update()

             value = metric.GetValue()


I believe the pipeline might not be set properly, but I don't know where.

In attachment you find the code and the required inputs.

Any help would be highly appreciated, thank you!

Fabio.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170101/5de906d5/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list