Is it possible to open multiple linked afni GUIs programmatically?

Dear afni experts,

When exploring MRI data with afni, it is often necessary to open multiple linked afni GUI windows in order to see and compare multiple coregisted datasets side-by-side interactively, especially when comparing the impact of different MR sequence, experiment design, or data processing parameters.

Very often, I find myself need to re-open the same set of views (even with the same underlay/overlay datasets) repeatedly, after closing them all for various reasons. This is pretty time-consuming and frustrating (press the New button 3~6 time, choose underlay and overlay for each of them, adjust threshold settings, etc.).

Is there a way to open multiple linked afni GUIs with specified underlay/overlay datasets and perhaps specified threshold values among other adjustable settings programmatically?



See the 4 plugout_drive commands in @DriveAfni
(in the binary directory). The first 2 work with
controller A, the latter 2 work with controller B.

The typical way one opens an afni window is with
something like:

-com ‘OPEN_WINDOW A.sagittalimage geom=+45+430’

Change ‘A’ to ‘B’ and now it is for controller B,
which will open up new controller and image

  • rick

Thanks, rick! This is really cool!

In case someone else is also interested in similar functionality, here is my current approach:
After opening multiple afni controllers, I save my multi-controller layout (as well as underlay, overlay, color, threshold, etc. associated with each controller) by:
Define Datamode > Misc > Save Layout > layout01.script (N.B.: file name must contain “script”)

And then reload this layout by:
$ layout01.script

With the help of a short custom python script “”:

#!/usr/bin/env python

-- coding: utf-8 --

from future import print_function
import sys, subprocess

if name == ‘main’:
afni_script = sys.argv[1]
with open(afni_script) as f:
lines = f.readlines()
com = ‘; ‘.join([line.strip() for line in lines if not line.startswith(’//’)]);‘afni -com “CLOSE_WINDOW A.axialimage;
CLOSE_WINDOW A.sagittalimage; CLOSE_WINDOW A.coronalimage”
-com “{0}”’.format(com), shell=True)

For more information, check
plugout_drive as a demo plugout as well as a tool
“-com” option of afni
All available commands

That is great!

Note that there is also a -layout option in afni.

  • rick