Freesurfer license errors with Singularity

Hi Stars!

I have run into a problem running a pipeline that I have been using for a few months now, and it seems to be related to the freesurfer license.

I’m running standard pipeline on a cluster with the Singularity image 1.0.0-rc11, and the command;

singularity run /home/harry/poldracklab_fmriprep_latest-2017-11-25-*.img ~/extras/BIDS/ ~/extras/out/ participant --nthreads 50 --n_cpus 2 --no-freesurfer -w ~/extras/work/ --fs-license-file ~/license.txt

And received the following error;

Node: fmriprep_wf.single_subject_01_wf.anat_preproc_wf.anat_template_wf.t1_merge
Working directory: /home/harry/extras/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_merge

Node inputs:

args = <undefined>
auto_detect_sensitivity = True
average_metric = <undefined>
environ = {'SUBJECTS_DIR': '/opt/freesurfer/subjects', 'OMP_NUM_THREADS': '1'}
fixed_timepoint = True
ignore_exception = False
in_files = ['/home/harry/extras/BIDS/sub-01/anat/sub-01_acq-1_T1w.nii.gz', '/home/harry/extras/BIDS/sub-01/anat/sub-01_acq-2_T1w.nii.gz']
in_intensity_scales = <undefined>
initial_timepoint = 1
initial_transforms = <undefined>
intensity_scaling = True
no_iteration = True
num_threads = 1
out_file = sub-01_acq-1_T1w_template.nii.gz
outlier_sensitivity = <undefined>
scaled_intensity_outputs = <undefined>
subjects_dir = /opt/freesurfer/subjects
subsample_threshold = 200
terminal_output = <undefined>
transform_outputs = True

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/", line 51, in run_node
    result['result'] =
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/", line 407, in run
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/", line 517, in _run_interface
    self._result = self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/", line 650, in _run_command
    result =
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/freesurfer/", line 268, in run
    return super(FSCommandOpenMP, self).run(**inputs)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/freesurfer/", line 144, in run
    return super(FSCommand, self).run(**inputs)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/", line 1088, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/", line 1671, in _run_interface
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/", line 1617, in raise_exception
RuntimeError: Command:
mri_robust_template --satit --fixtp --mov /home/harry/extras/BIDS/sub-01/anat/sub-01_acq-1_T1w.nii.gz /home/harry/extras/BIDS/sub-01/anat/sub-01_acq-2_T1w.nii.gz --inittp 1 --iscale --noit --template sub-01_acq-1_T1w_template.nii.gz --subsample 200 --lta /home/harry/extras/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_merge/tp1.lta /home/harry/extras/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_merge/tp2.lta
Standard output:
$Id: mri_robust_template.cpp,v 1.54 2016/05/05 21:17:08 mreuter Exp $

--satit: Will estimate SAT iteratively!
--fixtp: Will map everything to init TP!
--mov: Using /home/harry/extras/BIDS/sub-01/anat/sub-01_acq-1_T1w.nii.gz as movable/source volume.
--mov: Using /home/harry/extras/BIDS/sub-01/anat/sub-01_acq-2_T1w.nii.gz as movable/source volume.
    Total: 2 input volumes
--inittp: Using TP 1 as target for initialization
--iscale: Enableing intensity scaling!
--noit: Will output only first template (no iterations)!
--template: Using sub-01_acq-1_T1w_template.nii.gz as template output volume.
--subsample: Will subsample if size is larger than 200 on all axes!
--lta: Will output LTA transforms
Setting iscale ...
reading source '/home/harry/extras/BIDS/sub-01/anat/sub-01_acq-1_T1w.nii.gz'...
Standard error:
ERROR: FreeSurfer license file /opt/freesurfer/license.txt not found.
  If you are outside the NMR-Martinos Center,
  go to to 
  get a valid license file (it's free).
  If you are inside the NMR-Martinos Center,
  make sure to source the standard environment.
  A path to an alternative license file can also be
  specified with the FS_LICENSE environmental variable.
Return code: 255

I ran the same code on a different dataset a month ago and it worked perfectly fine (actually with the call to --fs-licenese-file omitted). I’ve tried running the code without the call to --fs-licenese-file and the same errors occur. I’ve not updated the image, and logs from previous successful calls to this code are identical except for the paths (such as below).

FMRIPREP version: 1.0.0-rc11
FMRIPREP command: /usr/local/miniconda/bin/fmriprep /home/harry/training/BIDS/ /home/harry/training/out/ participant --nthreads 50 --n_cpus 2 --no-freesurfer -w /home/harry/training/work/
Date preprocessed: 2017-12-14 04:48:56 +0000

Any clues?


You’ll need to go to and obtain a license file - it’s free and helps Freesurfer team track usage and apply for grants.

It seems to me that @Bronson already has a valid FreeSurfer license file.

The problem with singularity is that one can’t mount (bind) individual files.

I’d suggest to set the FS_LICENSE environment variable before invoking singularity:

export FS_LICENSE=$HOME/license.txt

Alternatively, your license file might be outdated (we switched to FreeSurfer 6 a while ago).

Finally, I would recommend updating to the latest fMRIprep (1.0.5) since the license file forced some release candidates.


Thanks, setting the environmental variable solved the issue.


1 Like

I’m having the same issue and changing the environment variable doesn’t help for me.

Command I’m using is:

sudo singularity run --cleanenv -B /home/quintin_frerichs/data/ds001590-download/:/data/ -B /home/quintin_frerichs/data/qsiprep-output:/out/ qsiprep-0.12.2.sif /data /out participant --output-resolution 1.3, or sudo singularity run --cleanenv -B /home/quintin_frerichs/data/ds001590-download/:/data/ -B /home/quintin_frerichs/data/qsiprep-output:/out/ qsiprep-0.12.2.sif /data /out participant --output-resolution 1.3 --fs-license-file=/home/quintin_frerichs/license.txt

(Neither works). I also tried re-registering with Freesurfer in case I had the version wrong, didn’t help either.