<div dir="ltr"><div>Thanks very much for the reply, Arnaud!  Yes, I had originally begin with the v4 version, but ran into trouble when I tried to use it with LevenbergMarquardtOptimizer.</div><div><br></div><div>EuclideanDistancePointMetric inherits from MultipleValuedCostFunction, wherease EuclideanDistancePointSetToPointSetMetricv4 inherits from SingleValuedCostFunctionv4.  To the best that I can tell, LevenbergMarquardtOptimizer expects its cost function to inherit from MultipleValuedCostFunction.  I tried wrapping EuclideanDistancePointSetToPointSetMetricv4 in an adapter class inheriting from MultipleValuedCostFunction, where I returned 1 from GetNumberOfValues() and wrapped the return of GetValue() in an itk::Array length 1.  However, when I did this, I got a warning saying (if I remember correctly) that there was a mismatch between the number of unknowns and residuals.  I realized that wrapping a "new" cost function class in an "old" cost function class was a hacky way to go about it in the first place, so I abandoned this method a while ago.</div><div><br></div><div>Is there a way to use the v4 version with LevenbergMarquardtOptimizer?  Is there a reason that the v3 EuclideanDistanceMetric is multiple valued, whereas the v4 metric is single valued?  Is a v4 LevenbergOptimizer in development, and will it be single valued or multiple valued?</div><div><br></div><div>Apologies in advance if I've been going about this the wrong way--I've been using ITK for a while, but am only just beginning to learn about optimization/registration.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 21, 2015 at 7:55 AM, Arnaud Gelas <span dir="ltr"><<a href="mailto:arnaudgelas@gmail.com" target="_blank">arnaudgelas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Davis,<br>
<br>
If you use the ITKv4 version of Metric, it compiles and works fine!<br>
<br>
—<br>
<br>
Here is the code<br>
<br>
#include "itkQuadEdgeMesh.h"<br>
#include "itkRegularSphereMeshSource.h"<br>
#include "itkEuclideanDistancePointSetToPointSetMetricv4.h"<br>
<span class="">#include "itkIdentityTransform.h"<br>
<br>
typedef itk::Mesh< double, 3 > TFMesh; // If you change this to itk::QuadEdgeMesh, it works<br>
typedef itk::QuadEdgeMesh< double, 3 > TMMesh; // Or if you change this to itk::Mesh, it also works<br>
typedef itk::RegularSphereMeshSource< TFMesh > TFSource;<br>
typedef itk::RegularSphereMeshSource< TMMesh > TMSource;<br>
</span>typedef itk::EuclideanDistancePointSetToPointSetMetricv4< TFMesh, TMMesh > TMetric;<br>
<span class="">typedef itk::IdentityTransform< double, 3 > TIdentity;<br>
<br>
int main(int argc, char ** argv)<br>
{<br>
<br>
 TFSource::Pointer fixed = TFSource::New();<br>
 fixed->Update();<br>
<br>
 TMSource::Pointer moving = TMSource::New();<br>
 moving->Update();<br>
<br>
 TIdentity::Pointer identity = TIdentity::New();<br>
<br>
 TMetric::Pointer metric = TMetric::New();<br>
 metric->SetFixedPointSet( fixed->GetOutput() );<br>
 metric->SetMovingPointSet( moving->GetOutput() );<br>
 metric->SetTransform( identity );<br>
</span> std::cout << metric->GetValue() << std::endl;<br>
<br>
 return EXIT_SUCCESS;<br>
<div class="HOEnZb"><div class="h5"><br>
}<br>
<br>
<br>
> On 20 May 2015, at 18:04, DVigneault <<a href="mailto:davis.vigneault@gmail.com">davis.vigneault@gmail.com</a>> wrote:<br>
><br>
> All--<br>
><br>
> I'm attempting to use itk::EuclideanDistancePointMetric to compare an<br>
> itk::Mesh to an itk::QuadEdgeMesh.  This works as expected if templated over<br>
> two meshes of the same type (i.e., itk::Mesh and itk::Mesh or<br>
> itk::QuadEdgeMesh and itk::QuadEdgeMesh).  However, if I attempt to mix the<br>
> two, and compare an itk::Mesh and an itk::QuadEdgeMesh, I get a build error,<br>
> copied below, along with a minimal example of the problem.<br>
><br>
> I'm having some trouble decoding the error, but it looks to me as though the<br>
> filter is having trouble converting between iterator types.  Does this have<br>
> something to do with a difference between how itk::Mesh and<br>
> itk::QuadEdgeMesh define their iterators?<br>
><br>
> Thank you in advance for your help!<br>
><br>
> Best,<br>
><br>
> --Davis<br>
><br>
> #include "itkQuadEdgeMesh.h"<br>
> #include "itkRegularSphereMeshSource.h"<br>
> #include "itkEuclideanDistancePointMetric.h"<br>
> #include "itkIdentityTransform.h"<br>
><br>
> typedef itk::Mesh< double, 3 > TFMesh; // If you change this to<br>
> itk::QuadEdgeMesh, it works<br>
> typedef itk::QuadEdgeMesh< double, 3 > TMMesh; // Or if you change this to<br>
> itk::Mesh, it also works<br>
> typedef itk::RegularSphereMeshSource< TFMesh > TFSource;<br>
> typedef itk::RegularSphereMeshSource< TMMesh > TMSource;<br>
> typedef itk::EuclideanDistancePointMetric< TFMesh, TMMesh > TMetric;<br>
> typedef itk::IdentityTransform< double, 3 > TIdentity;<br>
><br>
> int main(int argc, char ** argv)<br>
> {<br>
><br>
>  TFSource::Pointer fixed = TFSource::New();<br>
>  fixed->Update();<br>
><br>
>  TMSource::Pointer moving = TMSource::New();<br>
>  moving->Update();<br>
><br>
>  TIdentity::Pointer identity = TIdentity::New();<br>
><br>
>  TMetric::Pointer metric = TMetric::New();<br>
>  metric->SetFixedPointSet( fixed->GetOutput() );<br>
>  metric->SetMovingPointSet( moving->GetOutput() );<br>
>  metric->SetTransform( identity );<br>
>  std::cout << metric->GetValue(identity->GetParameters()) << std::endl;<br>
><br>
>  return EXIT_SUCCESS;<br>
><br>
> }<br>
><br>
><br>
> $ make<br>
> Scanning dependencies of target AmoebaOptimization<br>
> [100%] Building CXX object<br>
> CMakeFiles/AmoebaOptimization.dir/AmoebaOptimization.cxx.o<br>
> In file included from<br>
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.h:125:0,<br>
>                 from<br>
> /home/davis/Developer/oxford/Stebbing_Method/Test/src/AmoebaOptimization.cxx:3:<br>
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx: In<br>
> instantiation of ‘itk::EuclideanDistancePointMetric<TFixedPointSet,<br>
> TMovingPointSet, TDistanceMap>::MeasureType<br>
> itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,<br>
> TDistanceMap>::GetValue(const TransformParametersType&) const [with<br>
> TFixedPointSet = itk::Mesh<double, 3u>; TMovingPointSet =<br>
> itk::QuadEdgeMesh<double, 3u>; TDistanceMap = itk::Image<short unsigned int,<br>
> 3u>; itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,<br>
> TDistanceMap>::MeasureType = itk::Array<double>;<br>
> itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,<br>
> TDistanceMap>::TransformParametersType = itk::OptimizerParameters<double>]’:<br>
> /home/davis/Developer/oxford/Stebbing_Method/Test/src/AmoebaOptimization.cxx:28:58:<br>
> required from here<br>
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx:74:63: error:<br>
> conversion from ‘itk::MapContainer<long unsigned int,<br>
> itk::QuadEdgeMeshPoint&lt;float, 3u, itk::GeometricalQuadEdge&lt;long<br>
> unsigned int, long unsigned int, bool, bool, true> > >::ConstIterator’ to<br>
> non-scalar type ‘itk::EuclideanDistancePointMetric<itk::Mesh&lt;double, 3u>,<br>
> itk::QuadEdgeMesh<double, 3u> >::PointIterator {aka<br>
> itk::VectorContainer<long unsigned int, itk::Point<float, 3u><br>
>> ::ConstIterator}’ requested<br>
>   PointIterator pointItr = movingPointSet->GetPoints()->Begin();<br>
>                                                               ^<br>
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx:75:61: error:<br>
> conversion from ‘itk::MapContainer<long unsigned int,<br>
> itk::QuadEdgeMeshPoint&lt;float, 3u, itk::GeometricalQuadEdge&lt;long<br>
> unsigned int, long unsigned int, bool, bool, true> > >::ConstIterator’ to<br>
> non-scalar type ‘itk::EuclideanDistancePointMetric<itk::Mesh&lt;double, 3u>,<br>
> itk::QuadEdgeMesh<double, 3u> >::PointIterator {aka<br>
> itk::VectorContainer<long unsigned int, itk::Point<float, 3u><br>
>> ::ConstIterator}’ requested<br>
>   PointIterator pointEnd = movingPointSet->GetPoints()->End();<br>
>                                                             ^<br>
> make[2]: *** [CMakeFiles/AmoebaOptimization.dir/AmoebaOptimization.cxx.o]<br>
> Error 1<br>
> make[1]: *** [CMakeFiles/AmoebaOptimization.dir/all] Error 2<br>
> make: *** [all] Error 2<br>
><br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/EuclideanDistancePointMetric-Error-when-comparing-Mesh-to-QuadEdgeMesh-tp7587372.html" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/EuclideanDistancePointMetric-Error-when-comparing-Mesh-to-QuadEdgeMesh-tp7587372.html</a><br>
> Sent from the ITK Insight Users mailing list archive at Nabble.com.<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>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <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://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br>
</div></div></blockquote></div><br></div>