<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Davis,<div class=""><br class=""></div><div class="">Sounds like a bug to me (not an expert on the registration part though).</div><div class=""><br class=""></div><div class="">You can definitively submit a patch on gerrit </div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span><a href="http://review.source.kitware.com" class="">http://review.source.kitware.com</a></div><div class=""><br class=""></div><div class="">In such a case, convert your examples into one test to be included and make sure your patch fixes this test and does not break the rest of the toolkit.</div><div class=""><br class=""></div><div class="">Looking forward to seeing your patch on gerrit</div><div class=""><br class=""></div><div class="">Best</div><div class="">Arnaud</div><div class=""><br class=""></div><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On 21 May 2015, at 12:11, Davis Vigneault <<a href="mailto:davis.vigneault@gmail.com" class="">davis.vigneault@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">An update: the problem here seems to be that itkPointSetToPointSetMetric only defines one iterator, which it uses on both the fixed and moving pointsets. If I add fixed- and moving-specific iterators and change EuclideanDistancePointMetric accordingly, the original example compiles and gives the correct answer. Is this, in fact, a bug? If so, I'd be happy to attempt a patch.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, May 21, 2015 at 10:43 AM, Davis Vigneault <span dir="ltr" class=""><<a href="mailto:davis.vigneault@gmail.com" target="_blank" class="">davis.vigneault@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, May 21, 2015 at 7:55 AM, Arnaud Gelas <span dir="ltr" class=""><<a href="mailto:arnaudgelas@gmail.com" target="_blank" class="">arnaudgelas@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Davis,<br class="">
<br class="">
If you use the ITKv4 version of Metric, it compiles and works fine!<br class="">
<br class="">
—<br class="">
<br class="">
Here is the code<br class="">
<br class="">
#include "itkQuadEdgeMesh.h"<br class="">
#include "itkRegularSphereMeshSource.h"<br class="">
#include "itkEuclideanDistancePointSetToPointSetMetricv4.h"<br class="">
<span class="">#include "itkIdentityTransform.h"<br class="">
<br class="">
typedef itk::Mesh< double, 3 > TFMesh; // If you change this to itk::QuadEdgeMesh, it works<br class="">
typedef itk::QuadEdgeMesh< double, 3 > TMMesh; // Or if you change this to itk::Mesh, it also works<br class="">
typedef itk::RegularSphereMeshSource< TFMesh > TFSource;<br class="">
typedef itk::RegularSphereMeshSource< TMMesh > TMSource;<br class="">
</span>typedef itk::EuclideanDistancePointSetToPointSetMetricv4< TFMesh, TMMesh > TMetric;<br class="">
<span class="">typedef itk::IdentityTransform< double, 3 > TIdentity;<br class="">
<br class="">
int main(int argc, char ** argv)<br class="">
{<br class="">
<br class="">
TFSource::Pointer fixed = TFSource::New();<br class="">
fixed->Update();<br class="">
<br class="">
TMSource::Pointer moving = TMSource::New();<br class="">
moving->Update();<br class="">
<br class="">
TIdentity::Pointer identity = TIdentity::New();<br class="">
<br class="">
TMetric::Pointer metric = TMetric::New();<br class="">
metric->SetFixedPointSet( fixed->GetOutput() );<br class="">
metric->SetMovingPointSet( moving->GetOutput() );<br class="">
metric->SetTransform( identity );<br class="">
</span> std::cout << metric->GetValue() << std::endl;<br class="">
<br class="">
return EXIT_SUCCESS;<br class="">
<div class=""><div class=""><br class="">
}<br class="">
<br class="">
<br class="">
> On 20 May 2015, at 18:04, DVigneault <<a href="mailto:davis.vigneault@gmail.com" target="_blank" class="">davis.vigneault@gmail.com</a>> wrote:<br class="">
><br class="">
> All--<br class="">
><br class="">
> I'm attempting to use itk::EuclideanDistancePointMetric to compare an<br class="">
> itk::Mesh to an itk::QuadEdgeMesh. This works as expected if templated over<br class="">
> two meshes of the same type (i.e., itk::Mesh and itk::Mesh or<br class="">
> itk::QuadEdgeMesh and itk::QuadEdgeMesh). However, if I attempt to mix the<br class="">
> two, and compare an itk::Mesh and an itk::QuadEdgeMesh, I get a build error,<br class="">
> copied below, along with a minimal example of the problem.<br class="">
><br class="">
> I'm having some trouble decoding the error, but it looks to me as though the<br class="">
> filter is having trouble converting between iterator types. Does this have<br class="">
> something to do with a difference between how itk::Mesh and<br class="">
> itk::QuadEdgeMesh define their iterators?<br class="">
><br class="">
> Thank you in advance for your help!<br class="">
><br class="">
> Best,<br class="">
><br class="">
> --Davis<br class="">
><br class="">
> #include "itkQuadEdgeMesh.h"<br class="">
> #include "itkRegularSphereMeshSource.h"<br class="">
> #include "itkEuclideanDistancePointMetric.h"<br class="">
> #include "itkIdentityTransform.h"<br class="">
><br class="">
> typedef itk::Mesh< double, 3 > TFMesh; // If you change this to<br class="">
> itk::QuadEdgeMesh, it works<br class="">
> typedef itk::QuadEdgeMesh< double, 3 > TMMesh; // Or if you change this to<br class="">
> itk::Mesh, it also works<br class="">
> typedef itk::RegularSphereMeshSource< TFMesh > TFSource;<br class="">
> typedef itk::RegularSphereMeshSource< TMMesh > TMSource;<br class="">
> typedef itk::EuclideanDistancePointMetric< TFMesh, TMMesh > TMetric;<br class="">
> typedef itk::IdentityTransform< double, 3 > TIdentity;<br class="">
><br class="">
> int main(int argc, char ** argv)<br class="">
> {<br class="">
><br class="">
> TFSource::Pointer fixed = TFSource::New();<br class="">
> fixed->Update();<br class="">
><br class="">
> TMSource::Pointer moving = TMSource::New();<br class="">
> moving->Update();<br class="">
><br class="">
> TIdentity::Pointer identity = TIdentity::New();<br class="">
><br class="">
> TMetric::Pointer metric = TMetric::New();<br class="">
> metric->SetFixedPointSet( fixed->GetOutput() );<br class="">
> metric->SetMovingPointSet( moving->GetOutput() );<br class="">
> metric->SetTransform( identity );<br class="">
> std::cout << metric->GetValue(identity->GetParameters()) << std::endl;<br class="">
><br class="">
> return EXIT_SUCCESS;<br class="">
><br class="">
> }<br class="">
><br class="">
><br class="">
> $ make<br class="">
> Scanning dependencies of target AmoebaOptimization<br class="">
> [100%] Building CXX object<br class="">
> CMakeFiles/AmoebaOptimization.dir/AmoebaOptimization.cxx.o<br class="">
> In file included from<br class="">
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.h:125:0,<br class="">
> from<br class="">
> /home/davis/Developer/oxford/Stebbing_Method/Test/src/AmoebaOptimization.cxx:3:<br class="">
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx: In<br class="">
> instantiation of ‘itk::EuclideanDistancePointMetric<TFixedPointSet,<br class="">
> TMovingPointSet, TDistanceMap>::MeasureType<br class="">
> itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,<br class="">
> TDistanceMap>::GetValue(const TransformParametersType&) const [with<br class="">
> TFixedPointSet = itk::Mesh<double, 3u>; TMovingPointSet =<br class="">
> itk::QuadEdgeMesh<double, 3u>; TDistanceMap = itk::Image<short unsigned int,<br class="">
> 3u>; itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,<br class="">
> TDistanceMap>::MeasureType = itk::Array<double>;<br class="">
> itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,<br class="">
> TDistanceMap>::TransformParametersType = itk::OptimizerParameters<double>]’:<br class="">
> /home/davis/Developer/oxford/Stebbing_Method/Test/src/AmoebaOptimization.cxx:28:58:<br class="">
> required from here<br class="">
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx:74:63: error:<br class="">
> conversion from ‘itk::MapContainer<long unsigned int,<br class="">
> itk::QuadEdgeMeshPoint<float, 3u, itk::GeometricalQuadEdge<long<br class="">
> unsigned int, long unsigned int, bool, bool, true> > >::ConstIterator’ to<br class="">
> non-scalar type ‘itk::EuclideanDistancePointMetric<itk::Mesh<double, 3u>,<br class="">
> itk::QuadEdgeMesh<double, 3u> >::PointIterator {aka<br class="">
> itk::VectorContainer<long unsigned int, itk::Point<float, 3u><br class="">
>> ::ConstIterator}’ requested<br class="">
> PointIterator pointItr = movingPointSet->GetPoints()->Begin();<br class="">
> ^<br class="">
> /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx:75:61: error:<br class="">
> conversion from ‘itk::MapContainer<long unsigned int,<br class="">
> itk::QuadEdgeMeshPoint<float, 3u, itk::GeometricalQuadEdge<long<br class="">
> unsigned int, long unsigned int, bool, bool, true> > >::ConstIterator’ to<br class="">
> non-scalar type ‘itk::EuclideanDistancePointMetric<itk::Mesh<double, 3u>,<br class="">
> itk::QuadEdgeMesh<double, 3u> >::PointIterator {aka<br class="">
> itk::VectorContainer<long unsigned int, itk::Point<float, 3u><br class="">
>> ::ConstIterator}’ requested<br class="">
> PointIterator pointEnd = movingPointSet->GetPoints()->End();<br class="">
> ^<br class="">
> make[2]: *** [CMakeFiles/AmoebaOptimization.dir/AmoebaOptimization.cxx.o]<br class="">
> Error 1<br class="">
> make[1]: *** [CMakeFiles/AmoebaOptimization.dir/all] Error 2<br class="">
> make: *** [all] Error 2<br class="">
><br class="">
><br class="">
><br class="">
><br class="">
> --<br class="">
> 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" class="">http://itk-insight-users.2283740.n2.nabble.com/EuclideanDistancePointMetric-Error-when-comparing-Mesh-to-QuadEdgeMesh-tp7587372.html</a><br class="">
> Sent from the ITK Insight Users mailing list archive at <a href="http://Nabble.com" class="">Nabble.com</a>.<br class="">
> _____________________________________<br class="">
> Powered by <a href="http://www.kitware.com/" target="_blank" class="">www.kitware.com</a><br class="">
><br class="">
> Visit other Kitware open-source projects at<br class="">
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank" class="">http://www.kitware.com/opensource/opensource.html</a><br class="">
><br class="">
> Kitware offers ITK Training Courses, for more information visit:<br class="">
> <a href="http://www.kitware.com/products/protraining.php" target="_blank" class="">http://www.kitware.com/products/protraining.php</a><br class="">
><br class="">
> Please keep messages on-topic and check the ITK FAQ at:<br class="">
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank" class="">http://www.itk.org/Wiki/ITK_FAQ</a><br class="">
><br class="">
> Follow this link to subscribe/unsubscribe:<br class="">
> <a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank" class="">http://public.kitware.com/mailman/listinfo/insight-users</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>