two real-time with AFNI questions

Greetings, gurujis–

We’re having some fun with AFNI’s real-time capabilities. So far, we’ve managed to get motion params and ROI BOLD data and a real-time voxel time-series versus ideal waveform correlation map. Our ultimate objective is to present relatively clean (detrended plus motion, WM, and CSF regressed) ROI data to folks during scanning. Two questions emerge:

  1. Can you direct me to any existing documentation for obtaining real-time residuals using AFNI? If no such process exists then I’ll recruit MATLAB for the job. Which brings me to the second question…

  2. Have you or others developed anything for either: 1) writing the per-TR motion/ROI values to files for reading by programs waiting around for said files OR 2) managing communication directly between afni -rt and its frequent associates (e.g., MATLAB, R)?

Bonus: In using, I’d like to play with the -data_choice CHOICE option but I don’t see in the documentation what the CHOICEs are. Mind setting me straight?

Many thanks!


Hi Paul,

  1. Cameron Craddock added some support for that in 2012, though I
    do not know of anyone here who has really applied it. The bottom
    line of the RT Options plugin is for such detrending, including
    for ROIs (so maybe WM and CSF), motion and drift. There is not
    really documentation for this, as far as I know.

Note that if it uses ROIs for the detrending, it would presumably
not be able to send out detrended ROI averages. That means you
might have to make an ROI dataset that includes ROIs for both
detrending (e.g. CSF) as well as for feedback. Then your own
code would have to perform that detrending (or perhaps it could
be done via

  1. This is basically what does (as well as
    the older serial_helper), in receiving those values. It could
    easily write them to a text file if desired, for a temporary

But if you mean to send data directly to MATLAB or R programs
(without the intermediate, then I would use as a
template for how to do the TCP communication. While non-trivial,
it is probably not too difficult, either. An overview of that
can be found in the “COMMUNICATION NOTE” in in the -help output
from, including details of the handshake
and termination byte sequences.

Sorry, you are right, I never listed the data_choice options
in the help. They are seen in compute_TR_data():

motion : output the 6 motion parameters
motion_norm : output the euclidean norm of them
all_extras : output all extra data (ROI or voxel values)
diff_ratio : (a-b)/(abs(a)+abs(b)) for 2 ‘extra’ values

Basically, those options are demos to help a user get
started writing their own preferred computation code.

  • rick

Excellent, Rick. Thanks for letting me know!