MIRTK
MIRTK copied to clipboard
Problem with compose-dofs and approximate option
When I try to compose two dof files with the -approximate option, the result is not as expected. Attached are all the files from this short reproducible example.
compose-dofs-reprex.zip
mirtk register im1.nii.gz im2.nii.gz -parin my.cfg -dofout 1_to_2.dof.gz
mirtk register im2.nii.gz im3.nii.gz -parin my.cfg -dofout 2_to_3.dof.gz
mirtk compose-dofs 1_to_2.dof.gz 2_to_3.dof.gz 1_to_3.dof.gz
mirtk compose-dofs 1_to_2.dof.gz 2_to_3.dof.gz 1_to_3_appr.dof.gz -approximate
While the first two dof files have a "control point lattice" of 29x29 and the 1_to_3.dof.gz contains both transformations, the 1_to_3_appr.dof.gz has just a single transformation with a lattice of 1x1. Also, applying transform-image on im1.nii.gz with the 1_to_3.dof.gz has the intended result while applying it with 1_to_3_appr.dof.gz has almost no effect.
As I need a dof file with a single transformation inside, I use
mirtk convert-dof 1_to_3.dof.gz 1_to_3_single.dof.gz
This works as intended.
I think, this problem has previously been reported on Gitter by @karllandheer on Feb 19 2021 22:14
I'm using the latest version of mirtk, compiled today (mirtk rev 973ce2f, built on Aug 5 2022)
Outputs of `mirtk info`
❯ mirtk info 1_to_2.dof.gz
Multi-level FFD:
Global transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = 0.0000 ry = 0.0000 rz = 0.0000
sx = 100.0000 sy = 100.0000 sz = 100.0000
sxy = 0.0000 syz = 0.0000 sxz = 0.0000
Local transformation (passive):
3D B-spline FFD:
Number of DOFs: 2523
Number of CPs (active): 441
Number of CPs (passive): 400
Extrapolation mode: Const
Control point lattice:
Size: 29 x 29
Spacing: 10.00000 x 10.00000
Origin: [ -63.92842 , 33.27434 , -54.88671 , 0.00000]
X-axis: [ -0.61921 , -0.66309 , -0.42057]
Y-axis: [ 0.44986 , 0.13942 , -0.88215]
Z-axis: [ -0.64358 , 0.73544 , -0.21197]
❯ mirtk info 2_to_3.dof.gz
Multi-level FFD:
Global transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = 0.0000 ry = 0.0000 rz = 0.0000
sx = 100.0000 sy = 100.0000 sz = 100.0000
sxy = 0.0000 syz = 0.0000 sxz = 0.0000
Local transformation (passive):
3D B-spline FFD:
Number of DOFs: 2523
Number of CPs (active): 441
Number of CPs (passive): 400
Extrapolation mode: Const
Control point lattice:
Size: 29 x 29
Spacing: 10.00000 x 10.00000
Origin: [ -63.92842 , 33.27434 , -54.88671 , 0.00000]
X-axis: [ -0.61921 , -0.66309 , -0.42057]
Y-axis: [ 0.44986 , 0.13942 , -0.88215]
Z-axis: [ -0.64358 , 0.73544 , -0.21197]
❯ mirtk info 1_to_3.dof.gz
Fluid FFD:
Global transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = 0.0000 ry = 0.0000 rz = 0.0000
sx = 100.0000 sy = 100.0000 sz = 100.0000
sxy = 0.0000 syz = 0.0000 sxz = 0.0000
Local transformation (passive):
3D B-spline FFD:
Number of DOFs: 2523
Number of CPs (active): 441
Number of CPs (passive): 400
Extrapolation mode: Const
Control point lattice:
Size: 29 x 29
Spacing: 10.00000 x 10.00000
Origin: [ -63.92842 , 33.27434 , -54.88671 , 0.00000]
X-axis: [ -0.61921 , -0.66309 , -0.42057]
Y-axis: [ 0.44986 , 0.13942 , -0.88215]
Z-axis: [ -0.64358 , 0.73544 , -0.21197]
Local transformation (passive):
3D B-spline FFD:
Number of DOFs: 2523
Number of CPs (active): 441
Number of CPs (passive): 400
Extrapolation mode: Const
Control point lattice:
Size: 29 x 29
Spacing: 10.00000 x 10.00000
Origin: [ -63.92842 , 33.27434 , -54.88671 , 0.00000]
X-axis: [ -0.61921 , -0.66309 , -0.42057]
Y-axis: [ 0.44986 , 0.13942 , -0.88215]
Z-axis: [ -0.64358 , 0.73544 , -0.21197]
Affine post-transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = 0.0000 ry = 0.0000 rz = 0.0000
sx = 100.0000 sy = 100.0000 sz = 100.0000
sxy = 0.0000 syz = 0.0000 sxz = 0.0000
❯ mirtk info 1_to_3_appr.dof.gz
Fluid FFD:
Global transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = 0.0000 ry = -0.0000 rz = 0.0000
sx = 100.0000 sy = 100.0000 sz = 100.0000
sxy = 0.0000 syz = 0.0000 sxz = 0.0000
Local transformation (passive):
3D B-spline FFD:
Number of DOFs: 3
Number of CPs (active): 1
Number of CPs (passive): 0
Extrapolation mode: Const
Control point lattice:
Size: 1 x 1
Spacing: 0.00000 x 0.00000
Origin: [ -63.92842 , 33.27434 , -54.88671 , 0.00000]
X-axis: [ -0.61921 , -0.66309 , -0.42057]
Y-axis: [ 0.44986 , 0.13942 , -0.88215]
Z-axis: [ -0.64358 , 0.73544 , -0.21197]
Affine post-transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = 0.0000 ry = -0.0000 rz = 0.0000
sx = 100.0000 sy = 100.0000 sz = 100.0000
sxy = 0.0000 syz = 0.0000 sxz = 0.0000
❯ mirtk info 1_to_3_single.dof.gz
Multi-level FFD:
Global transformation:
tx = 0.0000 ty = 0.0000 tz = 0.0000
rx = -0.0826 ry = -0.0266 rz = -0.0061
sx = 100.0275 sy = 99.9523 sz = 99.9112
sxy = -0.0525 syz = 0.0757 sxz = -0.0178
Local transformation (passive):
3D B-spline FFD:
Number of DOFs: 2523
Number of CPs (active): 841
Number of CPs (passive): 0
Extrapolation mode: Const
Control point lattice:
Size: 29 x 29
Spacing: 10.00000 x 10.00000
Origin: [ -63.92842 , 33.27434 , -54.88671 , 0.00000]
X-axis: [ -0.61921 , -0.66309 , -0.42057]
Y-axis: [ 0.44986 , 0.13942 , -0.88215]
Z-axis: [ -0.64358 , 0.73544 , -0.21197]