**The following is for users with BASH as their shell**
In order to run Freesurfer you must set several environment variables and then source the SetUpFreesurfer.sh script. While it may be tempting to set your .bashrc so that this all happens automatically, there is substantial risk in doing so; if any of the resources you automatically call in your .bashrc happen to be offline, your shell will hang and you will not be able to log in or do anything anywhere.
Instead we recommend streamlining the process by using aliases.
1) What are aliases?
Aliases are essentially shortcuts that represent longer commands. By default your .bashrc already includes some aliases. You can see these by running ‘alias’:
The line alias ll=’ls -l –color=auto’ means that running the command ll actually runs the command ls -l –color=auto. You can verify this by observing that output from both commands looks identical.
2) Which aliases should I use to set up Freesurfer?
At a minimum you will need to set the variables FREESURFER_HOME and SUBJECTS_DIR.
Your alias should set FREESURFER_HOME to use whichever version of Freesurfer you need. In the screenshot below I have set it to use the Martinos Center installation of 7.0.0.
Your alias should set SUBJECTS_DIR to the path where your subjects’ data resides. In the screenshot below I have set a couple so I can easily switch from analyzing one study to another.
You can also set an alias for sourcing SetUpFreesurfer.sh
Below I have chosen to name my aliases ‘setfsvers’, ‘setknee’, etc. because it makes sense to me. You should choose your own aliases so that they are obvious to you.
3) And where specifically should I put them?
We recommend creating a separate .bash_aliases file to store your aliases. You can do this by running vi ~/.bash_aliases
You then need to edit your .bashrc to source your new .bash_aliases file. You can do this by running vi ~/.bashrc and adding the line source ~/.bash_aliases under the Interactive Settings.
Ultimately you should end up with .bashrc and .bash_aliases like:
4) And now what?
And now when you open a new terminal you are 3 short commands away from running Freesurfer! You can check that your aliases to set environment variables worked by using echo. You will know you sourced SetUpFreeSurfer.sh correctly when you see output like below.
5) What if I need more Freesurfer help?
Please visit https://surfer.nmr.mgh.harvard.edu/fswiki
Last Updated on May 18, 2020 by admin