nipreps / fmriprep

fMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse fMRI data. The transparent workflow dispenses of manual intervention, thereby ensuring the reproducibility of the results.
https://fmriprep.org
Apache License 2.0
634 stars 293 forks source link

Freesurfer License Problems #2164

Closed StephDocTUM closed 4 years ago

StephDocTUM commented 4 years ago

Hi,

I am running the following command:

fmriprep-docker /Users/neurolab/Desktop/NeuerOrdner /Users/neurolab/Desktop/NeuerOrdner/derivatives/participant --participant-label 010001 --fs-license-file /Users/neurolab/Desktop/Stephan/Programmes/freesurfer/license.txt

and encounter the following error:

Node Name: fmriprep_wf.single_subject_010001_wf.anat_preproc_wf.surface_recon_wf.autorecon1

The path to my freesurfer license is correct and I do not understand why is putting /opt/ for all freesurfer Pathes?

Anyone an idea?

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
    result = self._interface.run(cwd=outdir)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 397, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 792, in _run_interface
    self.raise_exception(runtime)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 723, in raise_exception
    ).format(**runtime.dictcopy())
RuntimeError: Command:
recon-all -autorecon1 -i /data/sub-010001/ses-02/anat/sub-010001_ses-02_T1w.nii -noskullstrip -openmp 7 -subjid sub-010001 -sd /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/freesurfer
Actual FREESURFER_HOME /opt/freesurfer
Linux ed810a344e1d 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
'/opt/freesurfer/bin/recon-all' -> '/out/freesurfer/sub-010001/scripts/recon-all.local-copy'
/out/freesurfer/sub-010001

 mri_convert /data/sub-010001/ses-02/anat/sub-010001_ses-02_T1w.nii /out/freesurfer/sub-010001/mri/orig/001.mgz 

mri_convert.bin /data/sub-010001/ses-02/anat/sub-010001_ses-02_T1w.nii /out/freesurfer/sub-010001/mri/orig/001.mgz 
--------------------------------------------------------------------------
ERROR: FreeSurfer license file /opt/freesurfer/license.txt not found.
  If you are outside the NMR-Martinos Center,
  go to http://surfer.nmr.mgh.harvard.edu/registration.html 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.
--------------------------------------------------------------------------
$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $
reading from /data/sub-010001/ses-02/anat/sub-010001_ses-02_T1w.nii...
Linux ed810a344e1d 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

recon-all -s sub-010001 exited with ERRORS at Tue Jun  2 17:42:36 UTC 2020

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

Standard error:

Return code: 1
mgxd commented 4 years ago

what version of fmriprep are you using? could you share the actual docker command generated after running the wrapper command?

StephDocTUM commented 4 years ago

yes sure:

docker run --rm -it -e DOCKER_VERSION_8395080871=19.03.8 -v /Users/neurolab/Desktop/Stephan/Programmes/freesurfer/license.txt:/opt/freesurfer/license.txt:ro -v /Users/neurolab/Desktop/NeuerOrdner:/data:ro -v /Users/neurolab/Desktop/NeuerOrdner/derivatives/participant:/out poldracklab/fmriprep:20.1.0 /data /out participant --participant-label 010001

fMRIPrep v20.1.0

An I am using: export PATH=$PATH:/Users/neurolab/.local/bin alias fmriprep-docker='/Users/neurolab/.local/bin/fmriprep-docker' in my ~/.zprofile

mgxd commented 4 years ago

is it possible /Users/neurolab/Desktop/Stephan/Programmes/freesurfer/license.txt does not exist?

StephDocTUM commented 4 years ago

No, I checked it. It does exist for sure.

oesteban commented 4 years ago

This issue and https://neurostars.org/t/fmriprep-recon-all-finding-old-files-how-to-remove/6987 make me think we might have a bug with the config & the fs license setting.

mgxd commented 4 years ago

hm, it is looking for the license in the correct location (/opt/freesurfer/license.txt is where your local license is bound within the container), so I'm not immediate sure what's going on here.

Could you try checking the file within the container interactively?

To shell in, run the following command:

$ docker run --rm -it -e DOCKER_VERSION_8395080871=19.03.8 -v /Users/neurolab/Desktop/Stephan/Programmes/freesurfer/license.txt:/opt/freesurfer/license.txt:ro -v /Users/neurolab/Desktop/NeuerOrdner:/data:ro -v /Users/neurolab/Desktop/NeuerOrdner/derivatives/participant:/out --entrypoint=bash poldracklab/fmriprep:20.1.0

