When using FreeSurfer and FSL 6.0.6 or later, a certain issue may arise:
- Python3 becomes the Python3 provided by FSL.
- dcm2niix becomes the dcm2niix provided by FSL.
First, I will explain how to confirm if you are affected by this issue and then provide the solutions along with the reasons.
【Confirmation of Affected Status】
- Check the Python path:
command -v python3
If the result is something like /usr/local/fsl/bin/python3, it means you are affected.
command -v dcm2niix
If the result is something like /usr/local/fsl/bin/dcm2niix, it means you are affected.
- Modify the FreeSurferEnv.sh file located in the FreeSurfer directory around line 403.
Before modification: export FSL_BIN=$FSL_DIR/bin After modification: export FSL_BIN=$FSL_DIR/share/fsl/bin
After saving the changes, exit the terminal and restart it. Then, try the command “command -v python3” again.
This issue is caused by a change in the executable file path in FSL 6.0.6 or later. In versions prior to 6.0.6, the executable files were located in $FSLDIR/bin when using the FSL directory as $FSLDIR. However, starting from 6.0.6, they are now located in $FSLDIR/share/fsl/bin. The complication arises from the fact that $FSLDIR/bin is not removed; instead, it is used to store files related to Python, dcm2niix, and other FSL executable files.
FreeSurfer has not yet fully adapted to this change. FreeSurferEnv.sh, which contains information about FSL, including line 403:
export FSL_BIN=$FSL_DIR/bin # Line 403 PATH=$FSL_BIN:$PATH # Line 422
The variable FSL_DIR used here is defined by FreeSurfer. It defines the bin directory under the installation directory of FSL as FSL_BIN and adds it to the beginning of the PATH variable.
Therefore, when you want to use Python without using FSL specifically and type “python” in the terminal, it will call the Python within FSL, which is the first one in the PATH.
As a solution, you need to modify FSL_BIN to the correct value.
It is essential to confirm the installation paths correctly when installing packages with Python; otherwise, they may be installed in unexpected locations. Please make sure to check and confirm them.