1.1.7. Mac OS

What to do?

These setup instructions are for Mac OS versions 10.9+.


If you are seeking the new App version of install instructions, *and have a Mac OS version <=10.14 (not 10.15!), please click HERE.

  1. Each step involves either copy+pasting a command, or clicking on a download link.

  2. The user must have admin privileges (can run sudo ...). Some steps require an internet connection.

  3. Is your terminal shell bash or tcsh (or other)? To find out, type:

    echo $0
  4. Do the system check in the “Evaluate” stage. Try any recommendations in its “Please Fix” section.

  5. If you run into any problems, please just ask a clear question on the Message Board.

  6. To open a text file, you can type open -t FILENAME. For example, to open the bash “rc” file:

    open -t ~/.bashrc

Setup terminal

  1. Copy+paste:

    defaults write org.macosforge.xquartz.X11 wm_ffm -bool true
    defaults write org.x.X11 wm_ffm -bool true
    defaults write com.apple.Terminal FocusFollowsMouse -string YES

    Purpose: This sets the policy where “focus follows mouse” for relevant applications. After this, clicks on a new window are directly applied, without needing to “pre-click” it. You’re welcome.

Install Xcode and XQuartz

  1. Copy+paste:

    xcode-select --install
  2. For …

    • … OS X >= 10.11, click on this link: http://www.xquartz.org
      and then click on the “Quick Download” DMG, and follow instructions to install.
    • … OS X 10.9 and 10.10, copy+paste:


    Purpose: These install Xcode command line tools (needed for the gcc compiler et al.) and XQuartz (the desktop manager needed to run X11 programs, such as afni!).

  3. Copy+paste this mess:

    touch ~/.cshrc
    echo 'if ( $?DYLD_LIBRARY_PATH ) then' >> ~/.cshrc
    echo '  setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace' >> ~/.cshrc
    echo 'else' >> ~/.cshrc
    echo '  setenv DYLD_LIBRARY_PATH /opt/X11/lib/flat_namespace' >> ~/.cshrc
    echo 'endif' >> ~/.cshrc
    touch ~/.bashrc
    echo 'export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace' >> ~/.bashrc

    Purpose: This adjusts the library format variable for XQuartz in both tcsh and bash. Sigh.

Install AFNI binaries

  1. For …:

    • … (default) installing the binaries from online, copy+paste:

      curl -O https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries
      tcsh @update.afni.binaries -package macos_10.12_local -do_extras
    • … (alternative) installing already-downloaded binaries, you can use -local_package .. (replace “PATH_TO_FILE” with the actual path; also, if @update.afni.binaries has also been downloaded, you can skip the curl .. command), copy+paste:

      curl -O https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries
      tcsh @update.afni.binaries -local_package PATH_TO_FILE/macos_10.12_local.tgz -do_extras

    Purpose: Download and unpack the current binaries in your $HOME directory; set the AFNI binary directory name to $HOME/abin/; and add that location to the $PATH in both ~/.cshrc and ~/.bashrc.

  1. Copy+paste:

    cp $HOME/abin/AFNI.afnirc $HOME/.afnirc
    suma -update_env

    Purpose: Set up vanilla-mode environment variables for AFNI and SUMA. To see how you can bend these to your will later, read the Technical notes.


Please reboot your system.

Purpose: This deals with system updates, any change in login shell, and path updates.

Install R

  1. Click on this link: https://cran.r-project.org/bin/macosx/el-capitan/base/R-3.6.3.nn.pkg

    Purpose: Get R-3.6.3 (a recent, but not the most recent, version of R).

  2. Copy+paste:

    sudo rPkgsInstall -pkgs ALL

    Purpose: Get specific R packages needed for AFNI programs.

Install Netpbm

  1. Copy+paste:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
  2. Copy+paste:

    brew install netpbm
  3. Copy+paste:


Purpose: Install “netpbm”, which has functionality for converting image formats (such as to PNG) and is used in several programs like @snapshot_volreg, @chauffeur_afni and others.

Setup Python (opt)

  1. AFNI has very minimal Python requirements—at present, matplotlib and numpy. For example, for the recommended automatic QC output from afni_proc.py, matplotlib is necessary.

    You can use any method to install+manage Python and its dependencies. But we note that we have found Miniconda to be convenient in managing Python environment(s), and it is replicatable across platforms. If you are interested, you can check out this tutorial, which has both verbose and quick instructions.

    But Miniconda is not required.

