Skip to content

Mac OSX Setup Guide

tbbrown edited this page Sep 11, 2014 · 5 revisions

Setup Guide for the Human Connectome Project Pipeline Scripts for Mac OSX

  • Provided by B. Ely from the Icahn School of Medicine at Mount Sinai
  • Edited Date: 10 Sep 2014

Questions regarding this guide or setting up the HCP Pipelines for Mac OSX should be sent to the HCP-Users email list. Subscribe to the HCP-Users email list at http://humanconnectome.org/contact/#subscribe, then send a message to the list at hcp-users@humanconnectome.org.

  1. Make sure you’ve downloaded the relevant scripts (https://github.com/Washington-University/Pipelines) and put them somewhere useful, e.g. /Applications/Common-Preprocessing/

  2. Make sure your version of OSX is up to date (10.9.4, “Mavericks,” as of this writing). While it's possible to setup on older versions, it’s more trouble, and you’ll need to upgrade eventually, right?

  3. Make sure your default terminal shell is “bash”. Open a terminal window, then go to Preferences. Under the Startup tab, set “Shell opens with:” to “Command (complete path): /bin/bash”

  4. Install the latest version of Xcode. Go to the Apple App store, search for “Xcode,” and install normally.

  5. Agree to the Xcode license by running the following command in terminal:

        sudo xcodebuild –license
    
  6. Install Xcode command line utilities

        xcode-select --install
    
  7. Go here http://www.macports.org/install.php and download/run the MacPorts installer

  8. If terminal is open, exit it completely (right click and quit) then open a new terminal window. Run the command:

        sudo port -v selfupdate
    

    Note: if this doesn’t work, try modifying your .bashrc file. To edit, type:

        nano ~/.bashrc
    

    At the end of the file, paste:

        # MacPorts configuration
        export PATH=/opt/local/bin:/opt/local/sbin:$PATH
        # Finished adapting your PATH environment variable for use with MacPorts.`
    

    Hit Control+x to exit, y to save, then enter to overwrite previous .bashrc file. To make sure .bashrc is being sourced, also check your .bash_profile file:

        nano ~/.bashrc
    

    If it doesn’t contain the following line, add it and save as above

        # initialize with .bashrc
        . ~/.bashrc
    

    Then quit/relaunch terminal and try selfupdate command again.

  9. Make sure your version of Python is up-to-date by running:

        sudo easy_install python
    

    This will update you to the most recent version (currently 2.7). Sufficiently old versions of Python don’t come prepackaged with easy_install, in which case I suggest you speak to my friend Google.

  10. Install the Numpy (Numerical Python) and Scipy (Scientific Python) stacks needed to run gradient_unwarp.py using the following terminal command (one line):

        sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
    
  11. Install NiBabel (Neuroimaging …Babel) using the terminal command:

        sudo easy_install nibabel
    
  12. If you don’t already have it, install FreeSurfer version 5.3.0-HCP which is available at
    ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/5.3.0-HCP

    Follow the standard installation instructions (ignore part about configuring the bash profile for now – will do in step 19).

  13. Obtain a FreeSurfer license file by filling out this form https://surfer.nmr.mgh.harvard.edu/registration.html and save it to the FreeSurfer directory

  14. Download the gradunwarp package from https://github.com/Washington-University/gradunwarp. I suggest somewhere like:

        /Applications/Common-Preprocessing/src/gradient_unwarping
    
  15. Download and install the Connectome Workbench, again installing somewhere useful like:

        /Applications/workbench
    
  16. Completely exit terminal again for luck. Reopen terminal and move to the directory with the gradient unwarp script:

        cd /Applications/Common-Preprocessing/src/gradient_unwarping/
    
  17. Run the setup script:

        sudo python setup.py install
    
  18. Customize the HCP Setup file for your environment – this can be found in …/Examples/Scripts/SetUpHCPPipeline.sh. Main things are to point the HCPPIPEDIR and CARET7DIR to your HCP Pipelines and Connectome Workbench folder, respectively, e.g.

        export HCPPIPEDIR=/Applications/Common-Preprocessing
        export CARET7DIR=/Applications/workbench/bin_macosx64
    

    Save this as something identifiable, like SetUpHCPPipeline_Custom.sh

  19. Configure your .bashrc file to accommodate HCP default settings. In terminal, type:

        nano ~/.bashrc
    

    This will open a file with various terminal configuration settings. Make sure it contains the following:

        # Setup freesurfer path and run configuration script, suppressing terminal output
        export FREESURFER_HOME=/Applications/freesurfer   #or wherever your FS directory is
        source ${FREESURFER_HOME}/SetUpFreeSurfer.sh >/dev/null
        
        # Now add FSL path, source the FSL configuration file, set default output type to .nii.gz, 
        # and avoid some crashes if both .nii and .nii.gz versions of a file exist in a folder
        FSLDIR=/Applications/fsl/fsl  #or wherever your FSL directory is
        . ${FSLDIR}/etc/fslconf/fsl.sh
        PATH=/${FSLDIR}/bin:${PATH}
        export PATH FSLDIR
        export FSLOUTPUTTYPE=NIFTI_GZ
        export FSLMULTIFILEQUIT=FALSE
        
        # Add path for HCP scripts and source the HCP pipeline config files, 
        # suppressing output on terminal
        . /Applications/Common-Preprocessing/Examples/Scripts/SetUpHCPPipeline_Custom.sh >/dev/null
        export HCPPIPEDIR=/Volumes/geezer/Software/Common-Preprocessing
    

    To exit and save once you’ve added the above lines, press:

        Control+x (exit command, prompts to save)
        Y (answer Yes to saving)
        Enter (overwrites the previous .bashrc file)
    

    Quit/reopen Terminal one last time and you should be all set! Any errors along the way are usually traceable. If you’re having an issue with one particular component, try running:

        sudo easy_install COMPONENT
    

    or

        sudo port install COMPONENT