Once you're in, try:

$ cat /opt/freesurfer/license.txt

to verify the license looks correct. What version of freesurfer do you have installed locally?

effigies commented 4 years ago

FYI, you can use your normal fmriprep-docker command and add --shell at the end, and it will open a shell without running fMRIPrep.

oesteban commented 4 years ago

Could you try with 20.1.1 when it becomes available? - it carries #2165 which might solve this issue.

oesteban commented 4 years ago

@stephanwu89 the new release 20.1.1 just posted, could you give it a try?

tanya-wen commented 4 years ago

Hello. I'm having a similar issue after updating to 20.1.1. I was originally using an earlier version of fmriprep (version 20.0.7), which ran without any issues. But after updating, and inputting the same command in the command prompt, it tells me that it cannot find the freesurfer license. In my case, nothing has changed other than the update. The license exists in the indicated location and I've also set up the file sharing in Docker. I would be most grateful for any help/updates on this issue!

RUNNING: docker run --rm -it -e DOCKER_VERSION_8395080871=19.03.8 -v /Users/Tanya Wen/Desktop/fMRI/freesurfer.txt:/opt/freesurfer/license.txt:ro -v C:\Users\Tanya Wen\Desktop\fMRI\decodCC.01_BIDS\Nifti:/data:ro -v C:\Users\Tanya Wen\Desktop\fMRI\decodCC.01_BIDS\Preprocessed:/out poldracklab/fmriprep:20.1.1 /data /out participant --participant-label 03 --dummy-scans 4 --skull-strip-t1w force

ERROR: a valid license file is required for FreeSurfer to run. fMRIPrep looked for an existing license file at several paths, in this order: 1) command line argument --fs-license-file; 2) $FS_LICENSE environment variable; and 3) the $FREESURFER_HOME/license.txt path. Get it (for free) by registering at https://surfer.nmr.mgh.harvard.edu/registration.html

oesteban commented 4 years ago

cc/ @mgxd

StephDocTUM commented 4 years ago

I did recon-all now separately from fmri_rep. Do first recon-all put the output in an appropriate folder and do fmri_prep afterwards.

mgxd commented 4 years ago

@tanya-wen i suspect one your paths was broken by our latest change - could you try running:

docker run --rm -it -e DOCKER_VERSION_8395080871=19.03.8 -v C:\Users\Tanya Wen\Desktop\fMRI\freesurfer.txt:/opt/freesurfer/license.txt:ro -v C:\Users\Tanya Wen\Desktop\fMRI\decodCC.01_BIDS\Nifti:/data:ro -v C:\Users\Tanya Wen\Desktop\fMRI\decodCC.01_BIDS\Preprocessed:/out poldracklab/fmriprep:20.1.1 /data /out participant --participant-label 03 --dummy-scans 4 --skull-strip-t1w force

(this fixes the license path to be in line with your others)

effigies commented 4 years ago

Is it possible that the space in the user name is not being escaped?

mgxd commented 4 years ago

IMO, I suspect its an interaction with Windows requiring specific drives to be shared via Docker and the bash representation of something located on the C: drive. I think (hope) #2180 will fix this.

tanya-wen commented 4 years ago

@mgxd, thank you for your quick reply. Your solution worked!!! Everything is back and running.

p.s., When using 20.0.7, I originally didn't have "C:/" in front of any of the paths (input directory, output directly, nor freeserfer licence) when using the fmriprep-docker rapper. But it seemed that it wasn't an issue back then. It just added it automatically.

sbrueningk commented 4 years ago

HI, I also have this problem with the docker version of smriprep. I am running it on MAC (Catalina) and am using the following command (I replaced the absolute paths here since it is patient specific):

smriprep-docker path_BIDS path_out participant-label 01 fs-license-file $FREESURFER_HOME/license.txt