Prepare for Bootcamp

  1. Copy+paste:

    curl -O https://afni.nimh.nih.gov/pub/dist/edu/data/CD.tgz
    tar xvzf CD.tgz
    cd CD
    tcsh s2.cp.files . ~
    cd ..

    Purpose: Download the Bootcamp class data; untar+unzip it (= open it up); move into the newly opened directory; execute a script to copy the files to $HOME/..

    If no errors occur in the above, and your afni_system_check.py says things are OK, you can delete/remove the tarred/zipped package, using “rm CD.tgz”. If you are really confident, you can also deleted the CD/ directory in the present location.

  2. !Pro tip!: Bring a computer mouse to use at the Bootcamp. It is muuuuch easier to follow the demos that way.

  3. Read+practice with the handy Unix documentation/tutorial.

    Purpose: give you a quick lesson/refresher on using basic Linux shell commands (e.g., ls, cd, less, etc.). It will greatly enhance your bootcamp experience– we promise!

Evaluate setup/system (important!)

  1. Copy+paste:

    afni_system_check.py -check_all
  2. Read the “Please Fix” section at the end. If there are no suggestions, then rejoice! Otherwise, try the suggestion(s) there.

  3. Open up the AFNI and SUMA GUIs, juuuust to make sure all is well:


    Report any crashes!

  4. If stuck, then …

    • … put any error message into an online search, and/or post a question on the Message Board

    • … copy+paste this:

      afni_system_check.py -check_all > out.afni_system_check.txt

      ... and email the file “out.afni_system_check.txt” to an AFNI Guru for advice.

Niceify terminal (optional, but goood)

To improve your life when using the terminal, copy+paste these:

echo 'set filec'    >> ~/.cshrc
echo 'set autolist' >> ~/.cshrc
echo 'set nobeep'   >> ~/.cshrc

echo 'alias ls ls -G'    >> ~/.cshrc
echo 'alias ll ls -lG'   >> ~/.cshrc
echo 'alias ltr ls -lGtr'   >> ~/.cshrc
echo 'alias ls="ls -G"'  >> ~/.bashrc
echo 'alias ll="ls -lG"' >> ~/.bashrc
echo 'alias ltr="ls -lGtr"' >> ~/.bashrc

Purpose: The first commands set up tab autocompletion for tcsh (which should already be enabled for bash users by default). The second set of commands make aliases so that different types of files (“normal” files, zipped files, executables, et al.) and directories are shown using different colors and boldness. It makes it much easier to navigate on a terminal, IMHO.

Keep up-to-date (remember!)

  1. To update your AFNI sometime, copy+paste:

    @update.afni.binaries -d

    That’s it!!

    Purpose: This will automatically download the correct, latest AFNI version to your computer, replacing your old binaries. It will also update the apearch help information. Update often!

  2. To check your AFNI version, copy+paste:

    afni -ver

    Purpose: Report this useful info whenever asking a question on the Message Board!


The record of all changes (new options, new programs, bug fixes, et al.) in AFNI programs is maintained for all to see in the online AFNI History.

Install PyQt4, via JDK and fink (optional)

Note: at present, this step is only necessary if you want to have some of the Python-based GUI programs in AFNI. However, we don’t really use these much, and certainly if you are here for uber_subject.py, we would strongly recommend that you just build an afni_proc.py command from existing examples in the afni_proc.py help, instead!

  1. and then click on the Java icon.

    Purpose: Install Java SE (standard edition) JDK.

  2. Copy+paste:

    curl -O https://afni.nimh.nih.gov/pub/dist/bin/misc/save/install.fink.bash
    bash install.fink.bash

    Purpose: This runs an install script to download+install the package manager fink.

    This takes perhaps 30 minutes to finish and the user gets asked many questions (sorry, no way around it). One can simply keep hitting the ENTER key to accept the useful defaults (note: you can respond with ‘n’ for the Xcode installation prompt if prompted otherwise, as you should have it from an earlier step).

  3. Do each of the following (installs PyQt4):

    1. Open a new terminal window.

    2. Copy+paste:

      fink --version
    3. If no errors, copy+paste:

      sudo fink install pyqt4-mac-py27
    4. Copy+paste:

      sudo ln -s /sw/bin/python2.7 /sw/bin/python
      echo 'setenv PYTHONPATH /sw/lib/qt4-mac/lib/python2.7/site-packages' >> ~/.cshrc
  4. To test your PyQt4, copy+paste:


    Does a GUI open? Or is there a crash??