How to load a file of AFNI startup driving script?

Hi AFNI gurus,

On AFNI startup, I wanna simultaneously open 2 controllers with different underlay datasets displayed. I did so manually and saved the layout as a “script” file. Suppose the file name of this script is “a.script”, how can I execute it on AFNI startup? I have tried “afni -com a.script”, but it doesn’t work with an error message of “ERROR: Can’t drive AFNI with ‘a.script’”.

Thank you for your help!


The instructions, with some examples, for driving AFNI are here:
and the plugout instructions are:

Looking at the first example in the first file, I think you would want your AFNI commands in the file to look something like:

afni -com 'OPEN_WINDOW A.axialimage'       \
       -com 'SWITCH_UNDERLAY anat'         

If you wanted to, you could use the scripts to enter file names on the command line and to pass the file names to the commands, that way having a flexible tool. But if you have consistent names, then you could put static names after the SWITCH_UNDERLAY option.


You should provide the saved layout file
with the -layout option, as in:

afni -layout a.script

  • rick

Thank you Paul for this prompt response!
Actually what I meant to ask was whether there is a SINGLE option that can read in a lot of command lines saved in a script file. Including many specifications of window positions, my script file has tens of lines but I want to avoid typing tens of “-com”.

Thank you Rick, but “-layout” doesn’t work with an error message of “LAYOUT not found in layout file a.script”.

For the same layout, if I save it with a name of “a.layout”, the content is:
A geom=+2+23

But if I save it with a name of “a.script”, the content is:
OPEN_WINDOW A geom=+2+23

So the “-layout” only reads in things of “attribute=parameter”, but does not execute things like “SET_UNDERLAY”

If you prefer the actual script format, I do not
see a direct option. However you can set
AFNI_STARTUP_SCRIPT to the name of the
script, e.g.


How is that?

  • rick

It worked like a charm, Rick, thank you!