Skip to content

Deformation field debugging

John Bogovic edited this page Feb 5, 2019 · 7 revisions

Deformation field debugging

Effect of quantization

  • I quantized the JRC2018F_JFRC2010 field, specifying the max error to be 0.08um (quantization multiplier = 0.046188)
  • Compared the results:
Command
compareDfields /groups/saalfeld/public/jrc2018/transformations/jrc2018F-jfrc2010/JRC2018F_JFRC2010_Warp.nii /groups/saalfeld/public/jrc2018/transformations/quant/JRC2018F_JFRC2010_transform_quant16.h5 0.08
dfield1: [0, 0, 0, 0] -> [1426, 663, 412, 2], dimensions (1427, 664, 413, 3)
dfield2: [0, 0, 0, 0] -> [1426, 663, 412, 2], dimensions (1427, 664, 413, 3)
min error magnitude : 0.0
avg error magnitude : 0.011574032532083861
max error magnitude : 0.03883343141295593

Max error is within specified tolerance. Conclusion - quantization works

Effect of downsampling

Subsampling (mine)

I subsampled with imglib2: Views.subsample( field, 2, 2, 2, 1 ) where the 4th dimension stores displacement vector components.

Command
downsampleDfield \
    -d /groups/saalfeld/public/jrc2018/transformations/jrc2018F-jfrc2010/JRC2018F_JFRC2010_Warp.nii \
    -o /nrs/saalfeld/john/tests/dfield_downsample_tests/jrc18F_jfrc2010/dfield_downMy.nii \
    -f 2,2,2,1 --sample

Max error is larger than I'd like.

 dfield1: [0, 0, 0, 0] -> [1426, 663, 412, 2], dimensions (1427, 664, 413, 3)
 dfield2: [0, 0, 0, 0] -> [713, 331, 206, 2], dimensions (714, 332, 207, 3)
min error magnitude : 0.0
avg error magnitude : 0.00560486476846499
max error magnitude : 0.2579358430108029

Subsampling (ants)

Peculiarities

Command
dfield="/groups/saalfeld/public/jrc2018/transformations/jrc2018F-jfrc2010/JRC2018F_JFRC2010_Warp.nii"
ResampleImageBySpacing 3 $dfield dfield_downAnts.nii 0.88 0.88 0.88 0 0 0

Part of the original header describing dimensions / sizes

    dim[0] = 5
    dim[1] = 1427
    dim[2] = 664
    dim[3] = 413
    dim[4] = 1
    dim[5] = 3
    dim[6] = 1
    dim[7] = 1
    intent_code = 1007

Part of the header of the downsampled image describing dimensions / sizes

    dim[0] = 3
    dim[1] = 713
    dim[2] = 331
    dim[3] = 206
    dim[4] = 1
    dim[5] = 1
    dim[6] = 1
    dim[7] = 1
    intent_code = 0

Note nifti intent code changes, and dim[5] (holding the displacement vectors) is length 1 not 3. The output file is too small: 186M. For comparison, the file subsampled with imglib2 is 562M. I looked at the output, and it indeed looks like ants picked one 3d subset of the displacement field and downsampled that.

Note dim[0] stores the number of dimensions.

Comparing transforming points

Do my code and ANTs produce the same results when applying transforms written by ANTs?