<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Presumably your points over all time exist within a bounding<br>box. &nbsp;Do you know what that bounding box is?<br><font class="Apple-style-span" color="#0163c1"><br></font>If not, you might want to look at the itk::PointSet class and<br>it has a bounding box&nbsp;<br><font class="Apple-style-span" color="#0163c1"><br></font>On Jan 10, 2012, at 5:49 AM, Kerstin Müller wrote:<br><font class="Apple-style-span" color="#0163c1"><br><br></font><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><blockquote type="cite"></blockquote>Hi,<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>than may be I set my origin wrong. Here the sample code with comments.<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef float RealType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>// It's a volume<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk::Vector&lt;RealType, 3&gt; VectorType;<br><blockquote type="cite"></blockquote>// The deformation is over time<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk ::Image &lt;VectorType , 4 &gt; TimeVaryingDeformationFieldType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk ::PointSet &lt;VectorType , 4 &gt; TimeVaryingDeformationFieldPointSetType;<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType::Pointer fieldPoints = TimeVaryingDeformationFieldPointSetType:: New ();<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; fieldPoints-&gt;Initialize();<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldType::PointType&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; origin;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldType::SpacingType&nbsp;&nbsp;&nbsp; spacing;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldType::SizeType&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; size;<br><blockquote type="cite"></blockquote>// I want to have a sapcing of 10 mm in each dimension except in the temporal there it is 2&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; // Define the parametric domain of BSpline Field<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[0] = 10.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[1] = 10.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[2] = 10.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[3] = 2.0f;<br><blockquote type="cite"></blockquote>// Here the size of the BSpline field, I have 133 numberOfTimePoints<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[0] = 128;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[1] = 128;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[2] = 128;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[3] = 67;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>// The origin ( where I'm not sure, I also tried 0,0,0)<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; float O[3] ={0.0f,0.0f,0.0f};<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; for (int i=0; i&lt;3; i++)<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; O[i] = m_configuration.origin[i] - spacing[i] * (size[i] - 1) *0.5f;<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[0] = O[0];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[1] = O[1];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[2] = O[2];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[3] = 0.0f;<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; // Set the sample points<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; for ( int t = 0; t &lt; numberOfTimePoints ; t++ )&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; int num = 0;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; for( int idx = 0; idx &lt; <a href="http://endo_points.at/">endo_points.at</a>(t).size()-3; idx+=3 )<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VectorType v;<br><blockquote type="cite"></blockquote>// The sampling points range from -70 to +70 for example<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[0] = <a href="http://endo_points.at/">endo_points.at</a>(t)[idx]&nbsp;&nbsp; - <a href="http://endo_points.at/">endo_points.at</a>(0)[idx]&nbsp; ;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[1] = <a href="http://endo_points.at/">endo_points.at</a>(t)[idx+1] - <a href="http://endo_points.at/">endo_points.at</a>(0)[idx+1];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[2] = <a href="http://endo_points.at/">endo_points.at</a>(t)[idx+2] - <a href="http://endo_points.at/">endo_points.at</a>(0)[idx+2];<br><blockquote type="cite">
</blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType::PointType point;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0] = <a href="http://endo_points.at/">endo_points.at</a>(0)[idx];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1] = <a href="http://endo_points.at/">endo_points.at</a>(0)[idx+1];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[2] = <a href="http://endo_points.at/">endo_points.at</a>(0)[idx+2];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[3] = t;<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldPoints-&gt;SetPoint( num, point );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldPoints-&gt;SetPointData(num, v);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num++;<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; }<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; // Define the filter and set the parameters<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk::myBSplineScatteredDataPointSetToImageFilter&lt;TimeVaryingDeformationFieldPointSetType, TimeVaryingDeformationFieldType&gt; BSplineFilterType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; BSplineFilterType::Pointer filter = BSplineFilterType::New();<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetSize( size );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetOrigin( origin );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetSpacing( spacing );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetGenerateOutputImage ( false );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetNumberOfLevels ( 2 );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetSplineOrder ( 3 );<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; BSplineFilterType :: ArrayType ncps;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(0,8);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(1,8);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(2,8);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(3,5);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt; SetNumberOfControlPoints ( ncps );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetInput( fieldPoints );<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter-&gt;SetDebug(true);<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; try<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; filter -&gt;Update ();<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; catch ( itk::ExceptionObject &amp; excp )<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; std :: cerr &lt;&lt; "Test 2: itkBSplineScatteredDataImageFilter exception thrown" &lt;&lt; std:: endl;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; std::cerr&lt;&lt; excp &lt;&lt;std::endl;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>That's the Spline definition and afterwards I wanna resample the BSpline at arbitrary positions:<br><blockquote type="cite">
</blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>float fPoint[3] = {0.0f,0.0f,0.0f};<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; float sample_O[3] ={0.0f,0.0f,0.0f};<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; for (int i=0; i&lt;3; i++)<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; sample_O[i] = m_configuration.origin[i] - m_configuration.vs * (m_configuration.size[i] - 1) *0.5f;<br><blockquote type="cite">
</blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; int sample_size[3];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; sample_size[0] = m_configuration.size[0];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; sample_size[1] = m_configuration.size[1];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; sample_size[2] = m_configuration.size[2];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; for (int iz=0, idx=0; iz&lt;sample_size[2]; iz++)<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; fPoint[2] = sample_O[2] + iz*m_configuration.vs;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; for (int iy=0; iy&lt;sample_size[1]; iy++)<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fPoint[1] = sample_O[1] + iy*m_configuration.vs;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int ix=0; ix&lt;sample_size[0]; ix++)<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fPoint[0] = sample_O[0] + ix*m_configuration.vs;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType :: PointType point;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point [0] = fPoint[0];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point [1] = fPoint[1];<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point [2] = fPoint[2];<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VectorType V;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filter-&gt;EvaluateAtPoint(point, V);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //cout &lt;&lt; iy &lt;&lt; endl;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; }<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; iz &lt;&lt; endl;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>Thans a lot for your help!<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>Best,<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#007429"><br></font><blockquote type="cite"></blockquote>Kerstin<br>2012/1/10 Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>&gt;</span><br><blockquote type="cite"><div class="gmail_quote">
That's fine. &nbsp;I'm assuming, though, that they reside<br>in a bounding box of some sort, correct? &nbsp;Just&nbsp;<br>assign those points to their continuous coordinates<br>inside that bounding box.<br><br><br><br><br>On Jan 10, 2012, at 5:31 AM, Kerstin Müller wrote:<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">
<div><div class="h5"><div><div><div><div>
<blockquote type="cite"></blockquote>But my sample points are on continous world coordinates between for example -70.0 and 70.0.<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#6c0403"><br></font><blockquote type="cite"></blockquote>Best,<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#6c0403"><br></font><blockquote type="cite"></blockquote>Kerstin<br><blockquote type="cite"></blockquote><font class="Apple-style-span" color="#6c0403"><br></font>2012/1/10 Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</span><br><blockquote type="cite"><div class="gmail_quote">

