3dNwarpApply bug?

AFNI version info (afni -ver): Precompiled binary linux_openmp_64: May 8 2023 (Version AFNI_23.1.05 'Publius Helvius Pertinax')

Hello Afni gurus!

I have affine transformations estimated with 3dAllineate that I apply with 3dNwarpApply as follows:

3dNwarpApply -overwrite \
-source good.nii.gz \
-nwarp 'IDENT(good.nii.gz) good.aff12.1D' \
-prefix preproc_good.nii.gz

This works fine for 3/4 runs, but somehow fails in the 4th run as follows:

3dNwarpApply -overwrite \
-source bad.nii.gz \
-nwarp 'IDENT(bad.nii.gz) bad.aff12.1D' \
-prefix preproc_bad.nii.gz
++ 3dNwarpApply: AFNI version=AFNI_23.1.05 (May  8 2023) [64-bit]
++ Authored by: Zhark the Warped
++ opened source dataset 'bad.nii.gz'
++ Processing -nwarp 
++ Warping:.** ERROR (nifti_image_read): failed to find header file for './zyxt'
** ERROR: IW3D_from_nwarp_catlist: this message should never appear!!
** ERROR: Can't acquire/compute nwarp dataset #1 ?!?
** FATAL ERROR: Warping failed for some reason :-(((
** Program compile date = May  8 2023

The problem seems to lie in bad.aff12.1D as applying good.aff12.1D to bad.nii.gz--or replacing to content of bad.aff12.1D with that of good.aff12.1D--runs fine.

Not sure how I can attach those files here, but here is a download link.

bad.aff12.1D looks fine to me... Any idea what is going on?

Note that the -1Dmatrix_apply route with 3dAllineate works, but I will need to incorporate some non-linear warps.

Thanks a lot for your attention and
Have a great day!
S├ębastien

Hi, S├ębastien-

That is weird. I tried replacing different parts of that bad.aff12.1D file, and it looks like it only gives errors if I don't replace the bottom-right value in rightmost value in the bottom row (a bit stochastically, replacing it with like 0.3 led to not having an error). But it looks like minor replacements might also make it work. I tried just peeling off the last timepoint, and this did not produce an error:

tail -n 1 bad.aff12.1D > tmp.aff12.1D
3dcalc -a bad.nii.gz'[98]' -expr a -prefix tmp.nii.gz

3dNwarpApply -overwrite \
    -source tmp.nii.gz \
   -nwarp 'IDENT(tmp.nii.gz) tmp.aff12.1D' \
   -prefix preproc_tmp.nii.gz

So, I'm a bit stumped.

I'll note that this did work:

3dAllineate -1Dmatrix_apply bad.aff12.1D -source bad.nii.gz -final wsinc5 -prefix OUT

... which should should be equivalent (and faster)?

It is true that that the dataset is only 2D+time, but I don't see why that should matter.

So, yes, I'm a bit perplexed.

--pt