[Insight-users] input and output for BSpline parameters?
Luis Ibanez
luis.ibanez at kitware.com
Sat Aug 8 18:11:27 EDT 2009
Hi Motes,
You are right, in the example file in Examples, the input file (1) uses
the format:
x1y1z1, x2y2z2, ..., xNyNzN
while the array of parameters uses the format
x1x2x3x4x5x6..., y1y2y3y4y5y6..., z1z2z3z4z5z6..
In practice I will strongly encourage you to rather use the Transform
Readers and Writers.
See the following code for example:
#include "itkTransformFileWriter.h"
#include "itkTransformFileReader.h"
typedef itk::TransformFileReader TransformReaderType;
TransformReaderType::Pointer transformReader = TransformReaderType::New();
transformReader->SetFileName( "inputTransform.txt" );
transformReader->Update();
typedef TransformReaderType::TransformListType * TransformListType;
TransformListType transforms = transformReader->GetTransformList();
TransformReaderType::TransformListType::const_iterator titr =
transforms->begin();
if( !strcmp((*titr)->GetNameOfClass(),"BSplineDeformableTransform") )
{
TransformType::Pointer transform = TransformType::New();
transform = dynamic_cast< TransformType * >( titr->GetPointer() );
if( !transform )
{
std::cerr << "Error reading Transform" << std::endl;
return EXIT_FAILURE;
}
}
else
{
std::cerr << "Input file does not contain a BSpline Transform" <<
std::endl;
return EXIT_FAILURE;
}
then
registrationMethod->SetInitialParameters( transform->GetParameters() );
do registration
registrationMethod->Update();
and finally save the resulting transform
transform->SetParameters( registrationMethod->GetFinalParameters() )
typedef itk::TransformFileWriter TransformWriterType;
TransformWriterType::Pointer transformWriter = TransformWriterType::New();
transformWriter->SetFileName( "outputTransform.txt" );
transformWriter->SetInput( transform );
transformWriter->Update();
Regards,
Luis
---------------------------------------------
On Tue, Aug 4, 2009 at 9:55 AM, motes motes <mort.motes at gmail.com> wrote:
> I am trying to understand the format of the BSpline parameters. I have
> deformed a fixed image F with these parameters (read from a file):
>
>
> 1) Format A - input
>
> 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0
> 0 0 0 0 2 2 5 5 2 2 0
> 0 0 0 0 0
> 0 0 0 0 5 5 10 170 5 5 0
> 0 0 0 0 0
> 0 0 0 0 2 2 5 5 2 2 0
> 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0
>
> and stored the resulting moving image in M.
>
>
> When I run the registration algorithm I get the following transform
> parameters:
>
> 2) Format B - output
>
> [-0.00231844, -0.02326, 0.0484723, 0.0782189, 0.0917853, 0.119546,
> -0.00335514, -0.217619, -0.107065, 0, -0.0329693, -0.148395, 0.104663,
> -0.550282, -1.26802, -0.705694, 0.0873308, -0.309962, -0.802861, 0,
> 0.063379, 0.398289, -1.44105, -1.53938, -1.7608, -1.38484, -0.711425,
> -1.10221, -1.59358, 0, 0.298058, -0.564321, -1.91097, -3.58063, -6.30183,
> -4.78945, -1.61198, -0.70215, -0.954023, 0, 0.54965, -0.57544, -2.33652,
> -6.10376, -4.54323, -4.77601, -4.48725, -0.489267, -0.570523, 0, 0.668925,
> -0.46068, -2.42157, -4.74326, -12.8757, -6.57763, -1.16318, -3.09268,
> -0.411637, 0, 0.0390142, -0.273687, -0.624816, -1.51086, -2.18197, -1.86934,
> 0.297622, -1.07632, -0.0820767, 0, 0.0166208, -0.543326, 0.543721, -1.87936,
> 1.06337, 0.0752932, -0.0704278, -0.307334, -0.99684, 0, 0.00486263,
> -0.12788, -0.25644, -0.491107, 0.201335, -1.09141, -0.694021, -0.24188,
> -0.212387, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.000112593, 0.0110926,
> 0.0167261, -0.049946, -0.0783788, -0.0384529, 0.0407556, -0.154947,
> -0.0463077, 0, -0.0182507, 0.00359299, 0.00784705, 0.270986, 1.90373,
> 0.0225429, -0.684401, -0.250102, 0.0345052, 0, -0.0636621, -0.364021,
> -1.0357, -2.70395, -4.77634, -0.987079, -0.837127, 1.46826, 0.682614, 0,
> -0.0313031, -0.717254, -0.545265, -17.2006, -31.0422, -20.0047, -2.02679,
> -1.18301, 0.0228328, 0, -0.0125886, -4.34123, 0.0787134, -45.9453, -66.6283,
> -50.7082, 1.52779, -1.68643, -0.339206, 0, 0.65181, -8.32657, 6.24457,
> -37.9488, -110.562, -54.1226, 3.39012, -0.0921196, 0.12512, 0, 1.67071,
> 0.694154, -3.71556, 9.19359, -8.64445, 14.5316, -1.12059, -0.852576,
> 0.59615, 0, 0.001542, -0.94513, -0.844656, -6.95102, 1.63441, -5.0893,
> -3.16847, 1.19829, 0.0257344, 0, -0.186464, -1.54877, 0.321253, 0.403886,
> -0.983199, -1.91005, -0.53617, -0.353148, -0.0942512, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0]
>
> Now I would like to apply these parameters to the moving image M in a
> separate application and compare the result. But how do I convert the B
> format to the A format?
>
> I have read in Insight-DeformableRegistration-BSplines.ppt that the input
> format is read as:
>
> x1y1z1, x2y2z2, ..., xNyNzN
>
> and that the parameter array (output format) is read as:
>
> x1x2x3x4x5x6..., y1y2y3y4y5y6..., z1z2z3z4z5z6...
>
> Does anyone have a good idea on how to convert 2) into 1) based on this?
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090808/fbcf1f32/attachment.htm>
More information about the Insight-users
mailing list