Hi Afni Experts,
I am interested in combining subject level corrections using quadratic corrections (3dAllineate -nwarp option with bilinear) with my warps to MNI which are derived from auto_warp.py. In this case, instead of having just the 3dAllineate affine .aff12.1D file, I will have a parameter file instead.
If I wanted to combine 3dAllineate parameter file with my 3dQwarp warp field, can I do so similar to the typical case of 3dNwarpApply -nwarp ‘warp.nii aff12.1D’ ? Will this also combine the bilinear terms or just the affine matrix portion?
If this is not possible, is there any other way to get it into one single warp or would I have to first apply the param file and then warp the subsequent file to MNI space?
I wanted to follow up with my original email below to see if anyone had any thoughts/guidance.
Thanks,
Ajay
I am interested in combining subject level corrections using quadratic corrections (3dAllineate -nwarp option with bilinear) with my warps to MNI which are derived from auto_warp.py. In this case, instead of having just the 3dAllineate affine .aff12.1D file, I will have a parameter file instead.
If I wanted to combine 3dAllineate parameter file with my 3dQwarp warp field, can I do so similar to the typical case of 3dNwarpApply -nwarp ‘warp.nii aff12.1D’ ? Will this also combine the bilinear terms or just the affine matrix portion?
If this is not possible, is there any other way to get it into one single warp or would I have to first apply the param file and then warp the subsequent file to MNI space?
* The option '-nwarp_save sss' lets you save a 3D dataset of the
the displacement field used to create the output dataset. This
dataset can be used in program 3dNwarpApply to warp other datasets.
++ If the warp is symbolized by x -> w(x) [here, x is a DICOM 3-vector],
then the '-nwarp_save' dataset contains w(x)-x; that is, it contains
the warp displacement of each grid point from its grid location.
++ Also see program 3dNwarpCalc for other things you can do with this file:
warp inversion, catenation, square root, ...
It has been a long time since this option was implemented, so I can’t be sure if it still works as advertised. You’ll have to try it and see.
However, I’m not sure why you would want to combine bilinear warps (a very old idea of mine that didn’t prove useful, IMHO) with much more general nonlinear warps.
Hi Bob,
I was looking at bilinear for eddy current correction to test against affine to see if it was much better or not. I ran into a strange problem. I ran the following:
ind=0
while [ $ind -le 60 ]
do
3dAllineate -base B0ref_resamp.nii.gz -source dwi.nii[$ind] -master BASE -prefix eddy_${ind}.nii -1Dmatrix_save dwi_${ind}.aff12.1D -1Dparam_save dwi_${ind}.param.1D -nwarp_save warp_${ind}.nii.gz -warp aff -nwarp bilinear
ind=$((ind+1))
done
NOTE:B0ref_resamp.nii.gz is a higher resolution (1.5mm iso) than the dwi set (2mm iso). I also have B0ref.nii.gz which is the same resolution as dwi (2mm).
When I use 3dAllineate -1Dparam_apply dwi_0.param.1D -nwarp bilinear -master B0ref.nii.gz -source dwi.nii[0] -prefix dwi.eddy.0_test.nii it looks perfect.
When I use 3dNwarpApply it looks very zoomed in compared to the original reference image and cuts the brain off:
3dNwarpApply -nwarp ‘warp_0.nii.gz’ -master B0ref.nii -source dwi.nii[0] -prefix dwi.eddy.0.nii
When I tried combining affine+nonlinear again the image looks zoomed in. Is there something that is wrong that I should change to get nwarp to work correctly? I also tried adding IDENT(B0ref.nii.gz) before and after the original try of using warp_0.nii.gz to see if resampling helps and it does not…any ideas?
I would eventually like to combine the bilinear warp field with a warp to MNI which is why I want to figure out how to use the nwarp option in 3dNwarpApply.
I’d have to actually try this – possibly there is some incompatibility in the software between the bilinear warp and the 3dQwarp. For me, it would be simplest if you can provide some sample data (e.g., on Dropbox or Google Drive) with copies of the commands you ran. Then I can duplicate what you did, and figure out if (a) there’s a mistake in your commands, or (b) there’s a mistake in my software, or (c) BOTH.
You seem to be trying to duplicate the pre-processing calculations of various existing DTI processing packages. The package from NIH is called TORTOISE, and has excellent eddy current corrections built-in – among many other features. We work with the TORTOISE group, and don’t really want to spend effort to replicate their years of work.
Hi Bob,
I was planning on using this same step with my resting state analysis to better account for geometric distortions on this dataset that does not have a field map to my mean EPI image. Since the bilinear option seems quicker than 3dQwarp for this step i figure I can test on the DTI since the distortion on this subject is slightly worse than the resting state scan but definitely would want to use in the resting state analysis.
You can use 3dQwarp with options “-maxlev 0 -noQ -allineate” to make it compute a warp with the affine part (“-allineate”) plus a single 3D cubic polynomial (“-maxlev 0 -noQ”). These results should be similar to the mostly useless bilinear warp and will be available for use with other programs, such as 3dNwarpApply.
“-noQ” is a hidden option, which just means to skip the quintic polynomial steps at level 0 (the global patch). This option will make level 0 run pretty fast, since it will just do one cubic optimization.
Hi Bob,
When using B0ref.nii as the base and B0vols.nii[0] as the source (all same resolution), I assumed that this would potentially mitigate any underlying issues of the 3dAllineate -nwarp bilinear warp field being created from different resolution datasets being off.
Interestingly, when I used 3dNwarpApply on the resulting warp field the image looked correct except that it was shifted in the Z direction by 1.5*(Zvox resolution). In my case since the voxel size in the Z direction is 2mm I used the following commands to fix the error:
Extract the X and Y component of the warp field which seem correct:
3dcalc -a warp_1.nii.gz[0…1] -datum float -prefix warp_1a.nii.gz -expr ‘a’
Fix the Z component of the warp field which is off by 3mm in this case (or generalized to 1.5*Zvoxsize)
3dcalc -a warp_1.nii.gz[2] -datum float -prefix warp_1b.nii.gz -expr ‘a+3’
Concatenate the new field
3dTcat -prefix warp_2.nii.gz warp_1a.nii.gz warp_1b.nii.gz
The scaling is still an issue with different resolution between base/source, but when matched this seems to work…I am going to be running a few datasets with different resolutions in case the 1.5*Zvox was somehow a fluke and will follow up if this is not the case. Hope this helps.
Hi Bob,
Thanks for the followup and other options. I saw this after I sent my message on 3dAllineate. I’ll try it out!
Best,
Ajay
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.