[Insight-users] RE: Resample Time
Li, George (NIH/NCI)
ligeorge at mail.nih.gov
Fri Feb 18 09:53:55 EST 2005
Hi Luis:
First to clarify the confusion: In the resampling, it is ONE
resampling after registration. The comparison to 500 iteration
time in the registration work is purely a comparison of time;
Nothing else. I thought it would provide a helpful idea on the
time consumed without mentioning the machine setting. But, it
is not apparently.
Second, the trivial questions: I am using the itk1.8.0 release
on Pentium 4 Xeon 1.7Ghz, 1Gb memory with Windows2000. If it
takes 20 seconds for resampling in your case mentioned at the
end of your e_mail, and you think it is normal, then my 30 s
work seems well in the expected range. By the way, I am using
the Versor3DTransform.
Third, I don't quite understand your suggestion of "The way to
improve performance is to use multi-resolution." With all my
respects, a single resolution between fixed image and moving
image seems simplifying things, and therefore, the performance
would be better in principle. Actually, I would ask if there
is a way to turn off some of the not-going-to-use features based
on caller's inputs or dedicated "flags", so that the resampling
can be simplified and thus performs better. In my interactive
image registration program, similar resampling is usually done
within a second on the same machine. Of course, it only handles
one transform type and same resolution among images, while the
ITK filter is more versatile, handling all possible cases.
Finally, as you request, the portion of my code related to the
resampling is attached. Actually, it is nothing more than a bit
modification to ITK sample code.
Regards,
George
-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: Friday, February 18, 2005 1:49 AM
To: Li, George (NIH/NCI)
Cc: Insight-users at itk.org
Subject: Re: Resample Time
Hi George,
There is something confusing in your message.
The resample filter doesn't need an optimizer nor a metric.
Resampling is the action that you take once the registration has finished.
The ITK registration framework does not explicitly resample
the image. It just map the pixel coordinates one by one and interpolates the
values on the moving image.
Could you please let us know what Transform are you using ?
Could you please report the time of ONE iteration ?
Performance of the mapping should be evaluated on ONE iteration, since poor
parameter seetings of the optimizer maybe forcing the registration to use
too many iterations.
I would strongly encourage you to post a minimal in size
but fully working example of your code. There are so many parameters
involved in registration that it is unlikely that we could provide you with
any useful support only from a qualitative description of your registration.
Trivial questions:
1) Are you building for release ?
2) What kind of machine are you using ?
3) What is your operating system ?
Trivial answer to your question about performance:
The way to improve performance
is to use multi-resolultion.
You can register volumes of size 200x200x200 pixels in about 20 seconds when
using 3 levels of a multi-resolution pyramid, by subsampling by 2 at each
level, in a typical Pentium 4 machine at 2Ghz, and 512Mb of memory.
You can also reduce computation time by using NearestNeighborhod
interpolation instead of LinearInterpolation.
Regards
Luis
-----------------------------
Li, George (NIH/NCI) wrote:
> Hi, Luis and all:
>
> The resampleFilter seems taking longer than expected time
> to update(), usually around 30 seconds, roughly about 500 iteration
> time for OnePlusOneEvolutionary optimizer with Mattes metric on my
> computer.
>
> Is there a way to improve the performance? Or I did miss something? I
> would think voxel coordinate transformation, linear interpolation and
> voxel reassignment should not take more than 3 seconds for a regular
> sized volume, such as 320x320x100 volume.
>
> Thanks,
>
> George
>
>
-------------- next part --------------
The MI registration optimization is done and the final parameters are taken.
// Save the registered moving image. Guang 01/10/05.
ImageType::Pointer fixedImage = m_FixedImageReader->GetOutput();
ImageType::Pointer movingImage = m_MovingImageReader->GetOutput();
typedef itk::ResampleImageFilter<ImageType, ImageType> ResampleFilterType;
ResampleFilterType::Pointer resample = ResampleFilterType::New();
resample->SetInput( movingImage );
TransformType::Pointer finalTransform = TransformType::New();
finalTransform->SetParameters( finalParameters );
resample->SetTransform( finalTransform );
resample->SetInterpolator(interpolator); // default.
// Use the larger image size of the two for the output.
ImageType::SizeType fixedImageSize, movingImageSize;
fixedImageSize = fixedImage->GetLargestPossibleRegion().GetSize();
movingImageSize = movingImage->GetLargestPossibleRegion().GetSize();
if(fixedImageSize[2] >= movingImageSize[2]) {
resample->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );
}
else {
resample->SetSize( movingImage->GetLargestPossibleRegion().GetSize() );
}
// Cast the resampling transform the same as the registration and
// use the same center of rotation for the resampling as well.
((TransformType*)(resample->GetTransform()))->SetCenter(transform->GetCenter());
// Align moving image to fixed image.
resample->SetOutputOrigin( fixedImage->GetOrigin() );
resample->SetOutputSpacing( fixedImage->GetSpacing() );
PixelType defaultPixelValue = 0; // filling any uncovered voxels.
resample->SetDefaultPixelValue( defaultPixelValue );
resample->Update();
Do the voxel transfer to my own voxel format for output of the registered images.
More information about the Insight-users
mailing list