Using Matlab with AFNI

Ziad Saad has developed a package of Matlab functions to read, write, and process AFNI datasets. This may be useful for the hackers amongst you that want to do some quick calculations, or otherwise have some fun.

  1. The Matlab functions and associated files can be downloaded in tar+gzip format from file afni_matlab.tgz in this directory. The library unpacks into the directory ./afni_matlab.

  2. This library is in a (permanent) testing phase. Please report any errors you find to ziad@codon.nih.gov and we will do our best to correct them promptly. Any other comments are also appreciated. The library may be re-distributed.

  3. The Matlab script called MatAFNI_Demo.m can be run/viewed to see how the library works. To use this, you will also have to download the tar+gzip archive afni_matlab_data.tgz of some sample datasets, available in this directory. The data archive unpacks into the directory ./afni_matlab_data (about 21 Mbytes). The script should be a useful illustration of how to access and write AFNI data. Also see the Test* set of scripts for further examples.

  4. Writing AFNI bricks assumes you have an understanding of their header structure. Please read and understand the README.attributes file that is included in AFNI's distribution before writing bricks with these (or other) functions. There's only so much automatic checking on the header content that can be done and I can imagine quite a bit of room for creative error making! For convenience, I have included a copy of README.attributes with the library distribution. However, this file may not be the most current version that is being distributed with AFNI.

  5. Presently, documentation is only available by using the help function in Matlab.

  6. Remember: The data in the .BRIK is stored in the order (orientation) in which the images were loaded into to3d. So, in order to know how to slice through a data set you need to look into the Info structure (output of BrikInfo and BrikLoad). I have included the AFNI* functions to help shed some light into this darkness.

  7. Brik or Brick about 100 functions later ...: I regret having used brik instead of brick in many of the functions. It just looks wrong, but at the time I thought it mirrored .BRIK a little better. So some functions use Brik some Brick, I am sure you'll get used to this minor inconvenience.

  8. Set the Matlab path appropriately (e.g., add the afni_matlab directory to the MATLABPATH environment variable).

Ziad Saad
SSCC/NIMH/NIH
ziad@nih.gov