Overview of afni_proc.py

For those of you without access to a Unix-based platform, or whether you are just having a difficult time correctly installing your Python libraries, uber_subject.py may not be an option for generating templates of AFNI processing scripts. In that case, you can still use afni_proc.py, the command called upon by the uber_subject.py GUI. Building an afni_proc.py script from scratch is not all that difficult, but it can be time-consuming, and I recommend using one of the templates already provided on the AFNI website before creating your own.

The simplest use of afni_proc.py is to use the -ask_me option, which, although limited and not supported anymore, can be useful for creating processing templates that you can then alter. -ask_me will then go through a series of basic questions, such as where your functional data and timing files are located. You can also specify options specific to 3dDeconvolve, such as the basis function for each regressor.

While this will generate a basic template script, however, it is a relatively limited one. For more advanced purposes, I recommend copying one of the examples provided in the help of afni_proc.py, pasting it into a tcsh script, altering it as you need, and then executing it. For example, the following piece of code will search for datasets in the sb23 directory, make a copy of the anatomical dataset and move it to that directory, remove the first 3 volumes of each run, and align each EPI dataset to the last acquired volume (usually, the volume acquired closest to the anatomical run). An individual label is provided for each timing file (make sure that they line up in the order that they are input), and each is convolved with a boxcar function for a duration of 30 seconds. Three separate contrasts are carried out, with different weights for each calculated beta (see the lines under "regress_opts_3dD").



                afni_proc.py -subj_id sb23.blk                             \
                        -dsets sb23/epi_r??+orig.HEAD                      \
                        -copy_anat sb23/sb23_mpra+orig                     \
                        -tcat_remove_first_trs 3                           \
                        -volreg_align_to last                              \
                        -regress_stim_times sb23/stim_files/blk_times.*.1D \
                        -regress_stim_labels tneg tpos tneu eneg epos      \
                                             eneu fneg fpos fneu           \
                        -regress_basis 'BLOCK(30,1)'                       \
                        -regress_opts_3dD                                  \
                            -gltsym 'SYM: +eneg -fneg'                     \
                            -glt_label 1 eneg_vs_fneg                      \
                            -gltsym 'SYM: 0.5*fneg 0.5*fpos -1.0*fneu'     \
                            -glt_label 2 face_contrast                     \
                            -gltsym 'SYM: tpos epos fpos -tneg -eneg -fneg'\
                            -glt_label 3 pos_vs_neg                        \
                        -regress_est_blur_epits                            \
                        -regress_est_blur_errts



Aside from that, make sure to read the help output of afni_proc.py thoroughly. Most likely, one of the examples given will relate to what you want, and it is most efficient to copy that example and make the necessary changes. Also remember that afni_proc.py will only generate a script, which contains all of the individual lines needed to run each step - e.g., slice-timing correction through 3dTshift, regression through 3dDeconvolve, and all of the rest. If you need to make any further alterations, you can simply open up the script with your favorite editor and tweak it.

Overview of the -ask_me option in afni_proc.py. This is for little kids, and grandmas.



More advanced video showing you how to copying other people's work and pass it off as your own.



Thanks to Harshawardhan Deshpande, who is called by his enemies, both out of fear and respect, "El Muchacho".