Using FSL from MATLAB

On macOS, the fslinstaller script will usually set this up for you so you should not need to do this. However, if the installer cannot configure MATLAB for some reason you may need to do this by hand.

FSL ships with several MATLAB scripts for loading NIFTI files. These libraries are dependent on FSL environment variables which may not be set when you start up MATLAB from your desktop environment. You can configure MATLAB to be FSL-aware by adding the following to your ~/Documents/MATLAB/startup.m file (create it if it doesn't already exist). Change the path in the first line if you have installed FSL to a different location:

% FSL Setup
setenv( 'FSLDIR', '/usr/local/fsl' );
setenv('FSLOUTPUTTYPE', 'NIFTI_GZ');
fsldir = getenv('FSLDIR');
fsldirmpath = sprintf('%s/etc/matlab',fsldir);
path(path, fsldirmpath);
clear fsldir fsldirmpath;
 

FslInstallation/FslMatlabConfiguration (last edited 17:17:28 22-11-2022 by PaulMcCarthy)