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".
Hello Andrew,
ReplyDeleteThX for you useful blog. I am really a new and beginner in writing script for AFNI. I'm recently joined to the brain research center. They asked me to write some software to do some real time staff on the fMRI. so here I am now!!
I've watched some of your videos on youtube or in your blog, but I need more help!
For example, I found to generate a script I should use AFNI_proc.py, but in the last step (using _ask_me) it ask me about stim files, but I don't have it and I don't know what it is honestly! I've downloaded the first data set from http://afni.nimh.nih.gov/afni/download/data/releases/latest but there is no stim file or stim times, what should I do now? and what is you suggestion for me to be an expert in this area so fast? I am ready to read and do anything to improve my knowledge and help my skills to implement that real time code.
Thanks so much again. Hope you can help me :)
Best,
Nafis
Hi Nafis,
DeleteI apologize for only getting to this now - I must have forgotten about it, and I only caught it recently!
In case it is still of any help, stim files are text files containing the times when specific events happened; with AFNI, each regressor (or condition) has its own timing file, with a series of numbers designating when that particular condition occurred.
If you don't have any timing files, you can still run the afni_proc.py script by creating a dummy timing file (such as writing the numbers 0, 15, 30 into a text file and saving it), and then using that with afni_proc.py so that it won't crash.
Hope this helps, and again, I apologize for responding so late!
Best,
-Andy
Hi Andy,
ReplyDeleteI am beginning as well and am confused about something very basic—what to name my datasets (runs) in the second step.
Thanks,
Daisy
Hi Daisy,
DeleteThe question mark "?" is a wildcard that represents exactly one character. In the example, if I have 3 runs in my directory called r01, r02, and r03, then that line will expand to all three of them. You can alter the code to suit your run names.
Best,
-Andy