Differences between revisions 3 and 28 (spanning 25 versions)
Revision 3 as of 2021-05-28 00:33:46
Size: 11984
Editor: buildqa
Comment:
Revision 28 as of 2023-09-05 03:07:34
Size: 8269
Editor: buildqa
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
=== Freesurfer install on Ubuntu 18 running in WSL === === Freesurfer on Ubuntu Linux in WSL ===
Line 3: Line 3:
The terminal session below shows how to download, install and setup the freesurfer and X-windows environment using a terminal window launched from Ubuntu 18 running in WSL under Windows 10. The free version of Ubuntu 18 was selected from the Windows store. Please read the latest MS documentation about how to setup WSL (version2 as of this writing) on your Windows machine, [[https://docs.microsoft.com/en-us/windows/wsl/install-win10|MS WSL Dcoumentation]]. Once you are able to bring up a terminal window in WSL's installed version of Ubuntu linux you can proceed to setting up the Freesurfer environment with the commands listed below. As of this writing, WSL should install Ubuntu 22 Linux and so the setup of the Freesurfer Ubuntu 22 package is described below.
Line 5: Line 5:
After Ubuntu 18 was installed via the MS WSl instructions, [[https://docs.microsoft.com/en-us/windows/wsl/install-win10|MS Dcoumentation for WSL version 2 setup and install]] then subsequently the repos were updated on Ubuntu 18, the freesurfer installer was downloaded/installed and the shell environment was setup to run X graphics and freesurfer. The commands below show how to download, install and setup the freesurfer distribution using its installer package. We do not support manually installing packages in the WSL Ubuntu Linux image apart from using the provided Freesurfer installer. Once Freesurfer is installed, you can proceed to setting up a 3rd party X-windows server on the host Windows machine. Please note that if you do not need to view any brain images, e.g., through Freeview, then there is no need to setup the X-Windows server.
Line 7: Line 7:
The freesurfer. *.deb package should also work on Ubuntu 20, but as of this writing it has not been tested on newer versions of Ubuntu linux. We do not advise manually trying to install packages in order to get freesurfer to run. Please allow the installer to try and determine what packages are needed on the system and install them.

<<BR>>developer@DESKTOP-LD48TB7:~$
The commands listed below can be cut and pasted into the Linux terminal window. Some commands set environment variables while others should display the expected output in order to proceed to the next step. However, you may not be able to debug where something went wrong if you are completely unfamiliar with the Linux "bash" shell syntax and grammar. If you are having difficulty understanding the commands listed below, then please consider reviewing one of the many Linux command line tutorials found online, e.g.,
<<BR>>
[[https://maker.pro/linux/tutorial/basic-linux-commands-for-beginners|Linux Commands for Beginners]]
<<BR>>
[[https://www.youtube.com/watch?v=cBokz0LTizk|Linux command line tutorial video]]
Line 12: Line 14:
'''''... download the appropriate Freesurfer *.deb installer package. This is the dev stream
installer package. For an actual release like 7.2.0, you would look for the package under the URL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.2.0 ...'''''
'''Launch the WSL application in Windows, wait for Ubuntu linux to boot, and then open a new terminal window in the Ubuntu Linux desktop GUI. You should see a prompt, e.g., dollar sign in, the terminal window where you can start typing in the commands below (cut and pasting should work).'''
<<BR>>
Line 15: Line 17:
<<BR>>developer@DESKTOP-LD48TB7:~$
'''wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/dev/freesurfer_7-dev_amd64.deb'''
<<BR>>--2021-05-20 04:56:12-- https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/dev/freesurfer_7-dev_amd64.deb
<<BR>>Resolving surfer.nmr.mgh.harvard.edu (surfer.nmr.mgh.harvard.edu)... 132.183.240.105
<<BR>>Connecting to surfer.nmr.mgh.harvard.edu (surfer.nmr.mgh.harvard.edu)|132.183.240.105|:443... connected.
<<BR>>HTTP request sent, awaiting response... 200 OK
<<BR>>Length: 3528163516 (3.3G) [application/vnd.debian.binary-package]
<<BR>>Saving to: ‘freesurfer_7-dev_amd64.deb’
... go to your "HOME" directory in Linux ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''cd'''
<<BR>><<BR>>
... download the freesurfer installer package ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb'''
Line 24: Line 25:
<<BR>>freesurfer_7-dev_amd64.deb 100%[==================================================================================>] 3.29G 31.3MB/s in 1m 50s <download output not shown>
<<BR>><<BR>>
... check the installer file exists ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''ls freesurfer_ubuntu22-7.4.1_amd64.deb'''
Line 26: Line 31:
<<BR>>2021-05-20 04:58:02 (30.7 MB/s) - ‘freesurfer_7-dev_amd64.deb’ saved [3528163516/3528163516] freesurfer_ubuntu22-7.4.1_amd64.deb
<<BR>><<BR>>
... update the package information in Ubuntu linux ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''sudo apt-get update -y'''
Line 28: Line 37:
<<BR>>developer@DESKTOP-LD48TB7:~$
'''ls'''
<<BR>>freesurfer_7-dev_amd64.deb

'''''... update the repo information on the machine to index the latest packages ...'''''

<<BR>>developer@DESKTOP-LD48TB7:~$
'''sudo apt-get update'''
<<BR>>[sudo] password for developer:
<<BR>>Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
<<BR>>Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
<<BR>>Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
<<BR>>Get:4 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1726 kB]
<<BR>>Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
<<BR>>Get:6 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [322 kB]
<<BR>>Get:7 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [323 kB]
<<BR>>Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [43.2 kB]
<<BR>>Get:9 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1126 kB]
<<BR>>Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [254 kB]
<<BR>>Get:11 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [19.2 kB]
<<BR>>Get:12 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [4412 B]
<<BR>>Get:13 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
<<BR>>Get:14 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
<<BR>>Get:15 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
<<BR>>Get:16 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
<<BR>>Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2070 kB]
<<BR>>Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [413 kB]
<<BR>>Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [344 kB]
<<BR>>Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [46.8 kB]
<<BR>>Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1735 kB]
<<BR>>Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [369 kB]
<<BR>>Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [25.0 kB]
<<BR>>Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [6464 B]
<<BR>>Get:25 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [10.0 kB]
<<BR>>Get:26 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [4764 B]
<<BR>>Get:27 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [10.3 kB]
<<BR>>Get:28 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [4588 B]
<<BR>>Fetched 22.9 MB in 27s (857 kB/s)
<<BR>>Reading package lists... Done

'''''... run the apt get/install command to automatically install the freesurfer distribution under
/usr/local/freesurfer/<release>. Answer "Y" so any package dependenices can be installed.
The packages installed on your system may vary depending upon what is already installed on
your system ...'''''

<<BR>>developer@DESKTOP-LD48TB7:~$
'''sudo apt-get install ./freesurfer_7-dev_amd64.deb'''
<<BR>>Reading package lists... Done
<<BR>>Building dependency tree
<<BR>>Reading state information... Done
<<BR>>Note, selecting 'freesurfer' instead of './freesurfer_7-dev_amd64.deb'
<<BR>>The following additional packages will be installed:
<<BR>> csh libglu1-mesa libgomp1 libjpeg62 libxss1 make tcsh
<<BR>>Suggested packages:
<<BR>> make-doc
<<BR>>The following NEW packages will be installed:
<<BR>> csh freesurfer libglu1-mesa libgomp1 libjpeg62 libxss1 make tcsh
<<BR>>0 upgraded, 8 newly installed, 0 to remove and 148 not upgraded.
<<BR>>Need to get 1156 kB/3529 MB of archives.
<<BR>>After this operation, 3034 kB of additional disk space will be used.

'''Do you want to continue? [Y/n] Y'''

<<BR>>Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libxss1 amd64 1:1.2.2-1 [8582 B]
<<BR>>Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 csh amd64 20110502-3ubuntu0.18.04.1 [243 kB]
<<BR>>Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 make amd64 4.1-9.1ubuntu1 [154 kB]
<<BR>>Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 tcsh amd64 6.20.00-7 [428 kB]
<<BR>>Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 libglu1-mesa amd64 9.0.0-2.1build1 [168 kB]
<<BR>>Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgomp1 amd64 8.4.0-1ubuntu1~18.04 [76.5 kB]
<<BR>>Get:7 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libjpeg62 amd64 1:6b2-3 [78.3 kB]
<<BR>>Get:8 /home/developer/freesurfer_7-dev_amd64.deb freesurfer amd64 7-dev [3528 MB]
<<BR>>Fetched 1156 kB in 40s (28.8 kB/s)
<<BR>>Selecting previously unselected package libxss1:amd64.
<<BR>>(Reading database ... 29293 files and directories currently installed.)
<<BR>>Preparing to unpack .../0-libxss1_1%3a1.2.2-1_amd64.deb ...
<<BR>>Unpacking libxss1:amd64 (1:1.2.2-1) ...
<<BR>>Selecting previously unselected package csh.
<<BR>>Preparing to unpack .../1-csh_20110502-3ubuntu0.18.04.1_amd64.deb ...
<<BR>>Unpacking csh (20110502-3ubuntu0.18.04.1) ...
<<BR>>Selecting previously unselected package make.
<<BR>>Preparing to unpack .../2-make_4.1-9.1ubuntu1_amd64.deb ...
<<BR>>Unpacking make (4.1-9.1ubuntu1) ...
<<BR>>Selecting previously unselected package tcsh.
<<BR>>Preparing to unpack .../3-tcsh_6.20.00-7_amd64.deb ...
<<BR>>Unpacking tcsh (6.20.00-7) ...
<<BR>>Selecting previously unselected package libglu1-mesa:amd64.
<<BR>>Preparing to unpack .../4-libglu1-mesa_9.0.0-2.1build1_amd64.deb ...
<<BR>>Unpacking libglu1-mesa:amd64 (9.0.0-2.1build1) ...
<<BR>>Selecting previously unselected package libgomp1:amd64.
<<BR>>Preparing to unpack .../5-libgomp1_8.4.0-1ubuntu1~18.04_amd64.deb ...
<<BR>>Unpacking libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ...
<<BR>>Selecting previously unselected package libjpeg62:amd64.
<<BR>>Preparing to unpack .../6-libjpeg62_1%3a6b2-3_amd64.deb ...
<<BR>>Unpacking libjpeg62:amd64 (1:6b2-3) ...
<<BR>>Selecting previously unselected package freesurfer.
<<BR>>Preparing to unpack .../7-freesurfer_7-dev_amd64.deb ...
<<BR>>Unpacking freesurfer (7-dev) ...
<<BR>>Setting up libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ...
<<BR>>Setting up make (4.1-9.1ubuntu1) ...
<<BR>>Setting up libjpeg62:amd64 (1:6b2-3) ...
<<BR>>Setting up libxss1:amd64 (1:1.2.2-1) ...
<<BR>>Setting up tcsh (6.20.00-7) ...
<<BR>>update-alternatives: using /bin/tcsh to provide /bin/csh (csh) in auto mode
<<BR>>Setting up libglu1-mesa:amd64 (9.0.0-2.1build1) ...
<<BR>>Setting up csh (20110502-3ubuntu0.18.04.1) ...
<<BR>>update-alternatives: using /bin/bsd-csh to provide /bin/csh (csh) in auto mode
<<BR>>Setting up freesurfer (7-dev) ...
<<BR>>Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
<<BR>>Processing triggers for libc-bin (2.27-3ubuntu1.2) ...

'''''... the development stream package is installed under /usr/local/freesurfer/7-dev. The 7.2.0 release
install would be under /usr/local/freesurfer/7.2.0 There is no conflict with having
multiple versions of freesufer installed under parallel subdirectories - you only need to change the setting
of the FREESURFER_HOME environment variable ...'''''

<<BR>>developer@DESKTOP-LD48TB7:~$
'''ls /usr/local/freesurfer/7-dev/'''
<<BR>>ASegStatsLUT.txt FreeSurferEnv.sh Simple_surface_labels2009.txt build-stamp.txt fsafd mni sources.csh tktools
<<BR>>DefectLUT.txt SegmentNoLUT.txt WMParcStatsLUT.txt diffusion fsfast models sources.sh trctrain
<<BR>>FreeSurferColorLUT.txt SetUpFreeSurfer.csh average docs lib python subjects
<<BR>>FreeSurferEnv.csh SetUpFreeSurfer.sh bin etc matlab sessions tkmeditParcColorsCMA

'''''... setup your shell with the necessary environment variables for X-windows graphics and freesurfer. You can add these directly to your shell init file, e.g., the .bashrc file for bash shell. You will also need a license file for freesurfer which can be pointed to by an environment variable ...'''''

<<BR>>developer@DESKTOP-LD48TB7:~$
'''echo "export XDG_RUNTIME_DIR=$HOME/.xdg" >> $HOME/.bashrc'''
<<BR>>developer@DESKTOP-LD48TB7:~$
'''echo "export DISPLAY=:0" >> $HOME/.bashrc'''
<<BR>>developer@DESKTOP-LD48TB7:~$
'''echo "export FREESURFER_HOME=/usr/local/freesurfer/7-dev" >> $HOME/.bashrc'''

'''''... Add your license file and set FS_LICENSE to point to it ...'''''

<<BR>>developer@DESKTOP-LD48TB7:~$
'''echo "export FS_LICENSE=$HOME/license.txt" >> $HOME/.bashrc'''
<<BR>>developer@DESKTOP-LD48TB7:~$
'''echo "source /usr/local/freesurfer/7-dev/SetUpFreeSurfer.sh" >> $HOME/.bashrc'''

'''''... logout and log back in and verify you see the following ...'''''

<<BR>>freesurfer-linux-ubuntu18_x86_64-dev-20210518-60f02e6
[sudo] password for developer:
<<BR>>
<output from package updates not shown>
<<BR>><<BR>>
... install the freesurfer distribution under the path /usr/local/freesurfer/7.4.1. Anwer "Y" to any prompts ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''sudo apt-get -y install ./freesurfer_ubuntu22-7.4.1_amd64.deb'''
<<BR>>
[sudo] password for developer:
<<BR>>
The following NEW packages will be installed:
<<BR>>
<output from package updates and install of freesurfer not shown - wait for the install to finish and the return to the shell prompt>
<<BR>><<BR>>
... setup the FREESURFER_HOME environment variable. The 2nd command adds the environment variable settings into your bash shell init file, i.e., .bashrc ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''export FREESURFER_HOME=/usr/local/freesurfer/7.4.1'''
<<BR>>
developer@DESKTOP-LD48TB7:~$ '''echo "export FREESURFER_HOME=/usr/local/freesurfer/7.4.1" >> $HOME/.bashrc'''
<<BR>><<BR>>
... check the Freesurfer release was installed under /usr/local/freesurfer/7.4.1 ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''ls $FREESURFER_HOME'''
<<BR>>
{{attachment:ls_output.png}}
<<BR>><<BR>>
'''If you have an existing licence.txt file from a previous freesurfer registration, you can copy it in to your home directory in Linux. Otherwise, you need to register an email address and download a license file you can receive at that email destination in order to run freesurfer commands. Fill out the form [[https://surfer.nmr.mgh.harvard.edu/registration.html|freesurfer registration]] and wait for the license.txt file to be emailed to you. '''
<<BR>><<BR>>
... go to your home directory ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''cd'''
<<BR>><<BR>>
... then download and/or copy in your license.txt file and verify you can see it with the ls command ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''ls license.txt'''
<<BR>>
license.txt
<<BR>><<BR>>
... set the environment variable FS_LICENSE to point to license.txt ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''echo "export FS_LICENSE=$HOME/license.txt" >> $HOME/.bashrc'''
<<BR>><<BR>>
... set these environment variables for your display ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''echo "export XDG_RUNTIME_DIR=$HOME/.xdg" >> $HOME/.bashrc'''
<<BR>>
developer@DESKTOP-LD48TB7:~$ '''echo "export DISPLAY=:0" >> $HOME/.bashrc'''
<<BR>><<BR>>
... set the Freesurfer environment to be setup when you open a new Linux terminal window ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''echo "source $FREESURFER_HOME/SetUpFreeSurfer.sh" >> $HOME/.bashrc'''
<<BR>>
<<BR>>
'''Open a new Ubuntu linux terminal window and verify you see the following output showing the Freesurfer environment has been set. Or you could just logout and log back in to Ubuntu Linux. If you do not see the output below in the new terminal window, then something went wrong with your environment variable settings above and/or the install of Freesurfer. You should stop and ask for help if the output is missing.'''
<<BR>>
<<BR>>- - - - - - - -freesurfer-linux-ubuntu22_x86_64-7.4.1-20230614-7eb8460- - - - - - - -
Line 170: Line 94:
<<BR>>FREESURFER_HOME /usr/local/freesurfer/7-dev/
<<BR>>FSFAST_HOME /usr/local/freesurfer/7-dev//fsfast
<<BR>>FREESURFER_HOME /usr/local/freesurfer/7.4.1/
<<BR>>FSFAST_HOME /usr/local/freesurfer/7.4.1//fsfast
Line 173: Line 97:
<<BR>>SUBJECTS_DIR /usr/local/freesurfer/7-dev//subjects <<BR>>SUBJECTS_DIR /usr/local/freesurfer/7.4.1//subjects
Line 175: Line 99:
<<BR>>MNI_DIR /usr/local/freesurfer/7-dev//mni

'''''... you should now be able to run freeview and other commands from the
distribution pointed to by $FREESURFER_HOME/bin ...'''''
<<BR>>MNI_DIR /usr/local/freesurfer/7.4.1//mni
<<BR>><<BR>>
'''Setup an X-server running on the Windows host if you plan to run image viewing programs such as Freeview under Linux. Some notes are provided below for setting up Xming. Alternately you could try other server applications like Moba Xterm.'''
<<BR>><<BR>>
[[https://surfer.nmr.mgh.harvard.edu/fswiki/FSL_wsl_xming|Xming and setup notes]]
<<BR>>
[[https://mobaxterm.mobatek.net|MobaXterm]]
<<BR>>
[[https://sourceforge.net/projects/vcxsrv|VcxSrv]]
<<BR>><<BR>>
... Once the X-server is running on the Windows host, you should be able to start running freeview commands ...
<<BR>>
... if you see the following error when trying to run freeview ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''freeview'''
<<BR>>
QXcbConnection: Could not connect to display :0
<<BR>>
Could not connect to any X display.
<<BR>><<BR>>
... then try modifying your DISPLAY variable to contain your IP address before the :0 ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''grep nameserver /etc/resolv.conf'''
<<BR>>
nameserver 154.132.1.1
<<BR>>
developer@DESKTOP-LD48TB7:~$ '''export DISPLAY="154.132.1.1:0"'''
<<BR>><<BR>>
... if you have installed and setup Xming as your X-server on the windows host, then edit the Xming X0.hosts file to contain your machines IP address below the entry for localhost ...
<<BR>><<BR>>
... before edit ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''cat /mnt/c/"Program Files (x86)"/Xming/X0.hosts'''
<<BR>>localhost
<<BR>><<BR>>
.. after edit ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''cat /mnt/c/"Program Files (x86)"/Xming/X0.hosts'''
<<BR>>localhost
<<BR>>154.132.1.1
<<BR>><<BR>>
... check DISPLAY matches IP address...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''echo $DISPLAY'''
<<BR>>154.132.1.1:0
<<BR>><<BR>>
... try running freeview again ...
<<BR>><<BR>>
developer@DESKTOP-LD48TB7:~$ '''freeview'''

Freesurfer on Ubuntu Linux in WSL

Please read the latest MS documentation about how to setup WSL (version2 as of this writing) on your Windows machine, MS WSL Dcoumentation. Once you are able to bring up a terminal window in WSL's installed version of Ubuntu linux you can proceed to setting up the Freesurfer environment with the commands listed below. As of this writing, WSL should install Ubuntu 22 Linux and so the setup of the Freesurfer Ubuntu 22 package is described below.

The commands below show how to download, install and setup the freesurfer distribution using its installer package. We do not support manually installing packages in the WSL Ubuntu Linux image apart from using the provided Freesurfer installer. Once Freesurfer is installed, you can proceed to setting up a 3rd party X-windows server on the host Windows machine. Please note that if you do not need to view any brain images, e.g., through Freeview, then there is no need to setup the X-Windows server.

The commands listed below can be cut and pasted into the Linux terminal window. Some commands set environment variables while others should display the expected output in order to proceed to the next step. However, you may not be able to debug where something went wrong if you are completely unfamiliar with the Linux "bash" shell syntax and grammar. If you are having difficulty understanding the commands listed below, then please consider reviewing one of the many Linux command line tutorials found online, e.g.,
Linux Commands for Beginners
Linux command line tutorial video

Launch the WSL application in Windows, wait for Ubuntu linux to boot, and then open a new terminal window in the Ubuntu Linux desktop GUI. You should see a prompt, e.g., dollar sign in, the terminal window where you can start typing in the commands below (cut and pasting should work).

... go to your "HOME" directory in Linux ...

developer@DESKTOP-LD48TB7:~$ cd

... download the freesurfer installer package ...

developer@DESKTOP-LD48TB7:~$ wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb
<download output not shown>

... check the installer file exists ...

developer@DESKTOP-LD48TB7:~$ ls freesurfer_ubuntu22-7.4.1_amd64.deb
freesurfer_ubuntu22-7.4.1_amd64.deb

... update the package information in Ubuntu linux ...

developer@DESKTOP-LD48TB7:~$ sudo apt-get update -y
[sudo] password for developer:
<output from package updates not shown>

... install the freesurfer distribution under the path /usr/local/freesurfer/7.4.1. Anwer "Y" to any prompts ...

developer@DESKTOP-LD48TB7:~$ sudo apt-get -y install ./freesurfer_ubuntu22-7.4.1_amd64.deb
[sudo] password for developer:
The following NEW packages will be installed:
<output from package updates and install of freesurfer not shown - wait for the install to finish and the return to the shell prompt>

... setup the FREESURFER_HOME environment variable. The 2nd command adds the environment variable settings into your bash shell init file, i.e., .bashrc ...

developer@DESKTOP-LD48TB7:~$ export FREESURFER_HOME=/usr/local/freesurfer/7.4.1
developer@DESKTOP-LD48TB7:~$ echo "export FREESURFER_HOME=/usr/local/freesurfer/7.4.1" >> $HOME/.bashrc

... check the Freesurfer release was installed under /usr/local/freesurfer/7.4.1 ...

developer@DESKTOP-LD48TB7:~$ ls $FREESURFER_HOME
ls_output.png

If you have an existing licence.txt file from a previous freesurfer registration, you can copy it in to your home directory in Linux. Otherwise, you need to register an email address and download a license file you can receive at that email destination in order to run freesurfer commands. Fill out the form freesurfer registration and wait for the license.txt file to be emailed to you.

... go to your home directory ...

developer@DESKTOP-LD48TB7:~$ cd

... then download and/or copy in your license.txt file and verify you can see it with the ls command ...

developer@DESKTOP-LD48TB7:~$ ls license.txt
license.txt

... set the environment variable FS_LICENSE to point to license.txt ...

developer@DESKTOP-LD48TB7:~$ echo "export FS_LICENSE=$HOME/license.txt" >> $HOME/.bashrc

... set these environment variables for your display ...

developer@DESKTOP-LD48TB7:~$ echo "export XDG_RUNTIME_DIR=$HOME/.xdg" >> $HOME/.bashrc
developer@DESKTOP-LD48TB7:~$ echo "export DISPLAY=:0" >> $HOME/.bashrc

... set the Freesurfer environment to be setup when you open a new Linux terminal window ...

developer@DESKTOP-LD48TB7:~$ 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. Or you could just logout and log back in to Ubuntu Linux. If you do not see the output below in the new terminal window, then something went wrong with your environment variable settings above and/or the install of Freesurfer. You should stop and ask for help if the output is missing.

- - - - - - - -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
INFO: /home/developer/matlab/startup.m does not exist ... creating
MNI_DIR /usr/local/freesurfer/7.4.1//mni

Setup an X-server running on the Windows host if you plan to run image viewing programs such as Freeview under Linux. Some notes are provided below for setting up Xming. Alternately you could try other server applications like Moba Xterm.

Xming and setup notes
MobaXterm
VcxSrv

... Once the X-server is running on the Windows host, you should be able to start running freeview commands ...
... if you see the following error when trying to run freeview ...

developer@DESKTOP-LD48TB7:~$ freeview
QXcbConnection: Could not connect to display :0
Could not connect to any X display.

... then try modifying your DISPLAY variable to contain your IP address before the :0 ...

developer@DESKTOP-LD48TB7:~$ grep nameserver /etc/resolv.conf
nameserver 154.132.1.1
developer@DESKTOP-LD48TB7:~$ export DISPLAY="154.132.1.1:0"

... if you have installed and setup Xming as your X-server on the windows host, then edit the Xming X0.hosts file to contain your machines IP address below the entry for localhost ...

... before edit ...

developer@DESKTOP-LD48TB7:~$ cat /mnt/c/"Program Files (x86)"/Xming/X0.hosts
localhost

.. after edit ...

developer@DESKTOP-LD48TB7:~$ cat /mnt/c/"Program Files (x86)"/Xming/X0.hosts
localhost
154.132.1.1

... check DISPLAY matches IP address...

developer@DESKTOP-LD48TB7:~$ echo $DISPLAY
154.132.1.1:0

... try running freeview again ...

developer@DESKTOP-LD48TB7:~$ freeview

FS7_wsl_ubuntu (last edited 2023-09-05 03:07:34 by buildqa)