<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->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; </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->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 want to consider. </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 </div><div>already.</div><div><br></div><div>2. 67 control points is quite a bit. 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 (6-3) * 2^(5-1) x (6-3) * 2^(5-1) x (67-3) * 2^(5-1) =</div><div>48x48x48x1024. A large lattice size in the temporal dimension </div><div>might not be necessary.</div><div><br></div><div>Nick </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> const unsigned int DataDimension = 3;<br><br> typedef double RealType;<br> typedef itk ::Vector <RealType , DataDimension > VectorType;<br> typedef itk ::Image <VectorType , ParametricDimension > ImageType;<br>
<br> typedef itk :: PointSet <VectorType , ParametricDimension > PointSetType ;<br> PointSetType :: Pointer pointSet = PointSetType :: New ();<br> <br> // Set the sample points<br> for ( int img_num = 0; img_num < m_configuration.num_projections ; img_num++ ) <br>
{<br> int num = 0;<br> for( int idx = 0; idx <= <a href="http://points.at/">points.at</a>(img_num).size()-3; idx+=3 )<br> {<br> <br> VectorType v;<br> v[0] = <a href="http://points.at/">points.at</a>(img_num)[idx];<br>
v[1] = <a href="http://points.at/">points.at</a>(img_num)[idx+1];<br> v[2] = <a href="http://points.at/">points.at</a>(img_num)[idx+2];<br> pointSet->SetPointData(num, v);<br><br> num++;<br>
<br> }<br> }<br> // Instantiate the filter and set the parameters<br> typedef itk::myBSplineScatteredDataPointSetToImageFilter<PointSetType , ImageType > FilterType;<br> FilterType :: Pointer filter = FilterType :: New ();<br>
<br> // Define the parametric domain<br> ImageType :: SpacingType spacing; <br> spacing[0] = 42.0f;<br> spacing[1] = 42.0f;<br> spacing[2] = 42.0f;<br> spacing[3] = 2.0f;<br> ImageType :: SizeType size; <br>
size[0] = 6;<br> size[1] = 6;<br> size[2] = 6;<br> size[3] = 67;<br> ImageType :: PointType origin; <br> origin.Fill( 0.0 );<br><br> filter ->SetSize( size );<br> filter ->SetOrigin( origin );<br>
filter ->SetSpacing( spacing );<br> filter ->SetInput( pointSet );<br><br> filter -> SetSplineOrder ( 3 );<br> FilterType :: ArrayType ncps;<br> ncps.SetElement(0,6);<br> ncps.SetElement(1,6);<br>
ncps.SetElement(2,6);<br> ncps.SetElement(3,67);<br><br> filter -> SetNumberOfControlPoints ( ncps );<br> filter -> SetNumberOfLevels ( 5 );<br> filter -> SetGenerateOutputImage ( false );<br><br>
try<br> {<br> filter ->Update ();<br> }<br> catch ( itk::ExceptionObject & excp )<br> {<br> std :: cerr << "Test 2: itkBSplineScatteredDataImageFilter exception thrown" << std:: endl;<br>
std::cerr<< excp <<std::endl;<br> }<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>