I get the following output: RUNNING: docker run --rm -it -e DOCKER_VERSION_8395080871=19.03.8 -v path_to_license/license.txt:/opt/freesurfer/license.txt:ro -v path_BIDS:/data:ro -v /path_out:/out poldracklab/smriprep:0.6.1 /data /out participant --participant-label 01 Traceback (most recent call last): File "/usr/local/miniconda/bin/smriprep", line 10, in sys.exit(main()) File "/usr/local/miniconda/lib/python3.7/site-packages/smriprep/cli/run.py", line 10, in main return build_opts(opts) File "/usr/local/miniconda/lib/python3.7/site-packages/smriprep/cli/run.py", line 182, in build_opts 'ERROR: a valid license file is required for FreeSurfer to run. ' RuntimeError: ERROR: a valid license file is required for FreeSurfer to run. sMRIPrep looked for an existing license file at several paths, in this order: 1) command line argument --fs-license-file; 2) $FS_LICENSE environment variable; and 3) the $FREESURFER_HOME/license.txt path. Get it (for free) by registering at https://surfer.nmr.mgh.harvard.edu/registration.html

When I type: echo $FS_LICENSE I get the correct path to my license file, same for $FREESURFER_HOME/license.txt and I also tried to give the absolute path in the --fs-license-file (which also points to the correct file) I would very much appreciate your help :)

oesteban commented 4 years ago

@sbrueningk can you try with:

smriprep-docker path_BIDS path_out participant-label 01 -e FS_LICENSE=/opt/freesurfer/license.txt --fs-license-file $FREESURFER_HOME/license.txt

This is assuming that your license file on the host is located at $FREESURFER_HOME/license.txt

sbrueningk commented 4 years ago

Hello, thank you so much for the quick reply - unfortunately there is still an error: when I use exactly the command suggested I get: smriprep-docker: error: argument analysis_level: invalid choice: 'participant-label' (choose from 'participant')

so I added the '--' for participant label: smriprep-docker path_BIDS path_out --participant-label label -e FS_LICENSE=/opt/freesurfer/license.txt --fs-license-file $FREESURFER_HOME/license.txt

then I the the following error: smriprep-docker: error: argument -e/--env: expected 2 arguments

What else do I need to include as an argument? I would very much appreciate your help. All the best, Sarah

oesteban commented 4 years ago

I may have propagated an error when copied your original command line:

smriprep-docker path_BIDS path_out participant --participant-label 01 -e FS_LICENSE=/opt/freesurfer/license.txt --fs-license-file $FREESURFER_HOME/license.txt
sbrueningk commented 4 years ago

HI, I found the origin of my problem which was that my license file was located on my Desktop and I had to manually allow Docker to access files on the Desktop via System Preferences - Security and Privacy - Files and Folders - Docker - Desktop Folder I don't know why this setting was not activated in the first place, but once this had been changed the normal command: smriprep-docker path-BIDS path-out participant --fs-license-file path-license worked! Thank you all so much for your help!

oesteban commented 4 years ago

I think this has been addressed. Please reopen if new problems emerge.

simmiz commented 4 years ago

Hi,

I'm using fmriprep version 20.1.1 via a singularity container on a HPC system and am running the following command:

cd /fred/oz156 module load singularity/latest singularity run --cleanenv --bind /fred/oz156/ \ /fred/oz156/code/containers/fmriprep-20.1.1.simg \ /fred/oz156/BIDS_files_anonymised_nifti /fred/oz156/BIDS_subjects_fMRIprepoutput_2 \ participant \ --participant-label $1 --work-dir "/fred/oz156/BIDS_files_anonymised_nifti/" \ --fs-license-file "/fred/oz156/freesurfer_license.txt" \

and I'm getting the following error:

ERROR: a valid license file is required for FreeSurfer to run. fMRIPrep looked for an existing license file at several paths, in this order: 1) command line argument --fs-license-file; 2) $FS_LICENSE environment variable; and 3) the $FREESURFER_HOME/license.txt path. Get it (for free) by registering at https://surfer.nmr.mgh.harvard.edu/registration.html

The path to my freesurfer license is correct. I was hoping to see if anyone has an idea of what may be happening?

Thankyou Simone

simmiz commented 4 years ago

@oesteban could you please reopen this thread?

effigies commented 4 years ago

Try running singularity shell and ensure that the path is accessible.

simmiz commented 4 years ago

Thank you - its all sorted now! Appreciate your help with this!

oesteban commented 4 years ago

Please note that this was addressed in 20.1.2 (a later release) and that 20.2.0 LTS had just come out http://reproducibility.stanford.edu/fmriprep-lts/

wanjunhu commented 2 years ago

Thank you - its all sorted now! Appreciate your help with this!

I have the same problem as you, how did you solve it?