Hi Motes,<br><br>You are right, in the example file in Examples, the input file (1) uses <br>the format:<br><br> x1y1z1, x2y2z2, ..., xNyNzN<br><br>while the array of parameters uses the format<br><br> x1x2x3x4x5x6..., y1y2y3y4y5y6..., z1z2z3z4z5z6..<br>
<br><br>In practice I will strongly encourage you to rather use the Transform<br>Readers and Writers.<br><br><br>See the following code for example:<br><br>#include "itkTransformFileWriter.h"<br>#include "itkTransformFileReader.h"<br>
<br> typedef itk::TransformFileReader TransformReaderType;<br><br> TransformReaderType::Pointer transformReader = TransformReaderType::New();<br><br> transformReader->SetFileName( "inputTransform.txt" );<br>
transformReader->Update();<br><br> typedef TransformReaderType::TransformListType * TransformListType;<br><br> TransformListType transforms = transformReader->GetTransformList();<br><br> TransformReaderType::TransformListType::const_iterator titr = transforms->begin();<br>
<br> if( !strcmp((*titr)->GetNameOfClass(),"BSplineDeformableTransform") )<br> {<br> TransformType::Pointer transform = TransformType::New();<br> transform = dynamic_cast< TransformType * >( titr->GetPointer() );<br>
<br> if( !transform )<br> {<br> std::cerr << "Error reading Transform" << std::endl;<br> return EXIT_FAILURE;<br> }<br> } <br> else<br> {<br> std::cerr << "Input file does not contain a BSpline Transform" << std::endl;<br>
return EXIT_FAILURE;<br> }<br><br><br>then<br><br> registrationMethod->SetInitialParameters( transform->GetParameters() );<br><br>do registration<br><br> registrationMethod->Update();<br><br>and finally save the resulting transform<br>
<br> transform->SetParameters( registrationMethod->GetFinalParameters() )<br><br> typedef itk::TransformFileWriter TransformWriterType;<br><br> TransformWriterType::Pointer transformWriter = TransformWriterType::New();<br>
<br> transformWriter->SetFileName( "outputTransform.txt" );<br> transformWriter->SetInput( transform );<br> transformWriter->Update();<br><br><br><br><br>Regards,<br><br><br><br> Luis<br><br><br>
<br><br><br><br>---------------------------------------------<br><div class="gmail_quote">On Tue, Aug 4, 2009 at 9:55 AM, motes motes <span dir="ltr"><<a href="mailto:mort.motes@gmail.com">mort.motes@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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):<br>
<br><br>1) Format A - input<br><br> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <br> 0 0 0 0 2 2 5 5 2 2 0 0 0 0 0 0 <br> 0 0 0 0 5 5 10 170 5 5 0 0 0 0 0 0 <br>
0 0 0 0 2 2 5 5 2 2 0 0 0 0 0 0 <br> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <br> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <br><br>and stored the resulting moving image in M.<br><br><br>When I run the registration algorithm I get the following transform parameters:<br>
<br>2) Format B - output<br><br>[-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]<br>
<br>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?<br><br>I have read in Insight-DeformableRegistration-BSplines.ppt that the input format is read as:<br>
<br>x1y1z1, x2y2z2, ..., xNyNzN<br><br>and that the parameter array (output format) is read as:<br><br>x1x2x3x4x5x6..., y1y2y3y4y5y6..., z1z2z3z4z5z6...<br><br>Does anyone have a good idea on how to convert 2) into 1) based on this?<br>
<br>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br><br>