[Elastix] Problem with CUDA re-sampler

M.Staring at lumc.nl M.Staring at lumc.nl
Mon Jul 16 10:32:17 CEST 2012

Hi Ruwan,
elastix indeed did not support the writing of resultant images after each iteration (only at the end and after each resolution). I added a function that does this, see the attached patch.
I only tested this for the normal resampler. It should automatically also work for the CUDAResampler, but please test this.
Note that we always resample the full moving image to the full fixed image region. This is specified in the function BeforeRegistrationBase(). If you want you can add an option "LetResamplerFollowPyramid" to the resampler base. This can be done by adding a function BeforeEachResolutionBase(), with contents similar to BeforeRegistrationBase(), but instead specifying the blurred & resized moving image, and corresponding sizes of the fixed image pyramid.
Also note that you don't need to put cuda specific code in the resampler base. In fact this is not the intention of the base class. Just implement the options you want with a normal resampler in mind and it should also work for the cuda resampler.
Regards, Marius
From: elastix-bounces at bigr.nl [mailto:elastix-bounces at bigr.nl] On Behalf Of Ruwan Tennakoon
Sent: maandag 16 juli 2012 7:25
To: elastix at bigr.nl
Subject: [Elastix] Problem with CUDA re-sampler

I'm trying to generale the transformed moving image after every iteration in a multi-resolution (two levels) registration process using the CUDA re-sampler. in order to do this I've modified the elxResamplerBase.hxx and added the function in code.txt file to it. in it I set the input image to a copy of the fixed image down converted to the correct resolution of the registration level.

but when the program is running it get stuck as soon as the resolution is changed to level 2 from level 1 (illustrate in the log file attached).

according to the analysis it gets stuck inside the function
::cudaCastToHost( const size_t sizevalue, const TInternalImageType* src, TInternalImageType* tmp_src, TImageType* dst )

in cudaResampleImageFilter.cu. it seams like the output image is not defined with enough memory (its defined with the size m_MaxNumberOfVoxelsPerIteration which is still set to the no of voxels in the previous level input image). I also tried changing the output image definitions in ::cudaMallocImageData() function to

this->m_OutputImage = cuda::cudaMalloc<TInternalImageType>(static_cast<unsigned int>( nrOfOutputVoxels ) ); and also tryied to force the m_MaxNumberOfVoxelsPerIteration  = static_cast<unsigned int>( nrOfOutputVoxels ) ;

but the problem was not resolved. I would be very grateful if you could help me resolve this issue. thank you very much.

Best Regards,
Ruwan Tennakoon
PhD candidate
Faculty of Engineering and Industrial Sciences
Swinburne University of Technology
(CRICOS Provider 00111D)
John Street Hawthorn VIC 3122
Email: RTENNAKOON at groupwise.swin.edu.au<mailto:RTENNAKOON at groupwise.swin.edu.au>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bigr.nl/pipermail/elastix/attachments/20120716/71193c95/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resampler.patch
Type: application/octet-stream
Size: 20175 bytes
Desc: resampler.patch
URL: <http://lists.bigr.nl/pipermail/elastix/attachments/20120716/71193c95/attachment.obj>

More information about the Elastix mailing list