Setup (Windows)

OS

Check that WSL2 is running by typing this command in PowerShell:

  wsl -l -v 
# You should see something like this
  NAME                   STATE           VERSION
  Ubuntu-22.04           Running         2
  
# If you have WSL1, you can update to WSL2 by typing 
  wsl --set-default-version 2 wsl --set-version Ubuntu-22.04 2

Otherwise, you can install Ubuntu by pasting the following commands:

1. Enable WSL by opening PowerShell as administrator
    wsl --install -d Ubuntu-22.04
2. Restart your computer
3. Start the Ubuntu app to open a Ubuntu shell
4. Set up a username and password

You’ll also need to GUI for WSL. I recommend you install VcXsrv on your system, which is a free X-sever on Windows. After downloading and installing VcXsrv with default options, run Xlaunch (which gets installed automatically) and perform the following configuration:

  1. Display setting: select multiple windows option

  2. Client startup: check the Start no client option

  3. Extra setting: make sure “Disable access control” is enabled and “native opengl” is disabled

  4. Add this to your .bashrc file:

     echo "export DISPLAY=$(grep nameserver /etc/resolv.conf  | awk '{print $2; exit}'):0" >> ~/.bashrc
     echo "export LIBGL_ALWAYS_INDIRECT=0" >> ~/.bashrc
     # For Windows 11 users, add this as well
      echo "export LIBGL_ALWAYS_SOFTWARE=1" >> ~/.bashrc
  5. Try running glxgears. A window with three spinning gears should open.

    Troubleshooting:

    • Make sure you are not using a VPN.
    • Go to Control panel > System and security > Windows defender firewall > Advanced settings > Inbound rules and make sure that the VcXsrv rules are not set to block - if they are you will need to edit the VcXsrv rule and change it from block to allow.

Software installation

The pipeline revolves around MRtrix3 which works hand in hand with Freesurfer, FSL, and ANTs

MRtrix3

Download MRtrix3 by copy pasting this command in a bash terminal:

# Clone the MRtrix3 repo
git clone https://github.com/MRtrix3/mrtrix3.git
# Configure the install
cd mrtrix3
./configure
# Build the binaries
./build
# Add it to your path
./set_path

If you get an error, you can try with conda:

# If conda has been installed in /root, you may need to enter:
sudo chown -R $USER:$USER miniconda3

conda install -c mrtrix3 mrtrix3

Type an MRtrix3 command like mrconvert to check everything’s working correctly.

Add MRtrix3 to your PATH:

echo "export MRtrix3=/path/to/miniconda3/pkgs/mrtrix3-3.0.4-h2bc3f7f_0/share/mrtrix3" >> .bashrc
echo "export PATH=${MRtrix3}:$PATH" >> .bashrc

Freesurfer

  1. In your “HOME” directory (cd $HOME), download the Freesurfer installer package:

    wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb
  2. Make sure to install the Freesurfer distribution under the path /usr/local/freesurfer/7.4.1

    cd /usr/local
    sudo apt-get -y install ./freesurfer_ubuntu22-7.4.1_amd64.deb
  3. Add it to your PATH

    echo "export FREESURFER_HOME=/usr/local/freesurfer/7.4.1" >> $HOME/.bashrc
  4. Get the free license online, download it in your home directory and add this command in your .bashrc:

    export FS_LICENSE=$HOME/license.txt
  5. Set the Freesurfer env to be setup when you open the shell:

    echo "source $FREESURFER_HOME/SetUpFreeSurfer.sh" >> $HOME/.bashrc

Open a new Ubuntu linux terminal window and verify you see the following output showing the Freesurfer environment has been set. If everything went fine, you should see this output:

 - - - - - - - -freesurfer-linux-ubuntu22_x86_64-7.4.1-20230614-7eb8460- - - - - - - -
Setting up environment for FreeSurfer/FS-FAST (and FSL)
FREESURFER_HOME   /usr/local/freesurfer/7.4.1
FSFAST_HOME       /usr/local/freesurfer/7.4.1/fsfast
FSF_OUTPUT_FORMAT nii.gz
SUBJECTS_DIR      /usr/local/freesurfer/7.4.1/subjects
MNI_DIR           /usr/local/freesurfer/7.4.1/mni

FSL

  1. Download the FSL installer script online. When selecting the OS to install on the download page, make sure to select Ubuntu and not Windows.

  2. Run the installer script by replacing <UserName> with your windows user name. Make sure to install it under the path /usr/local/fsl/.

    python3 "fslinstaller.py"

ANTs

  1. Download the ANTs installer script

  2. In the terminal, enter:

    bash installANTs.sh
  3. Add it to your PATH

    echo "ANTSPATH=$HOME/install/bin/" >> $HOME/.bashrc
    echo "export PATH=${ANTSPATH}:$PATH" >> $HOME/.bashrc