Batch processing

Hi AFNI masters,

I would like to process (using the same commands) several BRIK files which are located in different directories.
How can I do that using a single script and not individually for every file? Is there an example batch processing script I can use? I really just need the relevant syntax.


Hi, Sun-

Can you please be more specific— for example, what is 1 full command that you want to run; and then what does your file structure look like?

Also, what shell are you wanting to batch using? For example, tcsh, bash, zsh…?

Rick has created a nice Unix tutorial here:
… to help with learning+understanding syntax.

There are also scripting tidbits here (but these basically assume that you know the content of the tutorial above):



I would like to (1) allineate (using 3dAllineate) anatomy data to MNI, (2) then to allineate to this anatomy EPI data (3) and finally to resample the allineated EPI data so it will match a certain parcellation atlas (using 3dresample).

I have 18 subjects, each one was scanned during 6 or 7 different days, 2 scans per day (1 anatomy per day).

I’m using tcsh shell.

Thanks for the answer and the tutorials!

Hi, Sun-

Is your ultimate goal for these alignments to move the EPI into MNI space?

If so, this is really a job that should be taken on with, I think. And also, 3dAllineate is good for aligning, say, a subject’s EPI to their own anatomical; but to align an anatomical to a template, nonlinear registration should be used—e.g., using @SSwarper (for combining skullstripping with warping).