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?
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:
$ load_layout.py layout01.script
With the help of a short custom python script “load_layout.py”:
#!/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(’//’)]);
subprocess.call(‘afni -com “CLOSE_WINDOW A.axialimage;
CLOSE_WINDOW A.sagittalimage; CLOSE_WINDOW A.coronalimage”
-com “{0}”’.format(com), shell=True)
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.