<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Kerstin,<div><br></div><div>You're not setting your point locations in the parametric domain.</div><div>Inside your loop where you're setting the point data, you also need</div><div>to store the parametric location of your points inside your domain,i.e.</div><div><br></div><div style="text-align: left;"><i>pointSet-&gt;SetPointData(num, v)</i></div><div style="text-align: left;"><i><br></i></div><div style="text-align: left;"><i>PointSetType::PointType point;</i></div><div style="text-align: left;"><i><br></i></div><div><div style="text-align: left;"><i>point[0] = x;</i></div></div><div><div style="text-align: left;"><i>point[1] = y;</i></div></div><div><div style="text-align: left;"><i>point[2] = z;&nbsp;</i></div></div><div><div style="text-align: left;"><i>point[3] = t;</i></div></div><div style="text-align: left;"><i><br></i></div><div style="text-align: left;"><i>pointSet-&gt;SetPoint( num, point );</i></div><div style="text-align: left;"><i>num++</i></div><div style="text-align: left;"><br></div><div>where x, y, z, and t describes the parametric location of your data</div><div>point.</div><div><br></div><div>A couple other things you might&nbsp;want to consider. &nbsp;</div><div><br></div><div>1. The BSpline filter has been in ITK proper for some time</div><div>now and I know I've made several changes (including a</div><div>thorough parallelization for significant speed-up) since then.</div><div>You might want to consider using the class that's in ITK&nbsp;</div><div>already.</div><div><br></div><div>2. 67 control points is quite a bit. &nbsp;That, coupled with 5 levels,</div><div>would mean you would end up with a control point lattice of</div><div>(6-3) * 2^(5-1) x&nbsp;(6-3) * 2^(5-1) x&nbsp;(6-3) * 2^(5-1) x&nbsp;(67-3) * 2^(5-1) =</div><div>48x48x48x1024. &nbsp;A large lattice size in the temporal&nbsp;dimension&nbsp;</div><div>might not be necessary.</div><div><br></div><div>Nick&nbsp;</div><div><br></div><div><br></div><div><div><div>On Dec 23, 2011, at 4:19 AM, Kerstin Müller wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br><br>I'm using the <b>BSplineScatteredDataPointSetToImageFilter </b>from the Insight Journal. However,<br>I cannot find the correct parameter in order to make the filter work and does not crash during the evaluation.<br>
I'll have scattered 3-D points over time and I want to fit a 4-D Bspline field to that points. Afterwards I want to evaluate the Bspline on a dense volume grid to one time step.<br><br>Here you can find the code, unfortunately it crashes (either due to memory problems or without any error output)<br>
<br><br>const unsigned int ParametricDimension = 4;<br>&nbsp;&nbsp;&nbsp; const unsigned int DataDimension = 3;<br><br>&nbsp;&nbsp;&nbsp; typedef double RealType;<br>&nbsp;&nbsp;&nbsp; typedef itk ::Vector &lt;RealType , DataDimension &gt; VectorType;<br>&nbsp;&nbsp;&nbsp; typedef itk ::Image &lt;VectorType , ParametricDimension &gt; ImageType;<br>
<br>&nbsp;&nbsp;&nbsp; typedef itk :: PointSet &lt;VectorType , ParametricDimension &gt; PointSetType ;<br>&nbsp;&nbsp;&nbsp; PointSetType :: Pointer pointSet = PointSetType :: New ();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // Set the sample points<br>&nbsp;&nbsp;&nbsp; for ( int img_num = 0; img_num &lt; m_configuration.num_projections ; img_num++ ) <br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int num = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for( int idx = 0; idx &lt;= <a href="http://points.at/">points.at</a>(img_num).size()-3; idx+=3 )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; VectorType v;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; v[0] = <a href="http://points.at/">points.at</a>(img_num)[idx];<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; v[1] = <a href="http://points.at/">points.at</a>(img_num)[idx+1];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; v[2] = <a href="http://points.at/">points.at</a>(img_num)[idx+2];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pointSet-&gt;SetPointData(num, v);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num++;<br>
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; // Instantiate the filter and set the parameters<br>&nbsp;&nbsp;&nbsp; typedef itk::myBSplineScatteredDataPointSetToImageFilter&lt;PointSetType , ImageType &gt; FilterType;<br>&nbsp;&nbsp;&nbsp; FilterType :: Pointer filter = FilterType :: New ();<br>
<br>&nbsp;&nbsp;&nbsp; // Define the parametric domain<br>&nbsp;&nbsp;&nbsp; ImageType :: SpacingType spacing; <br>&nbsp;&nbsp;&nbsp; spacing[0] = 42.0f;<br>&nbsp;&nbsp;&nbsp; spacing[1] = 42.0f;<br>&nbsp;&nbsp;&nbsp; spacing[2] = 42.0f;<br>&nbsp;&nbsp;&nbsp; spacing[3] = 2.0f;<br>&nbsp;&nbsp;&nbsp; ImageType :: SizeType size; <br>
&nbsp;&nbsp;&nbsp; size[0] = 6;<br>&nbsp;&nbsp;&nbsp; size[1] = 6;<br>&nbsp;&nbsp;&nbsp; size[2] = 6;<br>&nbsp;&nbsp;&nbsp; size[3] = 67;<br>&nbsp;&nbsp;&nbsp; ImageType :: PointType origin; <br>&nbsp;&nbsp;&nbsp; origin.Fill( 0.0 );<br><br>&nbsp;&nbsp;&nbsp; filter -&gt;SetSize( size );<br>&nbsp;&nbsp;&nbsp; filter -&gt;SetOrigin( origin );<br>
&nbsp;&nbsp;&nbsp; filter -&gt;SetSpacing( spacing );<br>&nbsp;&nbsp;&nbsp; filter -&gt;SetInput( pointSet );<br><br>&nbsp;&nbsp;&nbsp; filter -&gt; SetSplineOrder ( 3 );<br>&nbsp;&nbsp;&nbsp; FilterType :: ArrayType ncps;<br>&nbsp;&nbsp;&nbsp; ncps.SetElement(0,6);<br>&nbsp;&nbsp;&nbsp; ncps.SetElement(1,6);<br>
&nbsp;&nbsp;&nbsp; ncps.SetElement(2,6);<br>&nbsp;&nbsp;&nbsp; ncps.SetElement(3,67);<br><br>&nbsp;&nbsp;&nbsp; filter -&gt; SetNumberOfControlPoints ( ncps );<br>&nbsp;&nbsp;&nbsp; filter -&gt; SetNumberOfLevels ( 5 );<br>&nbsp;&nbsp;&nbsp; filter -&gt; SetGenerateOutputImage ( false );<br><br>
&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter -&gt;Update ();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; catch ( itk::ExceptionObject &amp; excp )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std :: cerr &lt;&lt; "Test 2: itkBSplineScatteredDataImageFilter exception thrown" &lt;&lt; std:: endl;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::cerr&lt;&lt; excp &lt;&lt;std::endl;<br>&nbsp;&nbsp;&nbsp; }<br><br>Thank you for your help!<br><br>Best,<br><br>Kerstin<br>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.html<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></div></body></html>