[Insight-users] Question regarding BSplineScatteredDataPointSetToImageFilter
Nicholas Tustison
ntustison at gmail.com
Wed Jan 4 08:57:03 EST 2012
Okay, here's some pseudocode which hasn't been tested
since you have to provide it the interface to your values
but you should get the general idea.
typedef float RealType;
typedef itk::Image<RealType, ImageDimension> RealImageType;
// Read in your reference image which will define the domain of
// your B-spline displacement field. Assume, for simplicity, that it
// has identity direction
typedef itk::ImageFileReader<RealImageType> ImageReaderType;
typename ImageReaderType::Pointer reader = ImageReaderType::New();
reader->SetFileName( XXXX );
reader->Update();
typedef itk::Vector<RealType, ImageDimension> VectorType;
typedef itk::Image<VectorType, ImageDimension+1> TimeVaryingDeformationFieldType;
typedef itk::PointSet<VectorType, ImageDimension+1> TimeVaryingDeformationFieldPointSetType;
typename TimeVaryingDeformationFieldPointSetType::Pointer fieldPoints =
TimeVaryingDeformationFieldPointSetType::New();
fieldPoints->Initialize();
unsigned long count = 0;
// Assume points are stored in a 2-D matrix called 'mySamplePoints' where the column
// is the time point and the row is the point
for( unsigned int t = 0; t < numberOfTimePoints; t++ )
{
for( unsigned int n = 0; n < numberOfPointsPerTimePoint; n++ )
{
VectorType displacement = mySamplePoints[n][t] - mySamplePoints[n][0];
TimeVaryingDeformationFieldPointSetType::PointType parametric point;
for( unsigned int d = 0; d < ImageDimension; d++ )
{
point[d] = ( mySamplePoints[n][0] )[d];
}
point[ImageDimension] = t;
fieldPoints->SetPoint( count, point );
fieldPoints->SetPointData( count, displacement );
count++;
}
}
TimeVaryingDeformationFieldType::PointType origin;
TimeVaryingDeformationFieldType::SpacingType spacing;
TimeVaryingDeformationFieldType::SizeType size;
for( unsigned int d = 0; d < ImageDimension; d++ )
{
origin[d] = reader->GetOutput()->GetOrigin()[d];
size[d] = reader->GetOutput()->GetLargestPossibleRegion().GetSize()[d];
spacing[d] = reader->GetOutput()->GetSpacing()[d];
}
// Now include the temporal information. You can change this to whatever
// resolution you like. You just need to make sure that
// ( size[ImageDimension] - 1 ) * spacing[ImageDimension] = ( numberOfTimePoints - 1)
//
origin[ImageDimension] = 0;
size[ImageDimension] = numberOfTimePoints - 1;
spacing[ImageDimension] = 1;
typedef itk::BSplineScatteredDataPointSetToImageFilter
<TimeVaryingDeformationFieldPointSetType, TimeVaryingDeformationFieldType> BSplineFilterType;
typename BSplineFilterType::Pointer bspliner = BSplineFilterType::New();
bspliner->SetOrigin( origin );
bspliner->SetSpacing( spacing );
bspliner->SetSize( size );
bspliner->SetGenerateOutputImage( XXXX );
bspliner->SetNumberOfLevels( XXXX );
bspliner->SetSplineOrder( XXXX );
bspliner->SetNumberOfControlPoints( XXXX );
bspliner->SetInput( fieldPoints );
bspliner->Update();
On Jan 4, 2012, at 2:52 AM, Kerstin Müller wrote:
> Hi,
>
> yes correctly.
>
> 2012/1/3 Nicholas Tustison <ntustison at gmail.com>
> Okay, I'm assuming that these points correspond in
> time, correct? For example, point 937 in time point 0
> corresponds to point 937 in time point 1, 2, 3, ...133,
> right?
>
>
>
> On Jan 3, 2012, at 11:55 AM, Kerstin Müller wrote:
>
>> Hi,
>>
>> the basic problem I wanna solve:
>>
>> 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.
>> Now I want to represent that motion by BSplines in order to generate a dense motion vector field defined on specific 3D voxel positions.
>> 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.
>>
>> All the best,
>>
>> Kerstin
>>
>> 2012/1/3 Nicholas Tustison <ntustison at gmail.com>
>> In that case, let's start with the basic problem set-up.
>> Before, you described your problem as follows:
>>
>>
>>>> I'm using the BSplineScatteredDataPointSetToImageFilter from the Insight Journal. However,
>>>> I cannot find the correct parameter in order to make the filter work and does not crash during the evaluation.
>>>> 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.
>>
>>
>> What do these scattered 3D+t points represent?
>> Is it a curve, a time-varying scalar field, or something
>> else?
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120104/cb222684/attachment.htm>
More information about the Insight-users
mailing list