Hello all,<br><br>I am trying to modify the deformable registration metric to take a mask-file as an input region:<br><br>// begin code snippet<br><br>typedef itk::ImageMaskSpatialObject&lt; Dimension &gt;   MaskType;<br><br>
  MaskType::Pointer  spatialObjectMask = MaskType::New();<br><br>  typedef itk::Image&lt; unsigned char, Dimension &gt;   ImageMaskType;<br><br>  typedef itk::ImageFileReader&lt; ImageMaskType &gt;    MaskReaderType;<br><br>
  MaskReaderType::Pointer  maskReader = MaskReaderType::New();<br><br>  maskReader-&gt;SetFileName( argv[3] );<br><br>  try <br>    { <br>    maskReader-&gt;Update(); <br>    } <br>  catch( itk::ExceptionObject &amp; err ) <br>
    { <br>    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; <br>    std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>    return EXIT_FAILURE;<br>    } <br><br>  spatialObjectMask-&gt;SetImage( maskReader-&gt;GetOutput() );<br>
<br>  metric-&gt;SetFixedImageMask( spatialObjectMask );<br><br>// end code snippet<br><br>In the original deformableregistration15 code, these are the only following references to &#39;metric&#39;<br><br>/////////<br>MetricType::Pointer         metric        = MetricType::New();<br>
<br>registration-&gt;SetMetric(        metric        );<br><br>metric-&gt;SetNumberOfHistogramBins( 50 );<br><br>metric-&gt;ReinitializeSeed( 76926294 );<br><br>metric-&gt;SetNumberOfSpatialSamples( 10000L ); /// for rigid registration<br>
<br>metric-&gt;SetNumberOfSpatialSamples( 50000L ); /// for affine registration<br><br>metric-&gt;SetNumberOfSpatialSamples( numberOfBSplineParameters * 100 ); /// for coarse b-spline reg.<br><br>const unsigned long numberOfSamples = <br>
     static_cast&lt;unsigned long&gt;(<br>       vcl_sqrt( static_cast&lt;double&gt;( numberOfBSplineParameters ) *<br>                 static_cast&lt;double&gt;( numberOfPixels ) ) );<br>  metric-&gt;SetNumberOfSpatialSamples( numberOfSamples ); /// for fine b-spline reg.<br>
<br>////////<br><br>I hope this clearly outlines the problem.. I&#39;m a relatively new ITK users and I&#39;m still grappling with making small-ish changes to the pre-assembled algorithms.<br><br>Any help is much appreciated,<br>
<br><br clear="all"><br>-- <br>Tim Bhatnagar<br>PhD Candidate<br>Orthopaedic Injury Biomechanics Group<br>Department of Mechanical Engineering<br>University of British Columbia<br><br>Rm 5000 - 818 West 10th Ave.<br>Vancouver, BC<br>

Canada<br>V5Z 1M9<br><br>Ph: <a href="tel:%28604%29%20675-8845" value="+16046758845" target="_blank">(604) 675-8845</a><br>Fax: <a href="tel:%28604%29%20675-8820" value="+16046758820" target="_blank">(604) 675-8820</a><br>
Web: <a href="http://oibg.mech.ubc.ca" target="_blank">oibg.mech.ubc.ca</a><br><br>