Since your points reside in an image, an easy<br>parameterization is to assign their location to&nbsp;<br>their x,y,z location in the image. &nbsp;Does that make<br>sense?<br><br><br>On Jan 10, 2012, at 5:19 AM, Kerstin Müller wrote:<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">

<div><div><div><div><div><div><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Hi,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>yes I also used your sample code, but still I got a heap corruption error. That's why I just wanted to try if my sample points are the problem.<br><blockquote type="cite"></blockquote>Do I need to scale them to a range between [0 1]?<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Best Regards,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Kerstin<br><blockquote type="cite"></blockquote><br>2012/1/10 Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</span><br><blockquote type="cite"><div class="gmail_quote">Hi Kerstin,<br><br>Please keep the correspondence on the user's list. &nbsp;<br><br>Why are you setting your vector to all zeros?&nbsp;<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="word-wrap:break-word"><div><div><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VectorType v;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[0] = 0.0;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[1] = 0.0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; v[2] = 0.0;<br></div></div></div></blockquote>and why are you setting the location of your points to&nbsp;<br>(idx,idx,idx,t)?<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">


<div><div><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0] = idx;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1] = idx;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[2] = idx;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; point[3] = t;<br>
</div></div></div></blockquote>That can't possibly be right. &nbsp;Did you look at the sample<br>code I gave you?<br><br>Nick<br><br><br><br>On Jan 9, 2012, at 2:04 AM, Kerstin Müller wrote:<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div><div>


<blockquote type="cite"></blockquote>Hi,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>thank you very much!<br><blockquote type="cite"></blockquote>However I'm still struggeling with a heap corruption problem. I'm not sure if I set my parameters correct.<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef float RealType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk::Vector&lt;RealType, 3&gt; VectorType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk ::Image &lt;VectorType , 4 &gt; TimeVaryingDeformationFieldType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk :: PointSet &lt;VectorType , 4 &gt; TimeVaryingDeformationFieldPointSetType;<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType::Pointer fieldPoints = TimeVaryingDeformationFieldPointSetType:: New ();<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; fieldPoints-&gt;Initialize();<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; // Set the sample points just for testing 10 linear points no movement<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; for ( int t = 0; t &lt; m_configuration.num_projections ; t++ )&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; int num = 0;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; for( int idx = 0; idx &lt;= 10; idx++ )<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VectorType v;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[0] = 0.0;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[1] = 0.0;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v[2] = 0.0;<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType::PointType point;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0] = idx;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1] = idx;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[2] = idx;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[3] = t;<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldPoints-&gt;SetPoint( num, point );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldPoints-&gt;SetPointData(num, v);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num++;<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; }<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldType::PointType&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; origin;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldType::SpacingType&nbsp;&nbsp;&nbsp; spacing;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; TimeVaryingDeformationFieldType::SizeType&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; size;<br><blockquote type="cite">



</blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; // Define the parametric domain<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[0] = 1.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[1] = 1.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[2] = 1.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; spacing[3] = 2.0f;<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[0] = 128;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[1] = 128;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[2] = 128;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; size[3] = 66;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[0] = 0.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[1] = 0.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[2] = 0.0f;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; origin[3] = 0.0f;<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; // Define the filter and set the parameters<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; typedef itk::myBSplineScatteredDataPointSetToImageFilter&lt;TimeVaryingDeformationFieldPointSetType, TimeVaryingDeformationFieldType&gt; BSplineFilterType;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; BSplineFilterType::Pointer filter = BSplineFilterType::New();<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetSize( size );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetOrigin( origin );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetSpacing( spacing );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt; SetGenerateOutputImage ( false );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt; SetNumberOfLevels ( 2 );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt; SetSplineOrder ( 3 );<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; BSplineFilterType :: ArrayType ncps;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(0,8);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(1,8);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(2,8);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; ncps.SetElement(3,34);<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt; SetNumberOfControlPoints ( ncps );<br><blockquote type="cite"></blockquote>&nbsp; &nbsp;&nbsp;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter -&gt;SetInput( fieldPoints );<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; filter-&gt;SetDebug(true);<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>&nbsp; &nbsp; try<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; filter -&gt;Update ();<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; catch ( itk::ExceptionObject &amp; excp )<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; {<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; std :: cerr &lt;&lt; "Test 2: itkBSplineScatteredDataImageFilter exception thrown" &lt;&lt; std:: endl;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; std::cerr&lt;&lt; excp &lt;&lt;std::endl;<br><blockquote type="cite"></blockquote>&nbsp; &nbsp; }<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Thank you very much!<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Best,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Kerstin<br>2012/1/4 Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</span><br><blockquote type="cite"><div class="gmail_quote">




Okay, here's some pseudocode which hasn't been tested<br>since you have to provide it the interface to your values&nbsp;<br>but you should get the general idea.<br><br>&nbsp; typedef float RealType;<br>&nbsp; typedef itk::Image&lt;RealType, ImageDimension&gt; RealImageType;<br><br>&nbsp; // Read in your reference image which will define the domain of&nbsp;<br>&nbsp; // your B-spline displacement field. &nbsp;Assume, for simplicity, that it<br>&nbsp; // has identity direction<br><br>&nbsp; typedef itk::ImageFileReader&lt;RealImageType&gt; ImageReaderType;<br>&nbsp; typename ImageReaderType::Pointer reader = ImageReaderType::New();<br>&nbsp; reader-&gt;SetFileName( XXXX );<br>&nbsp; reader-&gt;Update();<br><br>&nbsp; typedef itk::Vector&lt;RealType, ImageDimension&gt; VectorType;<br>&nbsp; typedef itk::Image&lt;VectorType, ImageDimension+1&gt; TimeVaryingDeformationFieldType;<br><br>&nbsp; typedef itk::PointSet&lt;VectorType, ImageDimension+1&gt; TimeVaryingDeformationFieldPointSetType;<br>&nbsp; typename&nbsp;TimeVaryingDeformationFieldPointSetType::Pointer fieldPoints =<br>&nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType::New();<br>&nbsp; fieldPoints-&gt;Initialize();<br>&nbsp; unsigned long count = 0;<br><br>&nbsp; // Assume points are stored in a 2-D matrix called 'mySamplePoints' where the column<br>&nbsp; // is the time point and the row is the point<br><br>&nbsp; for( unsigned int t = 0; t &lt; numberOfTimePoints; t++ )<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; for( unsigned int n = 0; &nbsp;n &lt; numberOfPointsPerTimePoint; n++ )<br>&nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; VectorType displacement = mySamplePoints[n][t] - mySamplePoints[n][0];<br>&nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; TimeVaryingDeformationFieldPointSetType::PointType parametric point;<br>&nbsp; &nbsp; &nbsp; for( unsigned int d = 0; d &lt; ImageDimension; d++ )<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; point[d] = ( mySamplePoints[n][0] )[d];<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; point[ImageDimension] = t;<br><br>&nbsp; &nbsp; &nbsp; fieldPoints-&gt;SetPoint( count, point );<br>&nbsp; &nbsp; &nbsp; fieldPoints-&gt;SetPointData( count, displacement );<br>&nbsp; &nbsp; &nbsp; count++;<br>&nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; } &nbsp;&nbsp;<br><br>&nbsp; TimeVaryingDeformationFieldType::PointType origin;<br>&nbsp; TimeVaryingDeformationFieldType::SpacingType spacing;<br>&nbsp; TimeVaryingDeformationFieldType::SizeType size;<br><br>&nbsp; &nbsp;for( unsigned int d = 0; d &lt; ImageDimension; d++ )<br>&nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; origin[d] = reader-&gt;GetOutput()-&gt;GetOrigin()[d];<br>&nbsp; &nbsp; &nbsp; size[d] = reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize()[d];<br>&nbsp; &nbsp; &nbsp; spacing[d] = reader-&gt;GetOutput()-&gt;GetSpacing()[d];<br>&nbsp; &nbsp; &nbsp; }<br>&nbsp; // Now include the temporal information. &nbsp;You can change this to whatever<br>&nbsp; // resolution you like. &nbsp;You just need to make sure that&nbsp;<br>&nbsp; // &nbsp;( size[ImageDimension] - 1 ) * spacing[ImageDimension] = ( numberOfTimePoints - 1)<br>&nbsp; //&nbsp;<br>&nbsp; origin[ImageDimension] = 0;<br>&nbsp; size[ImageDimension] &nbsp;=&nbsp;numberOfTimePoints&nbsp;- 1;<br>&nbsp; spacing[ImageDimension] = 1;<br><br>&nbsp; typedef itk::BSplineScatteredDataPointSetToImageFilter<br>&nbsp; &nbsp; &lt;TimeVaryingDeformationFieldPointSetType, TimeVaryingDeformationFieldType&gt; BSplineFilterType;<br>&nbsp; typename BSplineFilterType::Pointer bspliner = BSplineFilterType::New();<br>&nbsp; bspliner-&gt;SetOrigin( origin );<br>&nbsp; bspliner-&gt;SetSpacing( spacing );<br>&nbsp; bspliner-&gt;SetSize( size );<br>&nbsp; bspliner-&gt;SetGenerateOutputImage( XXXX );<br>&nbsp; bspliner-&gt;SetNumberOfLevels( XXXX );<br>&nbsp; bspliner-&gt;SetSplineOrder( XXXX );<br>&nbsp; bspliner-&gt;SetNumberOfControlPoints( XXXX );<br>&nbsp; bspliner-&gt;SetInput( fieldPoints );<br>&nbsp; bspliner-&gt;Update();<br><br><br><br><br>On Jan 4, 2012, at 2:52 AM, Kerstin Müller wrote:<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">







































