afni_align_epi_anat results in very data size

Dear experts,

My alignment process align_epi_anat.py results in very large data size (upto 2.8GB per volume, from the original size of ~300MB), which would crash the subsequent 3dDeconvolve process. Any suggestions are appreciated, or please point me to the right post (if this problem has been reported). Thank you in advance.

The “cmd” script:

run afni_proc.py to create a single subject processing script

afni_proc.py -subj_id $subj
-script proc.$subj -scr_overwrite
-blocks tshift align volreg blur mask scale regress
-copy_anat $top_dir/T1.nii
-tcat_remove_first_trs 0
-dsets
$top_dir/session1_raw.nii
$top_dir/session2_raw.nii
$top_dir/session3_raw.nii
$top_dir/session4_raw.nii
-align_opts_aea -giant_move
-volreg_align_to third
-volreg_align_e2a
-blur_size 4.0
-regress_stim_times
$top_dir/stim.negEmoReg.1D
$top_dir/stim.negative.1D
$top_dir/stim.neutral.1D
-regress_stim_labels
gEmoReg gative utral
-regress_basis ‘BLOCK(8,1)’
-regress_censor_motion 0.3
-regress_opts_3dD
-jobs 4
-gltsym ‘SYM: gEmoReg -gative’ -glt_label 1 gEmoReg-gative
-gltsym ‘SYM: gEmoReg -utral’ -glt_label 2 gEmoReg-utral
-gltsym ‘SYM: gative -utral’ -glt_label 3 gative-utral
-gltsym ‘SYM: 0.333gEmoReg +0.333gative +0.333*utral’
-glt_label 4 mean.GGU
-regress_make_ideal_sum sum_ideal.1D
-regress_est_blur_epits
-regress_est_blur_errts

3dDeconvolve output:
3dDeconvolve -input pb04.Subj01_JiaoDing.r01.scale+orig.HEAD pb04.Subj01_JiaoDing.r02.scale+orig.HEAD pb04.Subj01_JiaoDing.r03.scale+orig.HEAD pb04.Subj01_JiaoDing.r04.scale+orig.HEAD -censor motion_Subj01_JiaoDing_censor.1D -polort 4 -float -num_stimts 9 -stim_times 1 stimuli/stim.negEmoReg.1D BLOCK(8,1) -stim_label 1 gEmoReg -stim_times 2 stimuli/stim.negative.1D BLOCK(8,1) -stim_label 2 gative -stim_times 3 stimuli/stim.neutral.1D BLOCK(8,1) -stim_label 3 utral -stim_file 4 motion_demean.1D[0] -stim_base 4 -stim_label 4 roll -stim_file 5 motion_demean.1D[1] -stim_base 5 -stim_label 5 pitch -stim_file 6 motion_demean.1D[2] -stim_base 6 -stim_label 6 yaw -stim_file 7 motion_demean.1D[3] -stim_base 7 -stim_label 7 dS -stim_file 8 motion_demean.1D[4] -stim_base 8 -stim_label 8 dL -stim_file 9 motion_demean.1D[5] -stim_base 9 -stim_label 9 dP -jobs 4 -gltsym SYM: gEmoReg -gative -glt_label 1 gEmoReg-gative -gltsym SYM: gEmoReg -utral -glt_label 2 gEmoReg-utral -gltsym SYM: gative -utral -glt_label 3 gative-utral -gltsym SYM: 0.333gEmoReg +0.333gative +0.333*utral -glt_label 4 mean.GGU -fout -tout -x1D X.xmat.1D -xjpeg X.jpg -x1D_uncensored X.nocensor.xmat.1D -fitts fitts.Subj01_JiaoDing -errts errts.Subj01_JiaoDing -bucket stats.Subj01_JiaoDing
++ 3dDeconvolve: AFNI version=AFNI_16.0.19 (Mar 29 2016) [64-bit]
++ Authored by: B. Douglas Ward, et al.
++ current memory malloc-ated = 292,936 bytes (about 293 thousand [kilo])
++ loading dataset pb04.Subj01_JiaoDing.r01.scale+orig.HEAD pb04.Subj01_JiaoDing.r02.scale+orig.HEAD pb04.Subj01_JiaoDing.r03.scale+orig.HEAD pb04.Subj01_JiaoDing.r04.scale+orig.HEAD
++ current memory malloc-ated = 11,951,219,248 bytes (about 12 billion [giga])
++ Auto-catenated input datasets treated as multiple imaging runs
++ Auto-catenated datasets start at: 0 240 480 720
++ STAT automask has 766571 voxels (out of 3112136 = 24.6%)
++ Skipping check for initial transients
++ Input polort=4; Longest run=480.0 s; Recommended minimum polort=4 ++ OK ++
++ -stim_times using TR=2 s for stimulus timing conversion
++ -stim_times using TR=2 s for any -iresp output datasets
++ [you can alter the -iresp TR via the -TR_times option]
++ ** -stim_times NOTE ** guessing GLOBAL times if 1 time per line; LOCAL otherwise
++ ** GUESSED ** -stim_times 1 using LOCAL times
++ ** GUESSED ** -stim_times 2 using LOCAL times
++ ** GUESSED ** -stim_times 3 using LOCAL times

