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.
  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:

    wget 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

    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
    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.

  33 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
    Linux – 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64
    ‘/usr/local/freesurfer/bin/recon-all’ ->
    #@# 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:
    Setting up environment variables

    /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

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

    See log file:
    Setting up environment variables

    /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,

  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.

  14. Did you have to do anything to setup OpenGL / libGL? I get the following error and the brain in tksurfer renders as solid red…

    libGL error: No matching fbConfigs or visuals found
    libGL error: failed to load driver: swrast

    I poked around the internet and some people recommended setting LIBGL_ALWAYS_INDIRECT to 1. This removes the error but the brain still renders in solid red….I’m on a notebook with Intel Iris graphics…

    Incidentally freeview seems to work OK.

  15. To follow up on my comment…I finally figured out how to get this to work properly. I had installed VcXsrv, instead of Xming. Xming works fine. Weirdly, I also didn’t get the problem with VcXsrv if I used Xlaunch and selected one large window. I don’t understand this issue at all, but PSA: use Xming or one window if you want to use tksurfer.

  16. […] have followed the instructions from: http://nuclear-imaging.info/site_content/2016/09/12/installing-running-freesurfer-windows-10/ I have tested whether FreeSurfer worked properly from the site: […]

  17. I have installed and followed all the instructions. However, when I try to run mri_convert i get the following…

    niiWrite(): error opening file sample-001.nii.gz
    ERROR: failure writing sample-001.nii.gz

    Could you give some clarity to how to solve this issue? Is it a permission to read/write on the file directory?

  18. Hi, I installed freesurfer as indicated above, when I am checking the installation calling recon-all the first time I get:
    ERROR: OS is missing bc (binary calculator) utility

    Any ideas how to fix this?


  19. At Final Check (Step 11), I get the message “bash: /usr/local/freesurfer/SetUpFreeSurfer.sh: No such file or directory.”
    I was able to download freesurfer with “wget ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/dev/freesurfer-Linux-centos6_x86_64-dev.tar.gz.” And freesurfer is in ls.
    I entered “cd /usr/local/freesurfer” and got “rbash: cd: restricted.” It appears that many of my files are restricted. I created license.txt and Xming Server:0.0 appears under mouse. How do I access these restricted files?

  20. Hi Matt: Please check the folder permission for the freesurfer directory. It is likely that you extracted the tar.gz file using the sudo command, but didn’t change the permissions back to read/write/execute when you are not running it as a super user. So change the permissions of that folder with:

    sudo chmod -R 755 /usr/local/freesurfer

    That should most likely fix it.

  21. Martin:

    You can install the binary calculator with:

    sudo apt-get install bc

  22. Hello, I tried to open freeview but got a message: “freeview.bin: error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or directory”.
    What could be a problem?

  23. Try installing the libsm6 package and check if that launches freeview

    sudo apt-get install libsm6

  24. Yes, that works, needed to install one more package and it all fine now.
    Thanks for your help.

  25. Will BASH on Windows 10 run FSLeyes? FSL and FSLview work, but I cannot get FSLeyes to run.

  26. I’ve also got the libut.so error.
    Did anyone find a solution about it ?

  27. Hello, when I tried to open freeview this message appears: freeview.bin : cannot connect to X server localhost.
    What could be the problem?

  28. That X server is either not running, or you have missed out the step to add the DISPLAY line to your .bashrc file. Try doing that and it should work.

  29. I have FSLeyes running on my system. You may have to unintsall fsl-complete [sudo apt-get remove fsl-complete]. Then you can reinstall fsl-complete along with fsleyes [sudo apt-get install fsl-complete fsleyes]. Make sure you update your repositories before installing both these packages.

  30. Happy New Year!

    I meet the following libut.so erros when I run freesurfer on Ubuntu16.04 base windows 10 bash:
    segmentSubjectT1_autoEstimateAlveusML: error while loading shared libraries: libut.so: cannot enable executable stack as shared object requires: Invalid argument
    Could anyone help me?

  31. Hello, I followed all the steps and download is complete but during extraction process to local, it prompt a passord like “sudo password for xyz”(my user name). When I enter passowrd, it say “sorry try again” and after entering password three time, it says “3 inncorec attempts”. What could be problem and how to fix it, as I am confirmed, I am using correct user password.

  32. I have been trying for last two days to install freesurfer on my PC, every thing looks fine I reached this step:

    ——– freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0-2beb96c ——–
    Setting up environment for FreeSurfer/FS-FAST (and FSL)
    FREESURFER_HOME /usr/local/freesurfer
    FSFAST_HOME /usr/local/freesurfer/fsfast
    SUBJECTS_DIR /usr/local/freesurfer/subjects
    MNI_DIR /usr/local/freesurfer/mni

    Then when I started trying my installation using examples it did not work and gave me permission denied as

    zhbar@DESKTOP-V43QKHC:~$ cp $FREESURFER_HOME/subjects/sample-001.mgz .
    cp: cannot create regular file ‘./sample-001.mgz’: Permission denied

    Thank you for help,

  33. The Freesurfer folder, as well as the /usr/local directory in which it is installed, needs admin rights.
    To move files to the Freesurfer directory you will have to type “sudo” before the command. You will be asked to enter you admin password before this command is executed.

    sudo cp $FREESURFER_HOME/subjects/sample-001.mgz

    If you are the only user on that computer, you can change the folder permissions to freely read/write without the need to enter your admin password each time.
    In order to change the permissions type in:

    sudo chmod -R 755 /usr/local/freesurfer

 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>



This site uses Akismet to reduce spam. Learn how your comment data is processed.