FreeSurfer license file error in fMRIprep 1.0.0-rc10

fmriprep

#1

This error popped up for me in the newest version of fMRIprep (1.0.0-rc10). I never had this one happen in the previous versions.

  File "/usr/local/miniconda/bin/fmriprep", line 11, in <module>
    load_entry_point('fmriprep==1.0.0rc10', 'console_scripts', 'fmriprep')()
  File "/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/cli/run.py", line 206, in main
    raise RuntimeError('ERROR: when --no-freesurfer is not set, a valid '
RuntimeError: ERROR: when --no-freesurfer is not set, a valid license file is required for FreeSurfer to run.

Kristina


#2

This is a recent feature added to FreeSurfer to make it easier for tools like FMRIPREP which bundle FreeSurfer in to ask users to use their own license. (Up until now, we’ve been using one of our own license.)

FreeSurfer licenses are free, but they use registrations to keep rough statistics on the number of users, which they can use in grants and presentations as a demonstration of their contribution to the neuroimaging community. You can register here: https://surfer.nmr.mgh.harvard.edu/registration.html

Once you have a license, there are two ways to let FMRIPREP know about it:

  • Set the FS_LICENSE environment variable with the path of the file, in e.g., your .bashrc
  • Pass the --fs-license-file <PATH> option to FMRIPREP, where <PATH> is the location of your license file

Runtime error (invalid literal for int() with base 10: 'Mask and image must be the same size') during ICA-AROMA, fMRIprep 1.0.0-rc8
#3

I’m having this problem as well. The --fs-license-file option doesn’t seem to be working, unless I’m doing something wrong…

  docker run -it --rm \
  -v ~/path/to/bids:/data:ro \
  -v ~/path/to/output:/out \
  poldracklab/fmriprep:latest \
  /data /out/out \
  participant \
  --fs-license-file /Applications/freesurfer/license.txt

#4

When running through Docker, I highly recommend using fmriprep-docker, which will take care of mounting the file for you. However, to directly use Docker, you’ll need to mount your license file into your container before fmriprep will have access to it.

Please see the FreeSurfer license section of the docs.


#5

That solved the initial problem, but there’s still one more call that seems to cause an error after fmriprep has run for a while.

I’ve called fmriprep with this command:

docker run -it --rm \
>   -v ~/path/to/data:/data:ro \
>   -v ~/path/to/output:/out \
>   -v ~/path/to/licsense:/opt/freesurfer/license.txt \
>   poldracklab/fmriprep:latest \
>   /data /out/out \
>   participant \
>   --participant-label sub-01 sub-02 \
>   --nthreads 4 \
>   --mem_mb 6000 \
>   --use-aroma \
>   --use-syn-sdc \
>   --write-graph \
>   --fs-license-file /opt/freesurfer/license.txt

But get this error:

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/multiproc.py", line 51, in run_node
result['result'] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 407, in run
self._run_interface()
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 517, in _run_interface
self._result = self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 650, in _run_command
result = self._interface.run()
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base.py", line 1088, in run
runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base.py", line 1658, in _run_interface
self.raise_exception(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base.py", line 1604, in raise_exception
**runtime.dictcopy()))
RuntimeError: Command:
recon-all -autorecon1 -i /root/src/fmriprep/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_reorient/sub-01_run-01_T1w_ras.nii.gz -noskullstrip -openmp 3 -subjid sub-01 -sd /out/out/freesurfer
Standard output:
Subject Stamp: freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1-f53a55a
Current Stamp: freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1-f53a55a
INFO: SUBJECTS_DIR is /out/out/freesurfer
Actual FREESURFER_HOME /opt/freesurfer
Linux e86541303ba0 4.9.49-moby #1 SMP Wed Sep 27 23:17:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
'/opt/freesurfer/bin/recon-all' -> '/out/out/freesurfer/sub-01/scripts/recon-all.local-copy'
/out/out/freesurfer/sub-01

 mri_convert /root/src/fmriprep/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_reorient/sub-01_run-01_T1w_ras.nii.gz /out/out/freesurfer/sub-01/mri/orig/001.mgz 

