3dDeconvolve differences between proc.py and standalone 3dDeconvolve

Hi there,

I am having trouble reproducing the same results using 3dDeconvolve as I get running the full proc_py script. Of course, i’d like to figure this out, so that I don’t have to preprocess the data every time I’d like to run a new gltsym. I have pasted the code for both 3dDeconvolves at the bottom to show that the flags and preferences are exactly the same.

1. SubBrick Differences
The first difference I noticed, was that 3ddeconvolve, when run through ProcPy creates a sub-brick for the coef, tstat, and fstat of each condition/contrast, as well as an overall full_fstat. However, when I run 3dDeconvolve, instead i get only a Tstat and coef for each condition, and the only fstat is the overall full_fstat. Is this a sign that internally there is a difference in what is being run?

See images below - you may need to click on the link:

A. ProcPy- 3 bricks per condition:
http://imgsafe.org/image/01138612a0

B. Standalone 3dDeconvolve - 2 bricks per condition
http://imgsafe.org/image/011798c1e1

2. Number of voxels included in contrasts - more voxels included when using standalone 3dDeconvolve
I am creating subject-specific masks for voxels that are more active for one condition than the others. I’ve found that creating this mask using both the proc_py and standalone 3dDeconvolve contrasts lead to different results.

For instance, I create a mask using the following code on the proc_py stats file using subbrick 20, which is the tstat associated with my contrast of interest:



thresh1="$(p2dsetstat -inset stats.${subj}_REML+orig.'[20]' -pval 0.001 -2sided -quiet)"
3dcalc -a stats.${subj}_REML+orig.'[20]' -expr "ispositive(a-${thresh1})+isnegative(${thresh1}-a)" -prefix faceSelectiveMask_Standard_procPy.nii

This produces a tstat of 3.34571 and a mask that contains 1,385 voxels. (according to output of '3dBrickStat -count -non-zero faceSelectiveMask_Standard_procPy.nii ')

However if I create the same mask using the stats file created with 3dDeconvolve and sub=brick 14 for the same contrast


thresh1="$(p2dsetstat -inset stats_3dDeconvolve.${subj}_REML+orig.'[14]' -pval 0.001 -2sided -quiet)"
3dcalc -a stats_3dDeconvolve.${subj}_REML+orig.'[14]' -expr "ispositive(a-${thresh1})+isnegative(${thresh1}-a)" -prefix faceSelectiveMask_Standard_3dD.nii

I get a slightly different tstat here 3.3454 instead of 3.3457. Additionally the mask ends up being several hundred voxels larger at 1,615 voxels, compared to 1,385.

  1. I am pretty confident that the standalone 3dDeconvolve code is the same as the one in the proc_py script (save for the addition of two more gltsym in procpy).
    I am pasting both below for comparison. Given this, do you have any idea why i might be getting these discrepancies?? I’d like to get to a point where the result are the same, so that i can feel confident in using 3dDeconvolve on its own. Please let me know why you think there might be this discrepancy!

A. proc_py code for 3dDeconvole:


