Possible problem with 3dAllienate and 3dQwarp

Dear AFNI experts,

We realized that we have voxels outsite of the brain with very low values (e.i. 0.0867) after we run:

3dAllineate -prefix [i]output.nii[/i] -base [i]MNI_template[/i] -source [i]Image[/i] -1Dmatrix_save [i]file_aff12.1D[/i]

Then, after using 3dQwarp, these low values extend even further. We run the command in the following way:

3dQwarp -prefix [i]output_Qwarp.nii[/i] -base  [i]MNI_template[/i] -source  [i]output_allineate.nii[/i]  -nmi  -workhard

Please see the attached images. We would like to know if these steps are correct. If so, should we do something the erode the low values? or is this normal?

Thanks in advance,




Yes, that’s normal. Warping involves regridding, and regridding involves interpolation, and that kind of “ringing” happens all the time, I think. (Hopefully, your main internal structures are well-aligned; you can turn down the opacity of the overlay to check?)

In fact, the recommendation interpolation kernel for the final data set when you have non-integer valued datasets is “wsinc5”, which will exhibit ringing with tiny values outside the brain; the trade off is that the interpolation inside the brain (where we care about data/values) should be as sharp as possible (or, quite sharp relative to most other kernels like cubic splines). If those tiny values bother you, you can probably automask, or dilate then inflate the brain to remove them, for example such as:

3dmask_tool -dilate inputs -2 2 -prefix OUTPUT_MASK -inputs INPUT_FILE
3dcalc -a OUTPUT_MASK -b INPUT_FILE -expr 'step(a)*b' -prefix OUTPUT_FILE_MASKED


Rather than doing this as two steps, you could use auto_warp.py or @SSwarper to combine the transformations and have only one interpolation.

Hi, Karel-

Sorry, I missed the aspect that Daniel pointed out in his reply-- while warps can be calculated individually, they should be concatenated and applied as a single warp. That is probably a much more important point than what I had noted… Daniel pointed out quite useful programs for that-- @SSwarper will combine skullstripping with estimating a warp from subject anatomical to template space. We often recommend that now as part of a standard processing stream: it tends to have nice alignments and also skullstrips the data nicely.