GLT matrix from ‘SYM: gEmoReg -gative’:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0

GLT matrix from ‘SYM: gEmoReg -utral’:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -1 0 0 0 0 0 0

GLT matrix from ‘SYM: gative -utral’:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0

GLT matrix from ‘SYM: 0.333gEmoReg +0.333gative +0.333*utral’:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.333 0.333 0.333 0 0 0 0 0 0
++ Number of time points: 960 (before censor) ; 910 (after)

  • Number of parameters: 29 [26 baseline ; 3 signal]
    ++ total shared memory needed = 24,175,072,448 bytes (about 24 billion [giga])
    ++ current memory malloc-ated = 11,954,394,714 bytes (about 12 billion [giga])
    ++ mmap() memory allocated: 24,175,072,448 bytes (about 24 billion [giga])
    Killed

Please let me know which process output is needed to resolve this issue, I will post in subsequent comment, this post is too long already.

What is the original voxel resolution?
For example, what is the output of:

3dinfo session1_raw.nii | grep extents

edit:
To be clear, I expect that you have high in-plane
resolution, and the default resolution is based on
it. You can specify the grid size with the
option, -volreg_warp_dxyz.

But still let me know what the above output is.

  • rick

Thank you for your reply,

“3dinfo session1_raw.nii | grep extents” only output this:
++ 3dinfo: AFNI version=AFNI_16.0.19 (Mar 29 2016) [64-bit]

but “mri_info session1_raw.nii” output this:
Volume information for session1_raw.nii
type: nii
dimensions: 128 x 128 x 24 x 240
voxel sizes: 1.7969, 1.7969, 4.0000
type: FLOAT (3)
fov: 230.000
dof: 0
xstart: -115.0, xend: 115.0
ystart: -115.0, yend: 115.0
zstart: -48.0, zend: 48.0
TR: 2000.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 degrees
nframes: 240
PhEncDir: UNKNOWN
ras xform present
xform info: x_r = -0.9989, y_r = 0.0385, z_r = -0.0251, c_r = 6.0954
: x_a = -0.0369, y_a = -0.9974, z_a = -0.0625, c_a = 12.6415
: x_s = -0.0274, y_s = -0.0615, z_s = 0.9977, c_s = 34.1263
Orientation : LPS
Primary Slice Direction: axial

voxel to ras transform:
-1.7950 0.0692 -0.1002 117.7461
-0.0663 -1.7921 -0.2501 134.5827
-0.0492 -0.1106 3.9909 -3.5364
0.0000 0.0000 0.0000 1.0000

voxel-to-ras determinant 12.915

ras to voxel transform:
-0.5559 -0.0205 -0.0152 68.1686
0.0214 -0.5551 -0.0342 72.0548
-0.0063 -0.0156 0.2494 3.7236
0.0000 0.0000 0.0000 1.0000

The original fMRI volume size is 360MB, after align_epi_anat process, the output volume is 2.8GB, which eventually crash 3dDeconvolve.
Any suggestions are greatly appreciated.
Best,

As rick suggests, add the option -volreg_warp_dxyz 2.0 to your afni_proc.py command and try again.

Yes, ‘extents’ should have been just ‘extent’ in the
earlier grep command. If you are not familiar with
running 3dinfo on a dataset to see the details, it
would be good to try out.

But there are a few small things that lead to a
9 or 10 times scaling in the size:

  1. The voxels will come out at 1.75mm^3 unless
    you specify otherwise. That scales the size by a
    factor of 2.4 (1.79691.79694 / (1.75^3)).

  2. The “extents” of the dataset are larger, to fill
    the box of the template. That probably doubles
    the size.

  3. The data are eventually processed as 32-bit
    floats, not 16-bit short integers. That doubles
    the size.

So the data size will be scaled by 9.6 (2.422),
unless you specify otherwise.

Using voxels of 2mm^3 will scale the size by
2/3 or so (1.75^3/2^3).

Also, use -regress_compute_fitts, which saves
about 40% RAM in the 3dDeconvolve command.

  • rick

Thank you for the very clear explaination.
-volreg_warp_dxyz 2.0 indeed reduced the output size, but down to ~1.9GB, still too large.
So i further increase the voxel size to 3.0, this works perfectly fine and I was able to finish my analysis.
Many thanks to your help.

Best,

It might be preferable to use -regress_compute_fitts
and not sacrifice too much resolution. You can ponder…

  • rick