Installing Freesurfer Using Enhanced Mode Ubuntu 18.04 for Hyper-V on Windows 10

Prerequisites

Before getting started, I first installed Ubuntu within Hyper-V on my Windows 10 computer following the instructions below:
https://www.hanselman.com/blog/UsingEnhancedModeUbuntu1804ForHyperVOnWindows10.aspx

Link to FreeSurfer installation page

While the link below is extremely well-written and helpful, I noticed a few steps during my installation process using Ubuntu for Hyper-V that required additional steps, not listed on the page. This is meant to help others using the same system that I am with the installation procedure – described in detail below. https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall

Installation Steps

1. Download Freesurfer

Download FreeSurfer for Linux from the download page while logged into your Ubuntu VM

File to download: freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

Link to download (you may need to be logged into your Gmail account in order to download the file): https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

2. Change Permissions

You will need to make sure you have permissions to write into /usr/local/ which is where you will unpack the FreeSurfer package.

$> sudo chmod -R 777 /usr/local/   

3. Unpack FreeSurfer Package

Unpack the package making sure you are in the directory where you saved the package. For me this was:

$> cd /home/shaas/Downloads
$> tar -C /usr/local -xzvf freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

4. Install additional necessary packages

$> sudo apt-get -y install bc binutils libgomp1 perl psmisc sudo tar tcsh unzip uuid-dev vim-common libjpeg62-dev 

5. Setup & Configuration

To begin using FreeSurfer, you need to open a terminal window and define and environment variable called FREESURFER_HOME which is set to the location FreeSurfer was installed, and then source the setup script. Sourcing FreeSurfer needs to be done every time you open a new terminal window. Or, you can add the two lines below to your default setup file (.bashrc or .cshrc) and FreeSurfer will be sourced automatically every time you open a new window.

## bash
$> export FREESURFER_HOME=/usr/local/freesurfer
$> source $FREESURFER_HOME/SetUpFreeSurfer.sh

If done correctly, you should see output similar to this:

Setting up environment for FreeSurfer/FS-FAST (and FSL)
FREESURFER_HOME /usr/local/freesurfer
FSFAST_HOME     /usr/local/freesurfer/fsfast
FSF_OUTPUT_FORMAT nii
SUBJECTS_DIR    /usr/local/freesurfer/subjects
MNI_DIR         /usr/local/freesurfer/mni

6. Get a license to use Freesurfer

A license key must be obtained to make the FreeSurfer tools operational. Obtaining a license is free and comes in the form of a license.txt file. Once you obtain the license.txt key file, copy it to your FreeSurfer installation directory. This is also the location defined by the FREESURFER_HOME environment variable.

Get license here: https://surfer.nmr.mgh.harvard.edu/registration.html

Once downloaded in Ubuntu, copy to folder where your FreeSurfer is:

$> cp /home/shaas/Downloads/license.txt /usr/local/freesurfer 

7. Additional items to install

$> sudo apt-get update
$> sudo apt-get upgrade
$> sudo apt-get install libtool autoconf build-essential pkg-config automake tcsh