eXTReMe Tracker
Sep 122016
 

Updated 2017.03.28

  • Freesurfer 6.0 is now a stable release and there are couple of additional dependencies that weren’t required in the beta release of freesurfer. I have changed the post to reflect the list of libraries that need to be installed.

There is good news for those who use neuroimaging tools such as AFNI, FSL and FreeSurfer on their Windows machines. The limitation is that they can only be run on Windows 10 with anniversary update. Does it use a Virtual Machine? No. It runs “natively” on Windows 10, so you can save, print, resize or hide any interface just like a Windows program.

Freeview running in Windows 10

Freesurfer on Windows 10

Before I get into how to install FreeSurfer, I must thank the author at K-Lab for the post on “How to run FSL on Windows 10“. That post describes how to install BASH on Windows 10 in the first few steps. Sadly it is not available for Windows 7/8. It uses Ubuntu 14.04 LTS which will be supported by Canonical until 2019. We hope by then Windows would incorporate the Ubuntu 16.04 LTS as the default distribution.

I’ll repeat a few things (steps 1-5) that Lin4Neuro wrote on how to get BASH and X-server on Windows 10.

  1. Install Linux BASH shell on Windows 10:
    There is detailed tutorial with screenshots on how to do this at the following site.
    How to Install and Use the Linux Bash Shell on Windows 10
  2. Install the updates:
    Before adding any tools, you should first download and install the updates for Ubuntu. Run the following commands at the terminal

    sudo apt-get update
    sudo apt-get upgrade
  3. Install the X server:
    With bash you can run applications on a command line but in order to run any GUIs for neuroimaging tools you’ll need a X-server for windows. The most popular software for this is Xming. You can download and install it with default settings.
    Xming X server for Windows
  4. Running X server:
    Run Xming by searching it from start menu. When it is loaded you should see this when you go to show hidden icons button at the bottom right corner of your desktop.
    xming_server
  5. In order for X server to work with BASH run the following command at the terminal
    echo "export DISPLAY=localhost:0.0" >> ~/.bashrc

    This will add the environment variable for display to the .bashrc file.


  6. Downloading Freesurfer (Release 6.0):
    You can obtain your copy of Freesurfer from their web page. To download FreeSurfer type this command at the terminal:

    ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

    Hint: You can copy the link with your mouse and when you right-click at the terminal, it will be automatically pasted so you don’t have to type it in manually.
    This is a large file (~4.6GB) so it may take some time to download it based on your network speed.

  7.  It is customary to install it at /usr/local/ so let’s extract it to that directory.
    sudo tar -xzf freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz -C /usr/local/

    You will require your admin password (for Ubuntu, not Windows) to extract it to /usr/local. Again, this step can take few minutes since we are extracting a file that’s several gigabytes in size. Once extracted, we’ll have to change permissions on that folder.

    sudo chmod -R 755 /usr/local/freesurfer

    This allows you to edit or create files in that folder.

  8. Obtain the FreeSurfer license:
    In order to run the FreeSurfer applications you need to register and obtain a license from their website.
    FreeSurfer Registration
    Once you have the license emailed to you, copy the contents between the lines that read “cut here” and create a license.txt file.

    sudo nano /usr/local/freesurfer/license.txt

    fs_lic
    Paste the contents with right-click
    Press ctrl+X to exit
    Press y to accept and save it as license.txt
    Hit Enter

  9. Add FreeSurfer path to .bashrc:
    echo "export FREESURFER_HOME=/usr/local/freesurfer" >> ~/.bashrc
    echo "source \$FREESURFER_HOME/SetUpFreeSurfer.sh" >> ~/.bashrc
  10. Dependencies: libjpeg.so.62, libgomp1, etc.
    Generally there are a few dependencies including the tcsh shell that aren’t included by default in the ubuntu distribution.  But they can be installed using:

    sudo apt-get install build-essential libjpeg62 libxss1 libgomp1 tcsh

    There may be some other dependencies that may be needed as time goes on. The best way to get the needed ones is to type in sudo apt-get install <partial-name-of-needed-file> and then hit tab to see if it recognizes and autocompletes the name of that dependency. It will work in most cases.

  11. Final check:
    Check that the Xming server is running and it says Xming Server:0.0 when you hover the mouse on the Xming icon in the lower right hand corner. Type bash at the terminal. You should see the following:

    -------- freesurfer-Linux-centos6_x86_6.0 --------
    Setting up environment for FreeSurfer/FS-FAST (and FSL)
    FREESURFER_HOME   /usr/local/freesurfer
    FSFAST_HOME       /usr/local/freesurfer/fsfast
    FSF_OUTPUT_FORMAT nii.gz
    SUBJECTS_DIR      /usr/local/freesurfer/subjects
    MNI_DIR           /usr/local/freesurfer/mni
  12. Test your installation:
    Check if everything works by going through some of the examples listed on the FreeSurfer website.
    FreeSurfer examples
    If everything has been installed correctly you should be able to run command line functions and open GUIs just like on a Mac or Linux machine.
    tksurfer_win10If you have any questions about the installation, please post a comment. If you have questions about FreeSurfer please visit the FreeSurfer user community mail archives.

  13 Responses to “Installing and running FreeSurfer on Windows 10”

  1. You need to add backslash before $ when adding the source line:

    echo “source \$FREESURFER_HOME/SetUpFreeSurfer.sh” >> ~/.bashrc

    If not, it will interpret it as a variable and will add only:

    “source /SetUpFreeSurfer.sh” to .bashrc

  2. Thanks for the tip Dorian. I will edit the command so others can get it working correctly.

  3. Having a problem when running
    sudo wget ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/dev/freesurfer-Linux-centos6_x86_64-dev.tar.gz

    which says,
    freesurfer-Linux-centos6_x86_64-dev.tar.gz: Permission denied

    Any suggestions?

  4. You won’t need admin rights or sudo to acquire the tar.gz file. Simply running
    wget ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/dev/freesurfer-Linux-centos6_x86_64-dev.tar.gz
    should download the file to your working directory.

  5. I have tried the command without sudo beforehand, but it just didn’t work.
    Actually, now the BASH itself can’t run properly… Seem like the subsystem doesn’t work smoothly on my PC.
    Thanks anyway!

  6. When I try to run freeview, I get the error message “/usr/local/freesurfer/bin/freeview.bin: Exec format error. Binary file not executable.”

    Do you know what might be causing that?

  7. In my experience, Freesurfer version 5.3 does not seem to work, unfortunately. It uses statically linked ELF executables and those are rejected as “cannot execute binary file: Exec format error”. Version 6 works since it’s using dynamically linked ELF binaries.

  8. Thank you Zsolt for your suggestion. Since I only used the Freesurfer v6, I wasn’t running into the “Binary not executable” error. Brain, please try version 6. Even though it is still not officially released, it is functionally quite solid.

  9. I had try to run the hippocampa-subfields segmentation analysis, however, I keep running into the following error: recon-all -s bob -hippocampal-subfields-T1
    Subject Stamp: freesurfer-Linux-centos6_x86_64-dev-20170103-696bbc1
    Current Stamp: freesurfer-Linux-centos6_x86_64-dev-20170103-696bbc1
    INFO: SUBJECTS_DIR is /usr/local/freesurfer/subjects
    Actual FREESURFER_HOME /usr/local/freesurfer
    -rw-rw-r– 1 michel 1590 1249629 Jan 24 13:40
    /usr/local/freesurfer/subjects/bob/scripts/recon-all.log
    Linux – 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64
    GNU/Linux
    ‘/usr/local/freesurfer/bin/recon-all’ ->
    ‘/usr/local/freesurfer/subjects/bob/scripts/recon-all.local-copy’
    #——————————————–
    #@# Hippocampal Subfields processing (T1 only) left Tue Jan 24 13:43:46 STD 2017

    /usr/local/freesurfer/bin/segmentSF_T1.sh /usr/local/freesurfer/MCRv80
    /usr/local/freesurfer bob /usr/local/freesurfer/subjects left

    See log file:
    /usr/local/freesurfer/subjects/bob/scripts/hippocampal-subfields-T1.log
    ——————————————
    Setting up environment variables

    LD_LIBRARY_PATH is
    .:/usr/local/freesurfer/MCRv80/runtime/glnxa64:/usr/local/freesurfer/MCRv80/bin/glnxa64:/usr/local/freesurfer/MCRv80/sys/os/glnxa64:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64/client:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64:
    /usr/local/freesurfer/bin/segmentSubjectT1_autoEstimateAlveusML: error while
    loading shared libraries: libut.so: cannot enable executable stack as shared
    object requires: Invalid argument
    #——————————————–
    #@# Hippocampal Subfields processing (T1 only) right Tue Jan 24 13:43:46 STD
    2017

    /usr/local/freesurfer/bin/segmentSF_T1.sh /usr/local/freesurfer/MCRv80
    /usr/local/freesurfer bob /usr/local/freesurfer/subjects right

    See log file:
    /usr/local/freesurfer/subjects/bob/scripts/hippocampal-subfields-T1.log
    ——————————————
    Setting up environment variables

    LD_LIBRARY_PATH is
    .:/usr/local/freesurfer/MCRv80/runtime/glnxa64:/usr/local/freesurfer/MCRv80/bin/glnxa64:/usr/local/freesurfer/MCRv80/sys/os/glnxa64:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64/client:/usr/local/freesurfer/MCRv80/sys/java/jre/glnxa64/jre/lib/amd64:
    /usr/local/freesurfer/bin/segmentSubjectT1_autoEstimateAlveusML: error while
    loading shared libraries: libut.so: cannot enable executable stack as shared
    object requires: Invalid argument

  10. I followed the install instructions, the FreeSurfer environment is set properly (I get the correct message when I type in ‘bash’), and I’m able to run recon-all. However, when I try to run freeview I get the following error:

    freeview.bin: error while loading shared libraries: libGLU.so.1: cannot open shared object file: No such file or directory

    Any ideas why this might be, and how I can fix the problem?

  11. You can get the libGLU.so.1 library by installing the package libglu1-mesa

    sudo apt-get install libglu1-mesa

  12. Hi,
    I followed all the steps you mentioned and I intalled the Version 6. The bash at the terminal looks perfect.
    However, I am getting an error when computing the first step in the example (mrri_convert).
    Here is the error:
    mri_convert.bin: error while loading shared libraries: libgomp.so.1: cannot open shared object file: No such file or directory
    I also get an error when I used freeview
    bash: /usr/ocal/freesurfer/bin/freeview: /bin/tcsh: intérprete erróneo: No such file or directory
    I also get an error when I used freeview
    Thank you very much for your comments,
    Best,
    Mikel

  13. Hello Lizarazu, thank you for your comments. Things have changed a bit since I wrote the blog post. The version of Freesurfer 6.0 is now a stable release and some additional library files are needed to run freesurfer.

    Please install some of the libraries using the following:

    sudo apt-get install build-essential tcsh libgomp1 libxss1

    The errors you encountered are because these dependencies are not met when launching the programs. Hope this helps.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)