<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Okay, here's some pseudocode which hasn't been tested</div><div>since you have to provide it the interface to your values </div><div>but you should get the general idea.</div><div><br></div><div> typedef float RealType;</div><div><div> typedef itk::Image<RealType, ImageDimension> RealImageType;</div><div><br></div><div> // Read in your reference image which will define the domain of </div><div> // your B-spline displacement field. Assume, for simplicity, that it</div><div> // has identity direction</div><div><br></div><div> typedef itk::ImageFileReader<RealImageType> ImageReaderType;</div><div> typename ImageReaderType::Pointer reader = ImageReaderType::New();</div><div> reader->SetFileName( XXXX );</div><div> reader->Update();</div><div><br></div><div> typedef itk::Vector<RealType, ImageDimension> VectorType;</div><div> typedef itk::Image<VectorType, ImageDimension+1> TimeVaryingDeformationFieldType;</div><div><br></div><div> typedef itk::PointSet<VectorType, ImageDimension+1> TimeVaryingDeformationFieldPointSetType;</div></div><div> typename TimeVaryingDeformationFieldPointSetType::Pointer fieldPoints =</div><div> TimeVaryingDeformationFieldPointSetType::New();</div><div> fieldPoints->Initialize();</div><div> unsigned long count = 0;</div><div><br></div><div> // Assume points are stored in a 2-D matrix called 'mySamplePoints' where the column</div><div> // is the time point and the row is the point</div><div><br></div><div> for( unsigned int t = 0; t < numberOfTimePoints; t++ )</div><div> {</div><div> for( unsigned int n = 0; n < numberOfPointsPerTimePoint; n++ )</div><div> {</div><div> VectorType displacement = mySamplePoints[n][t] - mySamplePoints[n][0];</div><div> </div><div> TimeVaryingDeformationFieldPointSetType::PointType parametric point;</div><div> for( unsigned int d = 0; d < ImageDimension; d++ )</div><div> {</div><div> point[d] = ( mySamplePoints[n][0] )[d];</div><div> }</div><div> point[ImageDimension] = t;</div><div><br></div><div> fieldPoints->SetPoint( count, point );</div><div> fieldPoints->SetPointData( count, displacement );</div><div> count++;</div><div> }</div><div> } </div><div><br></div><div><div> TimeVaryingDeformationFieldType::PointType origin;</div></div><div><div> TimeVaryingDeformationFieldType::SpacingType spacing;</div></div><div><div> TimeVaryingDeformationFieldType::SizeType size;</div></div><div><br></div><div> for( unsigned int d = 0; d < ImageDimension; d++ )</div><div> {</div><div> origin[d] = reader->GetOutput()->GetOrigin()[d];</div><div> size[d] = reader->GetOutput()->GetLargestPossibleRegion().GetSize()[d];</div><div> spacing[d] = reader->GetOutput()->GetSpacing()[d];</div><div> }</div><div> // Now include the temporal information. You can change this to whatever</div><div> // resolution you like. You just need to make sure that </div><div> // ( size[ImageDimension] - 1 ) * spacing[ImageDimension] = ( numberOfTimePoints - 1)</div><div> // </div><div> origin[ImageDimension] = 0;</div><div> size[ImageDimension] = numberOfTimePoints - 1;</div><div> spacing[ImageDimension] = 1;</div><div><br></div><div><div> typedef itk::BSplineScatteredDataPointSetToImageFilter</div><div> <TimeVaryingDeformationFieldPointSetType, TimeVaryingDeformationFieldType> BSplineFilterType;</div><div> typename BSplineFilterType::Pointer bspliner = BSplineFilterType::New();</div></div><div><div> bspliner->SetOrigin( origin );</div><div> bspliner->SetSpacing( spacing );</div><div> bspliner->SetSize( size );</div><div> bspliner->SetGenerateOutputImage( XXXX );</div><div> bspliner->SetNumberOfLevels( XXXX );</div><div> bspliner->SetSplineOrder( XXXX );</div><div> bspliner->SetNumberOfControlPoints( XXXX );</div><div> bspliner->SetInput( fieldPoints );</div></div><div> bspliner->Update();</div><div><br></div><div><br></div><div><br></div><br><div><div>On Jan 4, 2012, at 2:52 AM, Kerstin Müller wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br><br>yes correctly.<br><br><div class="gmail_quote">2012/1/3 Nicholas Tustison <span dir="ltr"><<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>></span><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>Okay, I'm assuming that these points correspond in </div><div>time, correct? For example, point 937 in time point 0</div><div>corresponds to point 937 in time point 1, 2, 3, ...133,</div>
<div>right? </div><div><div class="h5"><div><br></div><div><br></div><br><div><div>On Jan 3, 2012, at 11:55 AM, Kerstin Müller wrote:</div><br><blockquote type="cite">Hi,<br><br>the basic problem I wanna solve:<br><br>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>
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>
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><br>All the best,<br><br>Kerstin<br><br><div class="gmail_quote">2012/1/3 Nicholas Tustison <span dir="ltr"><<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>></span><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">In that case, let's start with the basic problem set-up.<div>Before, you described your problem as follows:<div>
<br><div><div><br><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"><blockquote type="cite">
<div><div>I'm using the<span> </span><b>BSplineScatteredDataPointSetToImageFilter<span> </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>
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></blockquote></span></blockquote>
</div></div></div></div><div><br></div><div>What do these scattered 3D+t points represent? </div><div>Is it a curve, a time-varying scalar field, or something</div><div>else?</div><div><br></div></div></blockquote></div>
<br>
</blockquote></div><br></div></div></div></blockquote></div><br>
</blockquote></div><br></body></html>