Repository navigation
Conversation
Add a cubic b-spline transform that is fitted to displacements defined at the points of a surface or volumetric mesh (any vtkPointSet, such as vtkPolyData or vtkUnstructuredGrid) with a 3-component displacement vector as point data. The coefficients are computed with the multilevel b-spline approximation (MBA) algorithm of Lee, Wolberg and Shin: a coarse control point lattice is fitted first, then the lattice is repeatedly refined and fitted to the remaining residual, until the residual drops below the requested tolerance or a refinement limit is reached. All three displacement components are fitted into a single lattice, because the b-spline weights only depend on the position and so the three components share the same denominator. The implementation is based on the algorithm used by the ScatteredTransform extension (https://github.com/Sunderlandkyl/ScatteredTransform), but it is specialized to 3D and writes the coefficients directly into the vtkImageData that vtkBSplineTransform consumes. VTK and MBA use the same cubic b-spline basis functions in the same order, therefore the control point coefficients transfer without reindexing. The class derives from vtkOrientedBSplineTransform, so the fitted transform can be stored in a vtkMRMLBSplineTransformNode and written to an ITK transform file. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
vtkScatteredBSplineTransform, a cubic B-spline transform fitted to displacement vectors given at the points of anyvtkPointSet(surface mesh, volumetric mesh, or point cloud). Once fitted, the transform can be evaluated and inverted anywhere in space, not only at the input points.This is needed to show a displacement field that is only known at the points of a mesh, for example in Slicer slice views.
vtkProbeFiltercan only interpolate inside the cells of a volumetric mesh, so it returns nothing for a surface mesh or a point cloud.Method
Tolerance, or whenMaximumNumberOfLevelsorMinimumControlPointSpacingis reached.vtkImageDatathatvtkBSplineTransformuses, with no reindexing, because VTK and MBA use the same cubic B-spline basis functions in the same order.vtkOrientedBSplineTransform, so the result can be stored in avtkMRMLBSplineTransformNodeand written to an ITK transform file.Options
DisplacementArrayName: the point data array to fit. If it is not set, the active vectors are used.ControlPointSpacing: the spacing of the coarsest lattice. The default is 1/10 of the fitting domain.MinimumControlPointSpacing,MaximumNumberOfLevels,Tolerance: these limit refinement.UseLinearApproximation: seeds the coarsest level with a least-squares linear fit, so the transform extrapolates the overall trend outside the sampled region instead of flattening out.GridBounds/AutomaticGridBounds: the fitting domain. By default it is the bounds of the input points.GetResidual()andGetNumberOfLevels(): report the accuracy and depth of the last fit.The transform refits automatically when the input point set is modified. Invalid input is reported, and the transform is then left as identity.
Testing
vtkScatteredBSplineTransformTest1uses a smooth analytic warp as ground truth on a surface mesh and on a hexahedral volumetric mesh. It checks:DeepCopy/MakeTransform;The test passes in a Slicer Release build on Windows (MSVC 2022, VTK 9.6.2).
🤖 Generated with Claude Code