<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Nick,<br>
<br>
sorry for this late reply, I was out of office over the past days.<br>
<br>
Thank you very much for looking at this in such detail!<br>
<br>
Best,<br>
Frank<br>
<br>
<br>
On 08/01/2013 04:09 PM, Nick Tustison wrote:<br>
</div>
<blockquote
cite="mid:4203253F-3C27-431D-A1B5-42CBA43730C6@gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
Hi Frank,
<div><br>
</div>
<div>I don't see anything immediately. I can't work on it now but
will most likely get to</div>
<div>it this weekend. I'll also take your code and, after we
figure out what's going on,</div>
<div>add it as a test in using the b-spline transform with the new
framework since</div>
<div>we currently don't have one (outside of our ANTs tool).</div>
<div><br>
</div>
<div>Nick</div>
<div><br>
</div>
<div><br>
<div>
<div>
<div>On Jul 31, 2013, at 11:10 AM, Frank Preiswerk <<a
moz-do-not-send="true"
href="mailto:frank.preiswerk@unibas.ch">frank.preiswerk@unibas.ch</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Nick,<br>
<br>
I have noticed that the error is not thrown if I do
not set the initial transform for the moving image via
registrationMethod->SetMovingInitialTransform
(although the optimizer then produces a constant error
value and the registration simply iterates without
altering the deformation field - I don't know if this
is an unrelated problem).<br>
<br>
My setup is simple, i.e. no multi-resolution involved.
I'm doing essentially this:<br>
<br>
typedef itk::BSplineTransform< PixelType,
ImageDimension > TransformType;<br>
typedef itk::MeanSquaresImageToImageMetricv4<
ImageType, ImageType > MetricType;<br>
typedef itk::GradientDescentOptimizerv4 OptimizerType;<br>
typedef itk::ImageRegistrationMethodv4< ImageType,
ImageType, TransformType > RegistrationMethodType;<br>
typedef
itk::RegistrationParameterScalesFromPhysicalShift<
MetricType > ScalesEstimatorType;<br>
<br>
MetricType::Pointer metric = MetricType::New();<br>
<br>
OptimizerType::Pointer optimizer =
OptimizerType::New();<br>
optimizer->SetNumberOfIterations( 200 );<br>
optimizer->SetDoEstimateLearningRateOnce( true );<br>
optimizer->SetMinimumConvergenceValue( 1e-16 );<br>
optimizer->SetConvergenceWindowSize( 20 );<br>
optimizer->SetMaximumStepSizeInPhysicalUnits( 2 );<br>
<br>
ScalesEstimatorType::Pointer scalesEstimator =
ScalesEstimatorType::New();<br>
scalesEstimator->SetMetric( metric );<br>
scalesEstimator->SetTransformForward( true );<br>
optimizer->SetScalesEstimator( scalesEstimator );<br>
optimizer->SetDoEstimateScales( true );<br>
<br>
RegistrationMethodType::Pointer registrationMethod =
RegistrationMethodType::New();<br>
registrationMethod->SetOptimizer( optimizer );<br>
registrationMethod->SetFixedImage( fixedImage );<br>
registrationMethod->SetMovingImage( movingImage );<br>
registrationMethod->SetFixedInitialTransform(
initialFixedTransform );<br>
registrationMethod->SetMovingInitialTransform(
initialMovingTransform );<br>
registrationMethod->SetNumberOfLevels( 1 );<br>
registrationMethod->SetMetric( metric );<br>
registrationMethod->SetMetricSamplingStrategy(
RegistrationMethodType::NONE );<br>
<br>
<br>
<br>
<br>
The initial transforms are initialized like this:<br>
<br>
TransformType::PhysicalDimensionsType
fixedPhysicalDimensions;<br>
TransformType::MeshSizeType meshSize;<br>
for( unsigned int i=0; i < ImageDimension; i++ )<br>
{<br>
fixedPhysicalDimensions[i] =
fixedImage->GetSpacing()[i] *<br>
static_cast<double>(<br>
movingImage->GetLargestPossibleRegion().GetSize()[i]
- 1 );<br>
}<br>
unsigned int SplineOrder = 3;<br>
unsigned int numberOfGridNodesInOneDimension = 5;<br>
meshSize.Fill( numberOfGridNodesInOneDimension -
SplineOrder );<br>
initialMovingTransform->SetTransformDomainOrigin(
movingImage->GetOrigin() );<br>
initialMovingTransform->SetTransformDomainPhysicalDimensions(
fixedPhysicalDimensions );<br>
initialMovingTransform->SetTransformDomainMeshSize(
meshSize );<br>
initialMovingTransform->SetTransformDomainDirection(
movingImage->GetDirection() );<br>
TransformType::ParametersType initialMovingParameters(
initialMovingTransform->GetNumberOfParameters() );<br>
initialMovingParameters.Fill(0.0);<br>
initialMovingTransform->SetParameters(initialMovingParameters);<br>
<br>
<br>
Thanks for the link to the relevant ANTs class. I took
a look at the relevant lines but it didn't help me
either.<br>
<br>
Many thanks,<br>
Frank<br>
<br>
<br>
<br>
<br>
<br>
On 07/31/2013 01:21 PM, Nick Tustison wrote:<br>
</div>
<blockquote
cite="mid:A17F6726-D128-435D-B37A-1F6A4D831A7D@gmail.com"
type="cite"> Hi Frank,
<div><br>
</div>
<div>I'm cc'ing the insight users list as others might
be interested. </div>
<div><br>
</div>
<div>How are you setting up the registration? In case
you were interested, we have </div>
<div>a pretty comprehensive application which ties in
all the new registration stuff </div>
<div>in a single application. In it, we set up the
B-spline transform which you can </div>
<div>view at</div>
<div><br>
</div>
<div><a moz-do-not-send="true"
href="https://github.com/stnava/ANTs/blob/master/Examples/itkantsRegistrationHelper.hxx">https://github.com/stnava/ANTs/blob/master/Examples/itkantsRegistrationHelper.hxx</a></div>
<div><br>
</div>
<div>starting at line 1896.</div>
<div><br>
</div>
<div>Nick</div>
<div><br>
<div>
<div>
<div>On Jul 31, 2013, at 4:45 AM, Frank
Preiswerk <<a moz-do-not-send="true"
href="mailto:frank.preiswerk@unibas.ch">frank.preiswerk@unibas.ch</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Nick,<br>
<br>
I have adapted my code to work with the
new ITKv4 classes. For the affine
registration this worked well. But for the
BSplineTransform, I get the following
error during optimization:<br>
<br>
<meta name="qrichtext" content="1">
<div style="margin: 0px; text-indent: 0px;
"><!--StartFragment--><span style="
font-family:'Monospace';
font-size:9pt; color:#b20808;">/usr/local/include/ITK-4.4/itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx:258:</span></div>
<div style="margin: 0px; text-indent: 0px;
"><span style=" font-family:'Monospace';
font-size:9pt; color:#b20808;">Exception
in GetValueAndDerivativeProcessPoint:</span></div>
<div style="margin: 0px; text-indent: 0px;
"><span style=" font-family:'Monospace';
font-size:9pt; color:#b20808;">/usr/local/include/ITK-4.4/itkBSplineBaseTransform.h:282:</span></div>
<div style="margin: 0px; text-indent: 0px;
"><span style=" font-family:'Monospace';
font-size:9pt; color:#b20808;">itk::ERROR:
BSplineTransform(0x384cb00):
ComputeJacobianWithRespectToPosition
not yet implemented for
BSplineTransform<br>
</span></div>
<div style="margin: 0px; text-indent: 0px;
"><span style=" font-family:'Monospace';
font-size:9pt; color:#b20808;"><br>
</span><!--EndFragment--></div>
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>I use GradientDescentOptimizerv4 and
MeanSquaresImageToImageMetricv4 and also
tried substituting them with
QuasiNewtonOptimizerv4 and
MattesMutualInformationImageToImageMetricv4
but to no avail.<br>
<br>
Sorry to bother you but I could not find
any examples on the web that shows how the
BSplineTransform can be used in the new
framework.<br>
<br>
Many thanks!<br>
Frank<br>
<br>
<br>
<br>
<br>
On 07/30/2013 04:09 PM, Nick Tustison
wrote:<br>
</div>
<blockquote
cite="mid:926583E4-B993-45F2-B82D-4C7D27D5DBD3@gmail.com"
type="cite">
<pre wrap="">Hi Frank,
I don't think that anybody on the registration team has tried to use the composite
transform with the old registration framework. I'm not even sure that it would work
as both the optimization and metrics are completely separate between ITKv3 and
ITKv4. In suggesting the use of the CompositeTransform class, I didn't catch that
you were sticking with ITKv3. Sorry about that.
There was some earlier work by Torsten and Marius & Stefan who gave us some
ideas for the current composite transform. Perhaps one of those contributions would
fit your needs.
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.insight-journal.org/browse/publication/143">http://www.insight-journal.org/browse/publication/143</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.insight-journal.org/browse/publication/91">http://www.insight-journal.org/browse/publication/91</a>
Also, I would be remiss if I didn't at least proselyte concerning the utility of the new
registration framework. There's quite a few advantages in addition to the composite
transform:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK/Release_4/Why_Switch_to_ITKv4#New_Registration_Framework">http://www.itk.org/Wiki/ITK/Release_4/Why_Switch_to_ITKv4#New_Registration_Framework</a>
Nick
On Jul 30, 2013, at 7:35 AM, Frank Preiswerk <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:frank.preiswerk@unibas.ch"><frank.preiswerk@unibas.ch></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Nick,
I have a few additional questions and I would be very glad if you could help me getting on the right track.
Your suggestion to use the CompositeTransform guided me to the new registration framework. I have played around a bit and now I'm unsure which version to use.
First of all, in ImageRegistrationMethodv4 there is a method SetMovingInitialTransform that probably does exactly what I need. As far as I understand it, one can achieve the same with the old framework by using CompositeTransform like this:
compositeTransform->AddTransform(affineTransform); // the output from the prior affine step
compositeTransform->AddTransform(bsplineTransform);
compositeTransform->SetOnlyMostRecentTransformToOptimizeOn(); // activate the bspline transform for the next optimization
registration->SetTransform( compositeTransform );
Is this the way how to properly use CompositeTransform in the old registration framework? And is my assumption correct that SetMovingInitialTransform would be sufficient when using the new framework?
Thanks a lot for your efforts,
Frank
On 07/29/2013 12:16 PM, Nick Tustison wrote:
</pre>
<blockquote type="cite">
<pre wrap="">You should try using the composite transform
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.itk.org/Doxygen/html/classitk_1_1CompositeTransform.html">http://www.itk.org/Doxygen/html/classitk_1_1CompositeTransform.html</a>
Nick
On Jul 29, 2013, at 4:49 AM, Frank Preiswerk <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:frank.preiswerk@unibas.ch"><frank.preiswerk@unibas.ch></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,
I'm writing a program that performs image registration by first computing an
affine transformation followed by a bspline deformation. The bspline
registration should be initialized with the output of the affine
registration.
I'm using ITK 4.4. The example DeformableRegistration15.cxx intends to do
the above but it seems that the BSplineTransform is actually not initialized
with the output of the affine step, as already reported earlier:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.itk.org/pipermail/insight-users/2012-May/044623.html">http://www.itk.org/pipermail/insight-users/2012-May/044623.html</a>
ITK 3's BSplineDeformableTransform had a method SetBulkTransform to concat
the bspline transform with another transform, but in ITK 4's
BSplineTransform this method was removed. So the question remains how to
properly initialize a BSplineTransform with an affine (or any other)
registration output.
Computing the parameters of the bspline transform by applying the affine
transform to the grid nodes is an option. But something like
SetBulkTransform would be much more convenient.
I'm thankful for any hints.
Regards,
Frank
--
View this message in context: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://itk-insight-users.2283740.n2.nabble.com/Initializing-a-BSplineTransform-in-ITK-4-4-tp7583607.html">http://itk-insight-users.2283740.n2.nabble.com/Initializing-a-BSplineTransform-in-ITK-4-4-tp7583607.html</a>
Sent from the ITK Insight Users mailing list archive at <a moz-do-not-send="true" href="http://nabble.com/">Nabble.com</a>.
_____________________________________
Powered by <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="http://www.kitware.com/">www.kitware.com</a>
Visit other Kitware open-source projects at
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Kitware offers ITK Training Courses, for more information visit:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a>
Please keep messages on-topic and check the ITK FAQ at:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
</pre>
</blockquote>
</blockquote>
<pre wrap="">--
Frank Preiswerk, Senior Researcher
Medical Image Analysis Center (MIAC)
University of Basel c/o University Hospital Basel
Spitalstrasse 21
CH-4031 Basel
Switzerland
Tel: +41 61 265 96 58
Fax: +41 61 265 96 68
Office:Schanzenstrasse 46, Room 321
</pre>
</blockquote>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Frank Preiswerk, Senior Researcher
Medical Image Analysis Center (MIAC)
University of Basel c/o University Hospital Basel
Spitalstrasse 21
CH-4031 Basel
Switzerland
Tel: +41 61 265 96 58
Fax: +41 61 265 96 68
Office:Schanzenstrasse 46, Room 321</pre>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Frank Preiswerk, Senior Researcher
Medical Image Analysis Center (MIAC)
University of Basel c/o University Hospital Basel
Spitalstrasse 21
CH-4031 Basel
Switzerland
Tel: +41 61 265 96 58
Fax: +41 61 265 96 68
Office:Schanzenstrasse 46, Room 321</pre>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Frank Preiswerk, Senior Researcher
Medical Image Analysis Center (MIAC)
University of Basel c/o University Hospital Basel
Spitalstrasse 21
CH-4031 Basel
Switzerland
Tel: +41 61 265 96 58
Fax: +41 61 265 96 68
Office:Schanzenstrasse 46, Room 321</pre>
</body>
</html>