[Insight-users] Transform DICOM Volume

Laurent PAUL Laurent.Paul at orto.ucl.ac.be
Wed May 3 10:58:52 EDT 2006


Hi users,

I need to transform a dicom volume from a registration result.
First, I make a registration (Mean squares metric,
VersorRigid3DTransform). I save registration parameters into a file. I
give this file as entry to a program which transforms the volume and save
it as dicom.

The transformation used is the same one that in the registration process.
Parameters and center are well passed to the transform program.
During execution (in registration process and transformation) I display
the transform. Parameters are exactly the same.

The result is not fine since resulting volume seems to be translated (and
even rotated) and thus not superposed into the first one.
I do that with Volume files (Analyze format), and it works perfectly.

The code used for transformation is the same as bulding the new volume in
the registration process.
This the code:

//After reading dicom serie and parse parameters file
typedef short InputPixelType;
typedef itk::Image < InputPixelType, 3 > ImageType;
typedef itk::Image < InputPixelType, 2 > OutputImageType;

typedef itk::VersorRigid3DTransform < double > TransformType;
TransformType::Pointer 	Versor3DTransform = TransformType::New();

typedef itk::LinearInterpolateImageFunction <ImageType,double>
InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();

typedef itk::ResampleImageFilter< ImageType, ImageType >   
ResampleFilterType;
ResampleFilterType::Pointer resample = ResampleFilterType::New();

typedef itk::ImageSeriesWriter < ImageType, OutputImageType >  WriterType;
WriterType::Pointer writer = WriterType::New();

ImageType::SizeType Size = TargetImage->GetLargestPossibleRegion().GetSize();
ImageType::SpacingType spacing = TargetImage->GetSpacing();
ResampleFilterType::OriginPointType Origin = TargetImage->GetOrigin();

Versor3DTransform->SetParameters( FinalParameters ); //FinalParameters
from file
Versor3DTransform->SetCenter( Center ); //Center from file
std::cout << "Versor3DTransform: " << Versor3DTransform << std::endl;

resample->SetInput( VolumeToMove );
resample->SetTransform( Versor3DTransform );
resample->SetSize( Size  );
resample->SetOutputOrigin( Origin );
resample->SetOutputSpacing( spacing );
resample->SetInterpolator( interpolator.GetPointer() );
resample->SetDefaultPixelValue( 0 );

OutputNamesGenerator->SetStartIndex(1);
OutputNamesGenerator->SetEndIndex( Size[2]);
OutputNamesGenerator->SetSeriesFormat(directory);

writer->SetImageIO( movinggdcmIO );
writer->SetFileNames(OutputNamesGenerator->GetFileNames());
writer->SetMetaDataDictionaryArray( DicomDictionaryArray);//dictionary
coming from reader
writer->SetInput(resample->GetOutput());

  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & err )
    {
    std::cout << "ExceptionObject caught !" << std::endl;
    std::cout << err << std::endl;
    return ;
    }


I'm pretty sure that it is just a center problem. I think resample first
create an image with size, origin and spacing from the targetImage and
then transform around center, but old coordinates center aren't the same
that new coordinates center, so transform result is bad.
Isn't it?
How to avoid this behavior?
Transformation around origin?
Dicom tags to change (Image origin, Patient position...)?

Thanks for help.

Laurent.




More information about the Insight-users mailing list