1.1.5. Mac OS: The essential system setup

What to do?

Here we describe a complete AFNI installation and system setup for clean/empty Mac OS versions 10.9+.

For each step, either:
  1. copy+paste commands from the green fields into the terminal (help and shortcuts here), or
  2. click on a link to download+install a package.

We assume the user has admin privileges (can run sudo ...), and some steps require an internet connection. Some steps depend on the OS version.

To find out what shell you are using (e.g., bash or tcsh), type:

echo $0
IMPORTANT: Please:
  1. Do all steps.
  2. Run afni_system_check.py -check_all in the “Evaluate” stage.
  3. And follow the system check recommendations in the output “Please Fix” section.

If anything seems problematic, please just ask a clear question on the Message Board.

Note

If you are seeking the new App version of install instructions, please see HERE.

Setup terminal

  1. Copy+paste the following into a terminal:

    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”, so that it is not necessary to first click on a new window (to select it) before subsequent clicks are applied to that window. These commands set the policy for the 3 applications that this might apply to.

Install Xcode and XQuartz

  1. Do the following for your system number:

    • For OS X >= 10.11,

      1. Copy+paste the following:

        xcode-select --install
        
      2. Then, click on this link: http://www.xquartz.org
        and then click on the “Quick Download” DMG and follow instructions to install.
    • For OS X 10.9 and 10.10,

      1. Copy+paste these two commands:

        xcode-select --install
        /Applications/Utilities/X11.app
        

    Purpose: These install Xcode, which is needed for the gcc compiler and related tools, and XQuartz, which is the desktop manager needed to run X11 programs (such as afni).

  2. Copy+paste the following:

    touch ~/.cshrc
    echo 'setenv DYLD_LIBRARY_PATH /opt/X11/lib/flat_namespace' >> ~/.cshrc
    
    touch ~/.bashrc
    echo 'export 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

Copy+paste the following:

cd
curl -O https://afni.nimh.nih.gov/pub/dist/bin/macosx_10.7_local/@update.afni.binaries
tcsh @update.afni.binaries -defaults

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

Note

If the AFNI binary package has already been downloaded already (say, to save time/bandwidth), one can use -local_package, followed by the location+name of the binary file, e.g. the third line in the above command could be:

tcsh @update.afni.binaries -local_package macosx_10.7_local.tgz -do_extras

Reboot

Please reboot your system.

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

Install R

  1. and then click on the top/latest package to install.
  2. Then, copy+paste:

    sudo rPkgsInstall -pkgs ALL
    

    Purpose: Get specific R packages needed for AFNI programs.

Make AFNI/SUMA profiles

Copy+paste the following:

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

Purpose: As noted in the Technical notes, AFNI and SUMA have a lot of default settings, controlled using environment variables. The above initializes vanilla-mode profiles with default values for both AFNI and SUMA.

These files ($HOME/.afnirc and $HOME/.sumarc) can be edited to the user’s heart’s content, setting up specific profile features you want when using AFNI and SUMA (e.g., having left=left when viewing axial slices, making default colorbars, etc.).

Prepare for Bootcamp

Copy+paste the following:

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: In order, these commands: get the tarred+zipped directory that contains the class data (and is hence named “CD”), downloading it to the current location in the terminal; untar/unzip it (=opens it up); go into the newly opened directory; execute a script to copy the files to $HOME/CD/; and finally exit the directory.

At this point, if there have been no errors, you can delete/remove the tarred/zipped package, using “rm CD.tgz”. If you are really confident, you can also deleted the CD tree in the present location (but leaving it in $HOME/CD/).

Note

If using Linux terminal commands is new to you, then do look over the handy Unix documentation/tutorial and practice a few of the basic commands on your own system (e.g., ls, cd, less, etc.). It will greatly enhance your bootcamp experience– we promise!

Evaluate setup/system (important!)

  1. Copy+paste the following, and read the displayed “Please Fix” section at the end of the output (try the suggestions there!):

    afni_system_check.py -check_all
    

    … and, for extra help, copy+paste this:

    afni_system_check.py -check_all > out.afni_system_check.txt
    

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

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

    afni
    suma
    

    Report any crashes!

  3. If the “system check” gives any errors, please:

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 ls="ls -G"'  >> ~/.bashrc
echo 'alias ll="ls -lG"' >> ~/.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 any time in the future, just run:

    @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. Check your AFNI version by typing:

    afni -ver
    

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

Note

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)

  1. and then click on the Java icon.

    Purpose: Install Java SE (standard edition) JDK.

  2. Copy+paste the following:

    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
      sudo ln -s /sw/bin/python2.7 /sw/bin/python
      echo 'setenv PYTHONPATH /sw/lib/qt4-mac/lib/python2.7/site-packages' >> ~/.cshrc
      
  4. Test your PyQt4.

    Copy+paste the following:

    uber_subject.py
    

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