3dQwarp Fails (source image has < 100 nonzero voxels after 3dAllineate)?

Hello,

I am running into an error while trying to warp some mice brains into the same space. I have created an FA mean control template (from 6 control mice), and then I warp my experimental FA mice brains to the template. Both the template FA and the experimental FA’s clearly have <<100 nonzero voxels to start with. However, I am getting an occasional error with some of the brains that "3dQwarp fails :: source has <100 nonzero voxels. This seems to occur after the automatic implementation of 3dAllineate associated with my 3dQwarp command. I have attached both an image of the output error and the code section being used. When I don’t receive this error, the warping does seem to work quite nicely. The only other thing I can potentially think might be causing the issue is the implementation of @Align_Centers and 3dresample… but again, this code block works completely well with almost all brains (both mice and rat) that I have thrown at it. Could the 3dAllineate somehow be zeroing out most of these voxels, but only for certain circumstances?

If it helps, the relevant code states:
echo "3dAutobox Brain $a of numbrains, Align_Centers To Template, & 3dresample to Template" 3dAutobox -prefix {currnameFA}_clipped -noclust ${currnameFA}
# @Align_Centers Will Save Shift as .1D file – this could be applied with 3dAllienate, but will be easier to just combine with Warp of 3dQwarp!
@Align_Centers -base template -dset {currnameFA}_clipped+orig. -cm -prefix ${currnameFA}_centered
3dresample -master template -prefix {currnameFA}_centered_sampled -input ${currnameFA}_centered+orig.

	echo "Warping FA of Brain $a of $numbrains to Template Now:"
3dQwarp -base $template -source ${currnameFA}_centered_sampled+orig. -prefix $newnameFA -workhard -minpatch 19 -pblur -inedge -mi -allineate

And the error output is:
3dAutobox Brain 5 of 6, Align_Centers To Template, & 3dresample to Template
++ 3dAutobox: AFNI version=AFNI_19.0.05 (Feb 1 2019) [64-bit]
++ Auto bbox: x=0…33 y=0…53 z=0…36
++ 3dAutobox: output dataset = ./dti_brain5_FA.nii.gz_clipped+orig.BRIK
++ 3dcopy: AFNI version=AFNI_19.0.05 (Feb 1 2019) [64-bit]
++ Rewriting header ./dti_brain5_FA.nii.gz_centered+orig.HEAD
*+ WARNING: Over-writing dataset ./dti_brain5_FA.nii.gz_centered+orig.HEAD
base: -8.04926 -15.504 13.8251
dset: -26.6875 -13.2733 8.15268
delta: 18.638240 -2.230700 5.672420
Warping FA of Brain 5 of 6 to Template Now:
++ OpenMP thread count = 15
++ 3dQwarp: AFNI version=AFNI_19.0.05 (Feb 1 2019) [64-bit]
++ Authored by: Zhark the (Hermite) Cubically Warped
++ Starting 3dAllineate (affine register) command:
3dAllineate -base /home/brb223/r-fcb-isilon/groups/ISNLGroup/CSF1R_Brains/s_2017120701_JPYu_Control_Male_D9_1to6/Control_M_D9_template_space/Control_M_D9.nii.gz -source dti_brain5_FA.nii.gz_centered_sampled+orig. -prefix XYZ_XWI4QRJeDWp1-tB-PrKZrQ.nii -1Dmatrix_save XYZ_XWI4QRJeDWp1-tB-PrKZrQ -cmass -final wsinc5 -float -master BASE -twobest 7 -fineblur 4.44

++ ###########################################################
++ 3dAllineate: AFNI version=AFNI_19.0.05 (Feb 1 2019) [64-bit]
++ Authored by: Zhark the Registrator
++ Source dataset: ./dti_brain5_FA.nii.gz_centered_sampled+orig.HEAD
++ Base dataset: /home/brb223/r-fcb-isilon/groups/ISNLGroup/CSF1R_Brains/s_2017120701_JPYu_Control_Male_D9_1to6/Control_M_D9_template_space/Control_M_D9.nii.gz
++ Loading datasets
++ 23222 voxels in source_automask+0
++ Zero-pad: xbot=4 xtop=4
++ Zero-pad: ybot=4 ytop=3
++ Zero-pad: zbot=4 ztop=4
++ Computing -autobox
++ 93344 voxels [89.2%] in weight mask
++ Number of points for matching = 34977
++ OpenMP thread count = 15
++ ======= Allineation of 1 sub-bricks using Hellinger metric =======
++ *** Coarse pass begins ***
++ *** Fine pass begins ***

  • Final fine fit Parameters:
    x-shift= 2.4855 y-shift= 3.0736 z-shift= -2.0525 … enorm= 4.4540 mm
    z-angle= 26.9183 x-angle= 9.8116 y-angle=-29.8650 … total= 39.4307 deg
    x-scale= 1.0075 y-scale= 0.9987 z-scale= 1.0205 … vol3D= 1.0268
    y/x-shear= -0.0063 z/x-shear= 0.0053 z/y-shear= 0.0005
    ++ Output dataset ./XYZ_XWI4QRJeDWp1-tB-PrKZrQ.nii
    ++ Wrote -1Dmatrix_save XYZ_XWI4QRJeDWp1-tB-PrKZrQ.aff12.1D
    ++ 3dAllineate: total CPU time = 0.0 sec Elapsed = 8.9
    ++ ###########################################################
    ++ # Please check results visually for alignment quality #
    ++ ###########################################################

++ 3dQwarp: replacing source dataset with 3dAllineate result dti_brain5_FA_warped_ControlD9_Allin.nii

  • 3dAllineate output files have been renamed

mat44 3dAllineate matrix:

  0.817707      0.319298      0.494330       2.485540
 -0.450689      0.875437      0.167056       3.073600
 -0.380729     -0.362427      0.874728      -2.052540

** FATAL ERROR: 3dQwarp fails :: source image has 26 nonzero voxels (< 100)
** Program compile date = Feb 1 2019
Concatenating The Two Shifts Into 1 Warp File
3dNwarpCat -prefix dti_brain5_FA_warped_ControlD9_complete_WARP -warp1 dti_brain5_FA_warped_ControlD9_WARP+orig. -warp2 dti_brain5_FA.nii.gz_centered.1D
++ 3dNwarpCat: AFNI version=AFNI_19.0.05 (Feb 1 2019) [64-bit]
++ Authored by: Zhark the Warper
** ERROR: Can’t open dataset from file ‘dti_brain5_FA_warped_ControlD9_WARP+orig.’
** ERROR: Failed to read 3D warp from ‘dti_brain5_FA_warped_ControlD9_WARP+orig.’
** ERROR: Can’t compute nonlinear warp from string 'dti_brain5_FA_warped_ControlD9_WARP+orig. dti_brain5_FA.nii.gz_centered.1D ’
** ERROR: EDIT_dset_items[181]: invalid input dataset
** ERROR: Cannot write dataset: it is invalid

I am using Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-145-generic x86_64), and afni version Precompiled binary linux_ubuntu_16_64: Feb 1 2019 (Version AFNI_19.0.05 ‘Tiberius’).

I’d be happy to send data via private messaging if that helps.

Thanks and best,
Keith

If you like, I can take a look at your data and give you some recommendations. I’ll PM you with some instructions.