Last active
September 28, 2023 00:22
-
-
Save gbnegrini/8d70c9b887798dbcfcd1654dcea279f6 to your computer and use it in GitHub Desktop.
Script to install FreeSurfer for Windows with WSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################################################################## | |
########################## INSTALL FREESURFER FOR WSL UBUNTU ########################## | |
######################################################################################## | |
# Guilherme Bauer Negrini (2021) | |
# Base source: https://surfer.nmr.mgh.harvard.edu/fswiki/FS7_wsl_ubuntu | |
# Tested on: Ubuntu 18.04. | |
# REQUIREMENTS | |
# 1. License file. See: https://surfer.nmr.mgh.harvard.edu/registration.html | |
# 2. WSL2. See: https://docs.microsoft.com/en-us/windows/wsl/install-win10 | |
# 3. X-server (required for GUI). Some options below: | |
# - GWSL -> Super easy, available at Microsoft Store. See: https://opticos.github.io/gwsl/ | |
# - Xming -> Used in the offical documentation of Free Surfer. See: https://surfer.nmr.mgh.harvard.edu/fswiki/FSL_wsl_xming | |
######################################################################################## | |
# Help | |
Help() | |
{ | |
echo "########################################################################################" | |
echo "########################## INSTALL FREESURFER FOR WSL UBUNTU ##########################" | |
echo "########################################################################################" | |
# Display Help | |
echo "REQUIREMENTS" | |
echo "1. License file" | |
echo "2. X-server" | |
echo "3. WSL2" | |
echo "--------------------------------------------------------------" | |
echo "Syntax: ./install_freesurfer.sh <license_filepath> [-h]" | |
echo | |
echo "args:" | |
echo "license_filepath: Full system path to license.txt" | |
echo " default: license.txt in the same folder" | |
echo | |
echo "options:" | |
echo "-h Print this Help." | |
echo | |
} | |
# Get the options | |
while getopts ":h" option; do | |
case $option in | |
h) | |
Help | |
exit;; | |
\?) | |
echo "Error: Invalid option" | |
exit;; | |
esac | |
done | |
######################################################################################## | |
#################################### MAIN SCRIPT ####################################### | |
######################################################################################## | |
# Download and install Free Surfer | |
wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.1.1/freesurfer-linux-centos7_x86_64-7.1.1.tar.gz | |
sudo tar -C /usr/local -zxvpf freesurfer-linux-centos7_x86_64-7.1.1.tar.gz | |
# Setup X-graphics for GUI | |
echo "export XDG_RUNTIME_DIR=$HOME/.xdg" >> $HOME/.bashrc | |
grep nameserver /etc/resolv.conf > ip.txt | |
awk '{print "export DISPLAY="$2":0"}' ip.txt >> $HOME/.bashrc | |
rm ip.txt | |
echo "export FREESURFER_HOME=/usr/local/freesurfer" >> $HOME/.bashrc | |
echo "export SUBJECTS_DIR=$FREESURFER_HOME/subjects" >> $HOME/.bashrc | |
# Setup license file | |
if [ $# -eq 0 ] | |
then | |
license="$(pwd)/license.txt" | |
else | |
license=$1 | |
fi | |
echo "export FS_LICENSE=$license" >> $HOME/.bashrc | |
echo "source $FREESURFER_HOME/SetUpFreeSurfer.sh" >> $HOME/.bashrc | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment