Exporting transforms from BigWarp

Right now we have 3 imaging modalities generating images a, b, and c. We used BigWarp to register modality a to modality b, and ANTs to register modality b to modality c. Ideally, if we could get the transformation from BigWarp in the right format, we could use antsApplyTransforms to sequentially apply transforms and effectively allign modality a to modality c since a->b->c is the same as a->c without having to actually do another transformation. We would like to automate this process in a script instead of having to use the GUI each time, and I thought ANTs might be a good way to do this. However, it seems like the file format that BigWarp outputs does not play nice with ANTs. If BigWarp can be used as a command line tool, that might be a better route to go. Unfortunately I couldn’t get it to install using conda. Is this no longer supported? Answered on github: https://github.com/saalfeldlab/bigwarp/issues/71

1 Like

Hi @zmiller22,

Sorry it took me awhile to get back to you.

Dealing with error - running master

Still looking into what caused the NullPointerException you pointed to in the issue - I can reproduce it when using the 0.1.0 release of the template-building repo.

But it seems to be working (for me) when I use master.

To get that to work I:

cd <template repo>
git checkout master
mvn clean compile install

Then I had to modify the file:
<template-repo>/jgo/transformImage to:

jgo.sh org.scijava:saalfeldlab-template-building:0.1.1-SNAPSHOT:process.TransformImage "$@"

Now if you re-run, I’d expect you won’t get the NullPointer anymore.

Preprocess ANTs

To be “safe,” I recommend doing two thing to your ANTs transforms to make it more likely to work.

  1. unzip you warp fields if they’re zipped (.gz)
  2. Convert the affine parts to text files using the ants utility:
ConvertTransformFile 3 $in $out --hm

Tips on running:

The following will describe how how we push an image through two transformations - one generated by ants, and the one generated by bigwarp - in that order.

I.e. the result will be what you’d get if you:

  1. Warp the image with ants
  2. Warp the result of (1) with bigwarp

but will be better because it will only be interpolated once (not twice).

I’m going to put together a downloadable example for you, but you can use transformImage to concatenate transformations you have with ANTs, and transforms you make with bigwarp:

transformImg \
    -i TeforBrain_3p6iso.nrrd \
    -o TeforBrain_3p6iso_xfmAffineWarpBw-master2.nrrd \
    -f jrc18_3p6.nrrd \
    -t WarpJrc18_landmarks.csv \
    -t tefor_to_jrc18_1Warp.nii \
    -t tefor_to_jrc18_Affine.mat \
    -j 8

I generated the transform in two parts:

First ANTs:
moving image TeforBrain_3p6iso.nrrd
target image jrc18_3p6.nrrd

ANTs generates an affine file that we converted to tefor_to_jrc18_Affine.mat as described above, as well as tefor_to_jrc18_1Warp.nii.

WarpJrc18_landmarks.csv stores the landmarks that I clicked with bigwarp.

Notice that the transforms are perhaps in the opposite order you’d expect. This is not a typo - it’s because all of these transforms are inverse transforms, because we need inverse transforms to warp images.

I’ll post these data somewhere soon so you can try it,


The test data I referenced above are downloadable from here:


Awesome, I will give it a try in the next couple days. Thank you so much!

1 Like