mri_convert.bin /root/src/fmriprep/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_reorient/sub-01_run-01_T1w_ras.nii.gz /out/out/freesurfer/sub-01/mri/orig/001.mgz 
$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $
reading from /root/src/fmriprep/work/fmriprep_wf/single_subject_01_wf/anat_preproc_wf/anat_template_wf/t1_reorient/sub-01_run-01_T1w_ras.nii.gz...
--------------------------------------------------------------------------
GNU libc version: 2.23
ERROR: Systems running GNU glibc version greater than 2.15
  require a newly formatted license file (it's free). Please
  download a new one from the following page:
  http://surfer.nmr.mgh.harvard.edu/registration.html
--------------------------------------------------------------------------
Linux e86541303ba0 4.9.49-moby #1 SMP Wed Sep 27 23:17:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

recon-all -s sub-01 exited with ERRORS at Mon Nov 20 22:13:39 UTC 2017

For more details, see the log file /out/out/freesurfer/sub-01/scripts/recon-all.log
To report a problem, see http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting

Standard error:

Return code: 1

The same error occurs for sub-02. If you have any idea what might be going on it would be much appreciated!


#6

Have you tried downloading a new license file from http://surfer.nmr.mgh.harvard.edu/registration.html as the error message suggests?


#7

I had, but I’m realizing now that I downloaded a Mac license, rather than Linux. That might be the problem. Re-running fmriprep now and I’ll let you know if that solves the error!


#8

Perfect, that worked straight away. Thanks!


#9

I’m getting an error using fMRI_prep in a singularity container. I keep getting the error:
ERROR: a valid license file is required for FreeSurfer to run.
Even when I include the --fs-license-file with a full path to the license.


#10

Could you share the full command line you are using?


#11

PYTHONPATH="" singularity run /exports/fsw/mrgiffin/poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img /exports/fsw/mrgiffin/UG/BIDS /exports/fsw/mrgiffin/UG/fMRI_prepped participant --fs-license-file /exports/fsw/mrgiffin/license.txt -w /exports/fsw/mrgiffin/UG/fMRI_prepped_interim


#12

Ok - nothing seems wrong on the first glance. Could you provide outputs of the following commands:

PYTHONPATH="" singularity exec /exports/fsw/mrgiffin/poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img env

and

PYTHONPATH="" singularity exec /exports/fsw/mrgiffin/poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img head -n 2 /exports/fsw/mrgiffin/license.txt


#13

PYTHONPATH="" singularity exec /exports/fsw/mrgiffin/poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img env

HISTFILESIZE=2000
LESSOPEN=| /usr/bin/lesspipe %s
HISTTIMEFORMAT=’%a, %d %b %Y %l:%M:%S%p %z ’
POSSUMDIR=/usr/share/fsl/5.0
AFNI_TTATLAS_DATASET=/usr/share/afni/atlases
AFNI_PLUGINPATH=/usr/lib/afni/plugins
MAIL=/var/mail/mrgiffin
SSH_CLIENT=145.88.65.151 43410 60172
USER=mrgiffin
LANGUAGE=en_US:
J2SDKDIR=/usr/lib/jvm/java-8-oracle
SGE_CLUSTER_NAME=p6444
SHLVL=1
J2REDIR=/usr/lib/jvm/java-8-oracle/jre
LD_LIBRARY_PATH=/usr/lib/fsl/5.0:
HOME=/home/mrgiffin
SSH_TTY=/dev/pts/1
SGE_EXECD_PORT=6445
PS1=Singularity.poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img> $
MINC_LIB_DIR=/opt/freesurfer/mni/lib
LMFILES=/usr/local/Modules/3.2.10/modulefiles/OpenGridScheduler:/usr/local/Modules/3.2.10/modulefiles/History:/usr/local/Modules/3.2.10/modulefiles/fsl/5.0.9-shark:/usr/local/Modules/3.2.10/modulefiles/singularity/2.4.1:/usr/local/Modules/3.2.10/modulefiles/freesurfer/5.3.0:/usr/local/Modules/3.2.10/modulefiles/freesurfer/dev:/usr/local/Modules/3.2.10/modulefiles/freesurfer/v6beta
FREESURFER_HOME=/opt/freesurfer
FSLDIR=/usr/share/fsl/5.0
MINC_BIN_DIR=/opt/freesurfer/mni/bin
AFNI_IMSAVE_WARNINGS=NO
ANTSPATH=/usr/lib/ants
FUNCTIONALS_DIR=/opt/freesurfer/sessions
FSLMULTIFILEQUIT=TRUE
FSLTCLSH=/usr/bin/tclsh
LOGNAME=mrgiffin
SINGULARITY_INIT=1
FSFAST_HOME=/opt/freesurfer/fsfast
XDG_SESSION_ID=1639
TERM=xterm-256color
SGE_ROOT=/usr/local/OpenGridScheduler/gridengine
HISTCONTROL=ignoreboth
PATH=/usr/local/miniconda/bin:/opt/ICA-AROMA:/opt/c3d//bin:/usr/lib/ants:/usr/lib/fsl/5.0:/usr/lib/afni/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DERBY_HOME=/usr/lib/jvm/java-8-oracle/db
PERL5LIB=/opt/freesurfer/mni/lib/perl5/5.8.5
FSLGECUDAQ=cuda.q
XDG_RUNTIME_DIR=/run/user/10041226
OS=Linux
SGE_CELL=default
MNI_DIR=/opt/freesurfer/mni
FSLOUTPUTTYPE=NIFTI_GZ
HISTSIZE=1000
LANG=C.UTF-8
MNI_PERL5LIB=/opt/freesurfer/mni/lib/perl5/5.8.5
AFNI_MODELPATH=/usr/lib/afni/models
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arj=01;31:.taz=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lz=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.axv=01;35:.anx=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.axa=00;36:.oga=00;36:.spx=00;36:.xspf=00;36:
LOCAL_DIR=/opt/freesurfer/local
FSLWISH=/usr/bin/wish
FS_OVERRIDE=0
CRN_SHARED_DATA=/niworkflows_data
SHELL=/bin/bash
LESSCLOSE=/usr/bin/lesspipe %s %s
FSL_DIR=/usr/share/fsl/5.0
FMRI_ANALYSIS_DIR=/opt/freesurfer/fsfast
FSF_OUTPUT_FORMAT=nii.gz
MODULE_VERSION=3.2.10
MODULE_VERSION_STACK=3.2.10
SINGULARITY_CONTAINER=poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img
MNI_DATAPATH=/opt/freesurfer/mni/data
LC_ALL=C.UTF-8
PWD=/home/mrgiffin
JAVA_HOME=/usr/lib/jvm/java-8-oracle
SGE_QMASTER_PORT=6444
LOADEDMODULES=OpenGridScheduler:History:fsl/5.0.9-shark:singularity/2.4.1:freesurfer/5.3.0:freesurfer/dev:freesurfer/v6beta
SUBJECTS_DIR=/opt/freesurfer/subjects
SSH_CONNECTION=145.88.65.151 43410 145.88.65.152 60172
MKL_NUM_THREADS=1
PYTHONPATH=
OMP_NUM_THREADS=1
SINGULARITY_NAME=poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img
MANPATH=/usr/local/OpenGridScheduler/gridengine/man:/usr/share/man:/usr/local/share/man
MODULEPATH=/usr/local/Modules/versions:/usr/local/Modules/$MODULE_VERSION/modulefiles:/usr/local/Modules/modulefiles
MODULESHOME=/usr/local/Modules/3.2.10
FIX_VERTEX_AREA=
C3DPATH=/opt/c3d/

PYTHONPATH="" singularity exec /exports/fsw/mrgiffin/poldracklab_fmriprep_latest-2018-02-23-faf5170f3072.img head -n 2 /exports/fsw/mrgiffin/license.txt
head: cannot open ‘/exports/fsw/mrgiffin/license.txt’ for reading: No such file or directory

The latter of which is strange, because the license.txt file is certainly in that directory. Thanks for your help!


#14

On my experience, the easiest way to pass the freesurfer license file into Singularity is:

  1. Place the file in the working directory where you plan to run singularity.
  2. Set FS_LICENSE to $PWD/license.txt

#15

In singularity no all paths from the host system are accessible inside the container. Which ones are depends on the configuration of singularity (performed by the administrator). Depending on the configuration you might be able to make some folder accessible as a user via command line arguments (more info here: http://singularity.lbl.gov/docs-mount).

However the quickest solution would be to put the license file inside a folder that you know is already accessible such as $HOME or /exports/fsw/mrgiffin/UG/BIDS.


#16

Great, thanks. Copying the license file to $HOME worked (it finds the license now, I’m getting another error but at least that problem is solved), turns out it was a problem of path accessibility. Thanks again.


#17

I’m getting a similar error, and I’ve downloaded (and re-loaded) a freesurfer license (but that didn’t solve the issue). Here’s the command I’m running.

docker run --rm -v /home/jamielh/:/opt/freesurfer/license.txt:ro -v /home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/:/data:ro -v /home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/derivatives/:/out -v /usr/share/fsl/5.0/data/standard/MNI152_T1_2mm_brain.nii.gz:/imports/MNI152_T1_2mm_brain.nii.gz:ro poldracklab/fmriprep:1.0.3 /data /out participant --participant_label ${i} --output-space T1w --no-freesurfer --ignore fieldmaps --output-space template T1w --use-aroma --ignore-aroma-denoising-errors --nthreads 2 --omp-nthreads 2 --output-grid-reference /imports/MNI152_T1_2mm_brain.nii.gz --work-dir /home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/derivatives/working

I pasted portions of my error/output log below…

Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/multiproc.py”, line 62, in run_node
result[‘result’] = node.run(updatehash=updatehash)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py”, line 441, in run
result = self._run_interface(execute=True)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py”, line 518, in _run_interface
return self._run_command(execute)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py”, line 594, in _run_command
result = self._interface.run()
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/freesurfer/base.py”, line 268, in run
return super(FSCommandOpenMP, self).run(**inputs)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/freesurfer/base.py”, line 144, in run
return super(FSCommand, self).run(**inputs)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py”, line 485, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py”, line 973, in _run_interface
self.raise_exception(runtime)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py”, line 912, in raise_exception
**runtime.dictcopy()))
RuntimeError: Command:
mri_robust_template --satit --fixtp --mov /data/sub-NDARAY461TZZ/anat/sub-NDARAY461TZZ_acq-VNav_T1w.nii.gz /data/sub-NDARAY461TZZ/anat/sub-NDARAY461TZZ_acq-VNavNorm_T1w.nii.gz --inittp 1 --iscale --noit --template sub-NDARAY461TZZ_acq-VNav_T1w_template.nii.gz --subsample 200 --lta /home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/derivatives/working/fmriprep_wf/single_subject_NDARAY461TZZ_wf/anat_preproc_wf/anat_template_wf/t1_merge/tp1.lta /home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/derivatives/working/fmriprep_wf/single_subject_NDARAY461TZZ_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 /data/sub-NDARAY461TZZ/anat/sub-NDARAY461TZZ_acq-VNav_T1w.nii.gz as movable/source volume.
–mov: Using /data/sub-NDARAY461TZZ/anat/sub-NDARAY461TZZ_acq-VNavNorm_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-NDARAY461TZZ_acq-VNav_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 ‘/data/sub-NDARAY461TZZ/anat/sub-NDARAY461TZZ_acq-VNav_T1w.nii.gz’…
GNU libc version: 2.23
ERROR: Systems running GNU glibc version greater than 2.15
require a newly formatted license file (it’s free). Please
download a new one from the following page:
http://surfer.nmr.mgh.harvard.edu/registration.html
Standard error:
Return code: 255
180507-14:17:56,677 workflow INFO:
[Node] Finished “fmriprep_wf.single_subject_NDARAY461TZZ_wf.func_preproc_task_rest_run_2_wf.bold_hmc_wf.mcflirt”.
180507-14:17:59,178 workflow INFO:
[Node] Setting-up “fmriprep_wf.single_subject_NDARAY461TZZ_wf.func_preproc_task_rest_run_1_wf.bold_hmc_wf.fsl2itk” in “/home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/derivatives/working/fmriprep_wf/single_subject_NDARAY461TZZ_wf/func_preproc_task_rest_run_1_wf/bold_hmc_wf/fsl2itk”.
180507-14:17:59,363 workflow INFO:
[Node] Running “fsl2itk” (“fmriprep.interfaces.itk.MCFLIRT2ITK”)
180507-14:18:51,155 workflow INFO:
[Node] Finished “fmriprep_wf.single_subject_NDARAY461TZZ_wf.func_preproc_task_rest_run_1_wf.bold_hmc_wf.fsl2itk”.
180507-14:18:53,386 workflow INFO:
[Node] Setting-up “fmriprep_wf.single_subject_NDARAY461TZZ_wf.func_preproc_task_rest_run_1_wf.bold_bold_trans_wf.bold_transform” in “/home/jamielh/Volumes/Hanson/NKI_HealthyBrainNetwork/CBIC/R3/derivatives/working/fmriprep_wf/single_subject_NDARAY461TZZ_wf/func_preproc_task_rest_run_1_wf/bold_bold_trans_wf/bold_transform”.
180507-14:18:53,544 workflow INFO:
[Node] Running “bold_transform” (“fmriprep.interfaces.itk.MultiApplyTransforms”)

Have others run into this?

Thanks much!
Jamie.


#18

Hi,

This part of your command line:

-v /home/jamielh/:/opt/freesurfer/license.txt:ro

indicates that you are mapping a folder to a file. You should try:

-v /home/jamielh/license.txt:/opt/freesurfer/license.txt:ro

If /home/jamielh/license.txt is the location where you saved your license file on the host file system.


#19

Perfect, that solved it. Interestingly, I think that initial syntax (without license.txt) worked in some iterations of things. (but I added the full path and all’s well).

Thanks much!