# ------------------------------
# run the regression analysis
3dDeconvolve -input pb04.$subj.r*.blur+orig.HEAD                         \
    -mask mask_anat.$subj+orig                                           \
    -censor censor_${subj}_combined_2.1D                                 \
    -ortvec mot_demean.r01.1D mot_demean_r01                             \
    -ortvec mot_demean.r02.1D mot_demean_r02                             \
    -ortvec mot_deriv.r01.1D mot_deriv_r01                               \
    -ortvec mot_deriv.r02.1D mot_deriv_r02                               \
    -polort 2                                                            \
    -local_times                                                         \
    -num_stimts 6                                                        \
    -stim_times 1 stimuli/a_face_times.txt 'GAM'                         \
    -stim_label 1 A_Face                                                 \
    -stim_times 2 stimuli/a_scram_times.txt 'GAM'                        \
    -stim_label 2 A_Scram                                                \
    -stim_times 3 stimuli/b_face_times.txt 'GAM'                         \
    -stim_label 3 B_Face                                                 \
    -stim_times 4 stimuli/b_scram_times.txt 'GAM'                        \
    -stim_label 4 B_Scram                                                \
    -stim_times 5 stimuli/fixationCross_times.txt 'GAM'                  \
    -stim_label 5 Fix_Crs                                                \
    -stim_times 6 stimuli/obj_times.txt 'GAM'                            \
    -stim_label 6 Obj                                                    \
    -GOFORIT 12                                                          \
    -num_glt 4                                                           \
    -gltsym 'SYM: +2*A_Face +2*B_Face -A_Scram -B_Scram -Fix_Crs -Obj'   \
    -glt_label 1 Face_Selective_Voxels_Standard                          \
    -gltsym 'SYM: +1.5*A_Face +1.5*B_Face -A_Scram -B_Scram -Fix_Crs'    \
    -glt_label 2 Face_Selective_Voxels_NoObjects                         \
    -gltsym 'SYM: +A_Face +B_Scram -B_Face -A_Scram'                     \
    -glt_label 3 Asian_Dir_Interaction                                   \
    -gltsym 'SYM: +B_Face +A_Scram -A_Face -B_Scram'                     \
    -glt_label 4 Black_Dir_Interaction                                   \
    -jobs 4                                                              \
    -fout -tout -x1D X.xmat.1D -xjpeg X.jpg                              \
    -x1D_uncensored X.nocensor.xmat.1D                                   \
    -fitts fitts.$subj                                                   \
    -errts errts.${subj}                                                 \
    -bucket stats.$subj

B.Standalone 3dDeconvole code:


3dDeconvolve -input pb04.${subj}.r01.blur+orig.HEAD pb04.${subj}.r02.blur+orig.HEAD \
-mask mask_anat.${subj}+orig \
-censor censor_${subj}_combined_2.1D \
-ortvec mot_demean.r01.1D mot_demean_r01 -ortvec mot_demean.r02.1D mot_demean_r02 -ortvec mot_deriv.r01.1D mot_deriv_r01 -ortvec mot_deriv.r02.1D mot_deriv_r02 \
-polort 2 \
-local_times \
-num_stimts 6 \
-stim_times 1 stimuli/a_face_times.txt 'GAM' -stim_label 1 A_Face  \
-stim_times 2 stimuli/a_scram_times.txt 'GAM' -stim_label 2 A_Scram \
-stim_times 3 stimuli/b_face_times.txt 'GAM' -stim_label 3 B_Face \
-stim_times 4 stimuli/b_scram_times.txt 'GAM' -stim_label 4 B_Scram \
-stim_times 5 stimuli/fixationCross_times.txt 'GAM' -stim_label 5 Fix_Crs \
-stim_times 6 stimuli/obj_times.txt 'GAM' -stim_label 6 Obj \
-GOFORIT 12 \
-num_glt 2 \
-gltsym 'SYM: +2*A_Face +2*B_Face -A_Scram -B_Scram -Fix_Crs -Obj' -glt_label 1 '3dDeconvolved - Face Selective Voxels Standard' \
-gltsym 'SYM: +1.5*A_Face +1.5*B_Face -A_Scram -B_Scram -Fix_Crs' -glt_label 2 '3dDeconvolved - Face Selective Voxels Sans Objects' \
-jobs $NUM_CPUS \
-fout -tout -x1D X.xmat_3dDeconvolve.1D -xjpeg X_3dDeconvolve.jpg -x1D_uncensored X.nocensor_3dDeconvolve.xmat.1D -fitts fitts_3dDeconvolve.${subj} -errts errts_3dDeconvolve.${subj} -bucket stats_3dDeconvolve.${subj} \


Hello,

The code looks the same to me (except for putting spaces in the label names, which might not be a good idea).

But if you are missing F-stats in the standalone version, I must suspect the your $NUM_CPUS variable is not actually set, and when 3dDeconvolve is run, it sees instead “-jobs -fout”, and the -fout option does not make it to the program.

You can check this by running “3dinfo stats.3dDeconvolve…” and looking at the actual command.

In any case, you do not have to write your own 3dDeconvolve command. Copy and edit the original afni_proc.py command script, and add:

-write_3dD_script SCRIPTNAME
-write_3dD_prefix WITH_NEW_GLTs
… and add your new -gltsym options …

That will generate “SCRIPTNAME” with a 3dDeonvolve command to be run in the already existing results directory, and it will create output files with your specified prefix. You might try that even if you get your current script to work.

  • rick

Thanks ! I’ll try this out!