can't malloc -1437173116 bytes in 3dNwarpApply

Hi, afni experts
I am trying to concatenate an affine (from 3dAllineate) and a nonlinear transform (from SSwarper) in 3dNwarpApply. However, the command keeps crashing. Actually, I tried to apply the affine and the nonlinear separately and both got good results. However, if I concatenate them. Commands crashed. Also, the exact same command worked on other subjects but kept crashing on one subject. Did I do something wrong? The error message is below.

ruyuan@stone:~/Dropbox/stonesync/monkeyanatpp/starlord$ 3dNwarpApply -prefix NMTseg_dti_FA.nii.gz -nwarp ‘dti_FA_affepi2t1_t1_matINV.aff12.1D starlord_anatT1_NMT2origWARP.nii.gz’ -source /home/stone/ruyuan/afniresource/NMT/NMT_v1.2/atlases/D99_atlas/D99_atlas_1.2a_al2NMT.nii.gz -master dti_FA.nii.gz -ainterp NN -overwrite -short
++ 3dNwarpApply: AFNI version=AFNI_18.2.19 (Sep 27 2018) [64-bit]
++ Authored by: Zhark the Warped
++ opened source dataset ‘/home/stone/ruyuan/afniresource/NMT/NMT_v1.2/atlases/D99_atlas/D99_atlas_1.2a_al2NMT.nii.gz’
++ -master dataset is ‘dti_FA.nii.gz’
++ Processing -nwarp
++ Warping:** ERROR: EDIT_full_copy: can’t malloc -1437173116 bytes for new sub-brick 0

  • Dataset ./Nwarp#02+orig.HEAD

Fatal Signal 11 (SIGSEGV) received
THD_nwarp_regrid
IW3D_set_geometry_nwarp_catlist
IW3D_read_nwarp_catlist
3dNwarpApply
Bottom of Debug Stack
** Command line was:
3dNwarpApply -prefix NMTseg_dti_FA.nii.gz -nwarp ‘dti_FA_affepi2t1_t1_matINV.aff12.1D starlord_anatT1_NMT2origWARP.nii.gz’ -source /home/stone/ruyuan/afniresource/NMT/NMT_v1.2/atlases/D99_atlas/D99_atlas_1.2a_al2NMT.nii.gz -master dti_FA.nii.gz -ainterp NN -short
** AFNI version = AFNI_18.2.19 Compile date = Sep 27 2018
** [[Precompiled binary linux_openmp_64: Sep 27 2018]]
** Program Death **
** If you report this crash to the AFNI message board,
** please copy the error messages EXACTLY, and give
** the command line you used to run the program, and
** any other information needed to repeat the problem.
** You may later be asked to upload data to help debug.
** Crash log is appended to file /home/stone/ruyuan/.afni.crashlog

Best
ruyuan

Add another piece of information here. I made two further explorations:

  1. I used 3dNwarpCat to combine the affine and the nonlinear warp file. Then use 3dNwarpApply to apply the obtained warp file. It reported no crash but produced very bad warp results.
  2. I ran two stages transformation. First did the nonlinear warp, saved the result. Then ran the affine. The results looked reasonable. However I have to resample twice in this regime.

It seems that 3dNwarpCat did not very well…

Hi, Ruyuan-

First question: @SSwarper on its own produces both an affine (*aff12.1D) and a nonlinear (WARP) transform that should be concatenated-- I’m not sure why a separate call to 3dAllineate would be needed or desired?

Also, from the 3dNwarpApply help file, I think the order of your concatenation in your original command is backwards:


3dNwarpApply -prefix Fred_final    \
                     -source Fred+orig     \
                     -master NWARP         \
                     -nwarp 'Fred_WARP+tlrc Fred.Xaff12.1D'

–pt

Thanks Paul

I actually first align my macaque T1 image to the NMT macaque template and obtained a nonlinear transformation file (i.e., WARP.nii.gz). I checked that this transformation was correct. I then align my EPI image to T1 and obtained an affine transformation matrix (i.e.,_mat.aff12.1D). My goal is to extract an ROI defined in the NMT template and warp back to the EPI space. In this case, I have to concatenate the affine the and nonlinear transformation matrix.

I did this for other three monkeys and it worked very well. It however always made the program crashed on one monkey brain. I am very confused. Now I am not able to concatenate them and have to resample twice, NMT template - t1 - epi.

I can provide the data if you are willing to take a look.

ruyuan

The way the transformations are concatenated can take a lot of memory if the datasets are not close in space to each other. I typically will use @Align_Centers to put the center of the dataset over the template’s center. The NMT align script and the macaque_align.csh script do this first before computing alignment. The SSwarper script requires a specially crafted dataset to do its business.

Thanks Daniel. I think that might be the reason. I indeed did the @align_center step when I aligned data but combined the shift matrix to other affine transformations. If memory is an issue, I need to keep the shift matrix.

Thanks again

ruyuan

That needs to be separate if you can manage it. Usually, you can work around this issue because there is no interpolation done by @Align_Centers because that transformns by just changing the origin in the header using 3drefit. The center shift transformation can be applied to other datasets with the -child option for @Align_Centers. If you are interested in the inverse transformation, you can apply a transformation via @Align_Centers again with the base and dset datasets reversed.