Odd crash and error during afniproc.py

Hello, the attached script is crashing, with the following error message:

++ Processing -nwarp ** FATAL ERROR: malloc (out of memory) error for dataset sub-brick #0

This memory error message is odd since I have more than enough memory-per-cpu going for this processing, it is only 20 minutes of task-MRI data, and I have processed more data with less memory in the past. Is anyone able to notice a problem in the script? It has worked for me no problem in the past (with different data as input). Or, has anyone had this error before and had it not pertain to an explicit memory issue on their cpu?


I think this could happen if your EPI is veery far away (spatially) from the final template dataset. In short, the warp program creates a grid that encompasses both, at the spatial resolution of the template (so, reasonably high res), and if they are far apart, that can be gigantic. But, this is only a postulate.

What is the output image of each of these look like:

@djunct_overlap_check    \
     -ulay ${top_dir}/nlWarp/MNI152_2009_template_SSW.nii.gz \
     -olay ${epi_dir}/MJ022+orig'[0]' \
     -prefix IMAGE1

@djunct_overlap_check    \
     -ulay ${top_dir}/nlWarp/MNI152_2009_template_SSW.nii.gz \
     -olay ${top_dir}/nlWarp/022_10012020_anatWarped/anatSS.022_10012020.nii \
     -prefix IMAGE2


(Also, it would probably be a bit easier to read the full afni_proc.py command if you copy+pasted it into the text here-- that image is a bit grainy and oddly spaced; there is even a “code” block icon just above the Message Board text fields that you can wrap code in, so it is offset in bright yellow-- the icon looks like a tiny white rectangle, kind of like a small postal letter but I guess it is supposed to look like code.)


Here is that code, thanks for the tip. As far as @djunct_overlap_check, my AFNI (19.0) does not seem to recognize it as a viable command. What version are you running it on?

#!/usr/bin/env tcsh

# created by uber_subject.py: version 0.37 (April 14, 2015)
# creation date: Thu Dec 31 14:20:32 2015

# set data directories
set top_dir   = /project2/jschnei1/MRI/MJE/MJ_022_10012020
set anat_dir  = $top_dir/Nifti
set epi_dir   = $top_dir/ZShim

# set subject and group identifiers
set subj      = MJ_022_10012020
set group_id  = test

# run afni_proc.py to create a single subject processing script
afni_proc.py -subj_id $subj                                                     \
        -script proc.$subj.IGT -scr_overwrite                                   \
        -blocks despike tshift align tlrc volreg blur mask scale regress        \
        -copy_anat $top_dir/nlWarp/022_10012020_anatWarped/anatSS.022_10012020.nii                  	\
	-anat_has_skull no 							\
        -anat_follower anat_w_skull anat $anat_dir/MJ_022-S1_WIP_T1_W_3D_5_1.nii           \
        -tcat_remove_first_trs 0                                                \
        -tshift_opts_ts -tpattern altplus                                       \
        -dsets $epi_dir/MJ022+orig.HEAD                   \
        -volreg_align_to MIN_OUTLIER                                            \
        -tlrc_base $top_dir/nlWarp/MNI152_2009_template_SSW.nii.gz                              \
        -volreg_align_e2a                                                       \
        -volreg_tlrc_warp                                                       \
	-tlrc_NL_warp								\
	-tlrc_NL_warped_dsets							\
		$top_dir/nlWarp/022_10012020_anatWarped/anatQQ.022_10012020.nii			\
		$top_dir/nlWarp/022_10012020_anatWarped/anatQQ.022_10012020.aff12.1D			\
		$top_dir/nlWarp/022_10012020_anatWarped/anatQQ.022_10012020_WARP.nii			\
        -blur_size 5.0                                                          \
        -mask_epi_anat yes                                                      \
        -regress_stim_times                                                     \
            $top_dir/control.txt                                                \
            $top_dir/losses.txt                                                 \
            $top_dir/selAB.txt                                                  \
            $top_dir/selCD.txt                                                  \
            $top_dir/wins.txt                                                   \
        -regress_stim_labels                                                    \
            control losses selAB selCD wins                                     \
        -regress_basis 'GAM'                                                    \
        -regress_censor_motion 0.3                                              \
        -regress_apply_mot_types demean deriv                                   \
        -regress_motion_per_run                                                 \
        -regress_opts_3dD                                                       \
            -gltsym 'SYM: wins -losses' -glt_label 1 wins-losses                \
            -gltsym 'SYM: selAB -selCD' -glt_label 2 selAB-selCD                \
            -gltsym 'SYM: .5*selAB +.5*selCD -control' -glt_label 3 sel-control \
	-regress_reml_exec							\
        -regress_anaticor_fast                                                  \
        -regress_make_ideal_sum sum_ideal.1D                                    \
        -regress_est_blur_epits                                                 \
        -regress_est_blur_errts                                                 \
        -regress_run_clustsim no


Great, thanks, that AP is much easier to read. If you have Python+matplotlib on your computer, I would definitely add “-html_review_style pythonic”, so you get the much nicer AP QC output HTML.

The @djunct_overlap_check program got added in Oct 2020. Actually, just to have the most recent set of AFNI programs (including afni_proc.py QC output), I would really recommend to update your local AFNI:

@update.afni.binaries -d

Your current version is nearly 2 years old… that is a long time in AFNI-land!


Sorry for the delayred response, it took a bit to get my afniVer updated. Attached are the images output from the djunct_overlap_check commands. It seems like something is quite wrong…


Well, just to be clear: those images show your initial datasets over the template (not the results after alignment).

The (likely) problem this reveals is one that relates to how 3dQwarp works to apply warps: it creates a mesh at the “base” dataset resolution that spans both the source and base dset FOVs, and then applies the warp. If the source and base are far apart (which is essentially what your images are showing), then that intermediate dset can be huge and lead to a crash. I believe that is what is happening here.

Can I send you a link for uploading your initial dsets so I could take a look?


Yes, that would be great. Thanks.

Just checking back in. Were you able to access the relevant files within the box folder?