View Issue Details

IDProjectCategoryView StatusLast Update
0003659Slicer4Module Modelspublic2014-06-14 16:31
Reporterfedorov Assigned Tolassoan  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version 
Target VersionSlicer 4.4.0Fixed in VersionSlicer 4.4.0 
Summary0003659: Model color messed up after placing under a bspline transform
Description

Looks like surface normals are flipped after applying a b-spline transform. Attached are screenshots and a sample transform to reproduce the issue. Issue observed with April 18 nightly.

TagsNo tags attached.

Relationships

duplicate of 0003614 closedlassoan Applying a Bspline transform to a model makes appear black in 3D 

Activities

2014-04-18 10:17

 

2014-04-18 10:18

 

2014-04-18 10:18

 

case9-bspline.tfm (8,407 bytes)
fedorov

fedorov

2014-04-18 10:19

developer   ~0011609

Steve, assigning to you since no one was assigned automatically - you would know better who is the right person to look into this.

pieper

pieper

2014-04-18 11:41

administrator   ~0011610

Alex - please have a look at this. I recall that we looked at the poly data transform code in vtk and I believe it was doing the correct thing with the normals so perhaps there is something else going on here.

alexy

alexy

2014-04-19 06:31

developer   ~0011619

Indeed, the computation of normals in vtkPolyDataTransform returns NAN's for Bspline.

I traced it to Jacobian computation returning all 0 matrix in ITK class:

BSplineDeformableTransform<TScalar, NDimensions, VSplineOrder>
::ComputeJacobianWithRespectToParameters( const InputPointType & point,
JacobianType & jacobian ) const

called from Slicer's vtkITKBSplineTransform class:

void
InverseTransformDerivativeHelper( vtkITKBSplineTransformHelperImpl<O>* helper,
const T in[3], T out[3], T derivative[3][3] )

May need help from an itk BSpline guru (Jim?)

pieper

pieper

2014-04-19 06:48

administrator   ~0011620

Yes, or as Andras suggested maybe we should switch to the vtk bspline class.

I'll use the 'send a reminder' feature to send this to Jim and Hans in case they have suggestions on Alex's note 11610.

pieper

pieper

2014-04-19 06:49

administrator   ~0011621

Reminder sent to: hjmjohnson, millerjv

Jim and Hans - any thoughts about the jacobian calculation in itk bsplines?

millerjv

millerjv

2014-04-19 07:47

developer   ~0011622

We'll need to take a look at this. I think the BSpline code change in ITKv4. I doubt the vtkITK BSpline was updated.

I don't recall a vtkBSpline class. Perhaps it is new. I would hesitate to use the vtkBSpline as it is not the one used in the registration methods. We'd have to convert between ITK BSplines and VTK BSplines. I anticipate that not being straightforward as the ITK BSplines are built for doing registration.

hjmjohnson

hjmjohnson

2014-04-20 14:24

developer   ~0011625

I think it is wrong in itkv3 and was corrected in v4.

alexy

alexy

2014-04-20 14:39

developer   ~0011626

Slicer4 uses BSplineDeformableTransform::ComputeJacobianWithRespectToParameters() which I believe is ITK4

hjmjohnson

hjmjohnson

2014-05-08 05:21

developer   ~0011711

I think your approach is good. Evenatually, we will be moving to the BSplineTransform to provide better support for ITKv4.

BSplineDeformableTransform is for backwards compatibility to ITKv3

BSplineTransform is a revised and improved version for ITKv4.

lassoan

lassoan

2014-05-12 08:49

developer   ~0011722

Fixed in rev 23148.

Problem:
vtkITKBSplineTransform incorrectly computed the 1. forward derivatives, 2. inverse displacement when there was a bulk transform component and rotated bspline grid, 3. the inverse displacement.

Analysis:
In the ITK bspline transform no inverse computation is available and in the current ITK bspline version no additive bulk transform is supported (therefore it is not backward-compatible with the old ITK bspline transform), ITK's transform support is very limited (compared to the powerful transform pipelines in VTK), and Slicer already uses VTK transforms (vtkGridTransform), therefore the ITK bspline is not usable in Slicer as is.
A bspline transform implementation is available in VTK, which is is efficient and well-tested (and equivalence with ITK's bspline implementation can be proven by testing).

Solution:
Replaced vtkITKBSplineTransform it with a vtkBSplineTransform-based transform, vtkOrientedBSplineTransform, which extends the original VTK class to handle arbitrarily oriented b-spline grids and supports an additive bulk transform.
Added test that verifies the vtkOrientedBSplineTransform's equivalence with the ITK BSpline transform implementation in the whole bspline grid (the differences are less than 1e-10).
Added test that verifies the correctness of the inverse and derivative computation.

Fixes:
http://www.na-mic.org/Bug/view.php?id=3664
http://www.na-mic.org/Bug/view.php?id=3659
http://www.na-mic.org/Bug/view.php?id=3614

millerjv

millerjv

2014-05-12 08:54

developer   ~0011724

Will CLI's written in ITK be able to read and write the bspline transforms that are understood by the new implementation?

lassoan

lassoan

2014-05-12 09:19

developer   ~0011725

ITK is still used for file IO, nothing is changed in the transform file format. The only difference is that ITK is not used for computation.

Now the implementation is consistent for all the transform types (linear, grid, and bspline) and image data: ITK IO is used for initializing VTK objects.

Issue History

Date Modified Username Field Change
2014-04-18 10:17 fedorov New Issue
2014-04-18 10:17 fedorov File Added: Screen Shot 2014-04-18 at 2.13.43 PM.png
2014-04-18 10:18 fedorov File Added: Screen Shot 2014-04-18 at 2.14.00 PM.png
2014-04-18 10:18 fedorov File Added: case9-bspline.tfm
2014-04-18 10:19 fedorov Status new => assigned
2014-04-18 10:19 fedorov Assigned To => pieper
2014-04-18 10:19 fedorov Note Added: 0011609
2014-04-18 11:40 pieper Assigned To pieper => alexy
2014-04-18 11:41 pieper Note Added: 0011610
2014-04-18 13:10 jcfr Target Version => Slicer 4.4.0
2014-04-18 14:20 lassoan Relationship added duplicate of 0003614
2014-04-19 06:31 alexy Note Added: 0011619
2014-04-19 06:48 pieper Note Added: 0011620
2014-04-19 06:49 pieper Note Added: 0011621
2014-04-19 07:47 millerjv Note Added: 0011622
2014-04-20 14:24 hjmjohnson Note Added: 0011625
2014-04-20 14:39 alexy Note Added: 0011626
2014-05-08 04:56 lassoan Assigned To alexy => lassoan
2014-05-08 05:21 hjmjohnson Note Added: 0011711
2014-05-12 08:49 lassoan Note Added: 0011722
2014-05-12 08:49 lassoan Status assigned => resolved
2014-05-12 08:49 lassoan Resolution open => fixed
2014-05-12 08:54 millerjv Note Added: 0011724
2014-05-12 09:19 lassoan Note Added: 0011725
2014-06-14 16:31 fedorov Status resolved => closed
2014-06-14 16:31 fedorov Fixed in Version => Slicer 4.4.0