<div><div><div>
<blockquote type="cite"></blockquote>Hi,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>yes correctly.<br><blockquote type="cite"></blockquote><br>2012/1/3 Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</span><br><blockquote type="cite"><div class="gmail_quote">




Okay, I'm assuming that these points correspond in&nbsp;<br>time, correct? &nbsp;For example, point 937 in time point 0<br>corresponds to point 937 in time point 1, 2, 3, ...133,<br>right? &nbsp;<br><br><br><br>On Jan 3, 2012, at 11:55 AM, Kerstin Müller wrote:<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">





<div><div><div><blockquote type="cite"></blockquote>Hi,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>the basic problem I wanna solve:<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>I'll have scattered points in 3D which vary over time, they describe a motion of a surface over time. They are not ordered in x-y-and z-dimension.<br><blockquote type="cite"></blockquote>Now I want to represent that motion by BSplines in order to generate a dense motion vector field defined on specific 3D voxel positions.<br><blockquote type="cite"></blockquote>I'll have 133 timesteps and ~960 sample points in each time step. Now I want to fit the BSpline to it and resample it.<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>All the best,<br><blockquote type="cite"></blockquote><br><blockquote type="cite"></blockquote>Kerstin<br><blockquote type="cite"></blockquote><br>2012/1/3 Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</span><br><blockquote type="cite"><div class="gmail_quote">






In that case, let's start with the basic problem set-up.<br>Before, you described your problem as follows:<br><br><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>






<div><div><blockquote type="cite"><span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium">I'm using the<span>&nbsp;</span><b>BSplineScatteredDataPointSetToImageFilter<span>&nbsp;</span></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>






<div><div>






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.</div></div></span></blockquote>






</div></div></div></div></div></blockquote><br>What do these scattered 3D+t points represent? &nbsp;<br>Is it a curve, a time-varying scalar field, or something<br>else?<br><div style="word-wrap:break-word"><div><br></div></div></div>






</blockquote><br></div></div></div></div></blockquote></div></blockquote><br></div></div></div></div></blockquote></div></blockquote><br></div></div></div></div></div></blockquote></div></blockquote><br></div></div></div></div></div></div></div></blockquote></div></blockquote><font class="Apple-style-span" color="#6c0403"><br></font></div></div></div></div></div></div></div></blockquote></div></blockquote><font class="Apple-style-span" color="#007429"><br></font></div></div></div></blockquote></div><br></body></html>