Skip to content

Instantly share code, notes, and snippets.

@danjgale
Created August 9, 2018 18:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save danjgale/4f64ca81f5e91cc0669d0f744c7a9f82 to your computer and use it in GitHub Desktop.
Save danjgale/4f64ca81f5e91cc0669d0f744c7a9f82 to your computer and use it in GitHub Desktop.
Pysurfer installation guide for Python 3.6

Installing Pysurfer with Python 3.6

Pysurfer can be a bit tough to install because the dependencies (e.g., Mayavi) can be tricky to get right. Further, the documentation, at the time of this writing, states that Pysurfer only works with Python 2.7. This is not entirely the case, as Pysurfer does in fact work with Python 3. Here, I've documented the installation steps to get Pysurfer working with Python 3 on OSX (I'm guessing these steps also hold for Linux; not sure about Windows).

Setup

Before we begin, you'll need conda installed to create a virtual environment, and you will also need Freesurfer installed on your computer (follow the installation steps for your operating system, as is, here).

Then, let's set up our conda environment. We'll want to specify Python 3.6 and install some dependencies:

$ conda create -n pysurfer python=3.6 pip mkl numpy scipy matplotlib "pyqt>=5.9" "vtk>8" pygments traits traitsui pyface

Now let's activate the pysurfer environment, install the remaining dependencies, and finally pysurfer itself:

$ source activate pysurfer
$ pip install mayavi nibabel imageio
$ pip install pysurfer

Once this is done, fire up your python terminal and test out your installation (based on this example):

from surfer import Brain

brain = Brain(subject_id='fsaverage', hemi='lh', surf='inflated')

You should see a brain open up in a new window. With that, you're set!

Special thanks to @rmarkello for coming up with these steps. We hope that these instructions can help save some time and headaches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment