[MINC-development] reversedef?

Andrew Janke a.janke at gmail.com
Tue May 28 20:17:06 EDT 2013


Hi Alex,

> I was wondering what is happening with reversedef. I noticed it still
> exists in the minctracc/Extra_progs dir, but seems to be somewhat
> dangling.

Not much, it's still there and still works.

> I recall from sometime in the 1990s that it could speed up
> mincresample a fair bit by reorganizing the deformation field somehow.

mincresample is faster if you do this:

   mincresample -transformation xfm_inv.xfm -invert_transformation ...

than if you use the forward transformation. This is due to how the
code works in mincresample, it blits through the output volume finding
data that goes to the current point and then resamples this.

> I have mincresample calls that can run up to an hour or so, so if
> there would be any way to speed these up that would actually be quite
> helpful.

So, reversedef can help you here, the only problem is that this will
then introduce in effect another resampling as when you invert a
transformation you have to resample/regrid the vectors. As I recall
the code in reversedef to do this is NR code.  Perhaps a better
approach and the approach that both Vlad and myself use in our model
building scripts is to generate an inverse transformation in the first
instance.

ie:

   # fit model to the source and resample
   minctracc ....  model.mnc source.mnc xfm_inv.xfm

   mincresample -like model.mnc -transformation xfm_inv.xfm \
       -invert_transformation source.mnc res.mnc

There are other advantages to this approach, the principal being that
this makes averaging xfms a whole lot easier. I have two other tools
that are probably worth mentioning here:

xfm2def - takes a complex xfm (could have multiple grids + linear,
etc) and turns it into a single nonlinear xfm.  This can also speed up
mincresample.

   https://github.com/BIC-MNI/minc/blob/master/progs/xfm/xfm2def.c

gennlxfm

   http://packages.bic.mni.mcgill.ca/scripts/gennlxfm

One of the problems of fitting multiple volumes to a model if you want
to average them is that the grids often don't align with each other
due to the bit of jiggery-pokery that minctracc does when intialising
grids. You can use this to generate an identity nonlinear grid that
you then feed to minctracc.

   # gennlxfm -ident -like model.xfm ident.xfm

   # minctracc -transformation ident.xfm model.mnc source1.mnc output1.xfm
   # minctracc -transformation ident.xfm model.mnc source2.mnc output2.xfm
   # minctracc -transformation ident.xfm model.mnc source3.mnc output3.xfm

You are now guaranteed that output{1,2,3}.xfm are all identically
sampled and thus can be averaged.


a


More information about the MINC-development mailing list