PeerHerholz / BIDSonym

a BIDS app for pseudo-anonymization of neuroimaging data
https://peerherholz.github.io/BIDSonym/
BSD 3-Clause "New" or "Revised" License
51 stars 12 forks source link

root must own output for pydeface? -u $UID:$GID gets error #66

Open dkp opened 2 years ago

dkp commented 2 years ago

Describe the bug I ran the docker container on linux calling pydeface: docker run -i --rm -u $UID:$GID -v ${PWD}:/bids_dataset peerherholz/bidsonym /bids_dataset participant --deid pydeface --participant_label 219 --brainextraction bet --bet_frac 0.5 --skip_bids_validation

To Reproduce Steps to reproduce the behavior: Run the pydeface algorithm with T1w data on a linux system

Expected behavior I expected pydeface to run and produce files owned by my UID and GID. All of the other algorithms (mridefacer, mri_deface, and quickshear) handle the -u $UID:$GID correctly.

OS/environment (please provide precise information on your OS/environment): Google cloudshell

Additional context It turns out that not all algorithms have a problem. For example, mridefacer runs fine with the -u $UID:$GID

dkp@cloudshell:data$ docker run -i --rm -u $UID:$GID -v ${PWD}:/bids_dataset  peerherholz/bidsonym /bids_dataset  participant --deid pydeface --del_meta 'InstitutionAddress' --participant_label 219 --brainextraction bet --bet_frac 0.5
whoami: cannot find name for user ID 1000
bids-validator@1.5.4

This dataset appears to be BIDS compatible.

        Summary:                 Available Tasks:                     Available Modalities:
        11 Files, 11.43MB        TODO: full task name for rest        T1w
        1 - Subject                                                   T2w
        1 - Session

        If you have any questions, please post on https://neurostars.org/tags/bids.

Making sure the input data is BIDS compliant (warnings can be ignored in most cases).
Processing data from 1 sessions:
['itbs']
220308-17:31:19,516 nipype.utils WARNING:
         A newer version (1.7.0) of nipy/nipype is available. You are using 1.6.0
220308-17:31:20,42 nipype.workflow INFO:
         Workflow brainextraction_wf settings: ['check', 'execution', 'logging', 'monitoring']
220308-17:31:20,47 nipype.workflow INFO:
         Running serially.
220308-17:31:20,47 nipype.workflow INFO:
         [Node] Setting-up "brainextraction_wf.bet" in "/tmp/tmp0veip8pg/brainextraction_wf/bet".
220308-17:31:20,52 nipype.workflow INFO:
         [Node] Running "bet" ("nipype.interfaces.fsl.preprocess.BET"), a CommandLine Interface with command:
bet /bids_dataset/sub-219/ses-itbs/anat/sub-219_ses-itbs_T1w.nii.gz /bids_dataset/sourcedata/bidsonym/sub-219/sub-219_ses-itbs_T1w_brainmask_desc-nondeid.nii.gz -f 0.50
220308-17:31:29,504 nipype.workflow INFO:
         [Node] Finished "brainextraction_wf.bet".
the following meta-data files will be checked:
/bids_dataset/task-rest_bold.json
/bids_dataset/dataset_description.json
/bids_dataset/sub-219/ses-itbs/sub-219_ses-itbs_scans.json
/bids_dataset/sub-219/ses-itbs/anat/sub-219_ses-itbs_T2w.json
/bids_dataset/sub-219/ses-itbs/anat/sub-219_ses-itbs_T1w.json
working on 219
found the following meta-data files:
/bids_dataset/task-rest_bold.json
/bids_dataset/dataset_description.json
/bids_dataset/sub-219/ses-itbs/sub-219_ses-itbs_scans.json
/bids_dataset/sub-219/ses-itbs/anat/sub-219_ses-itbs_T2w.json
/bids_dataset/sub-219/ses-itbs/anat/sub-219_ses-itbs_T1w.json
the following fields will be deleted:
InstitutionAddress
220308-17:31:29,617 nipype.workflow INFO:
         Workflow deface_wf settings: ['check', 'execution', 'logging', 'monitoring']
220308-17:31:29,622 nipype.workflow INFO:
         Running serially.
220308-17:31:29,622 nipype.workflow INFO:
         [Node] Setting-up "deface_wf.pydeface" in "/tmp/tmpfhxpmxjp/deface_wf/pydeface".
220308-17:31:29,625 nipype.workflow INFO:
         [Node] Running "pydeface" ("nipype.interfaces.utility.wrappers.Function")
--------------
pydeface 2.0.0
--------------
Traceback (most recent call last):
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1209, in get_cache_path
    _bypass_ensure_directory(target_path)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3198, in _bypass_ensure_directory
    _bypass_ensure_directory(dirname)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3198, in _bypass_ensure_directory
    _bypass_ensure_directory(dirname)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3198, in _bypass_ensure_directory
    _bypass_ensure_directory(dirname)
  [Previous line repeated 1 more time]
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3200, in _bypass_ensure_directory
    mkdir(dirname, 0o755)
PermissionError: [Errno 13] Permission denied: '/.cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/miniconda-latest/envs/bidsonym/bin/pydeface", line 33, in <module>
    sys.exit(load_entry_point('pydeface==2.0.0', 'console_scripts', 'pydeface')())
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pydeface-2.0.0-py3.6.egg/pydeface/__main__.py", line 95, in main
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pydeface-2.0.0-py3.6.egg/pydeface/utils.py", line 86, in deface_image
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pydeface-2.0.0-py3.6.egg/pydeface/utils.py", line 17, in initial_checks
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1144, in resource_filename
    self, resource_name
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1754, in get_resource_filename
    return self._extract_resource(manager, zip_path)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1783, in _extract_resource
    self.egg_name, self._parts(zip_path)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1211, in get_cache_path
    self.extraction_error()
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1191, in extraction_error
    raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s)
to the Python egg cache:

  [Errno 13] Permission denied: '/.cache'

The Python egg cache directory is currently set to:

  /.cache/Python-Eggs

Perhaps your account does not have write access to this directory?
You can change the cache directory by setting the PYTHON_EGG_CACHE
environment variable to point to an accessible directory.

220308-17:31:31,210 nipype.workflow WARNING:
         Storing result file without outputs
220308-17:31:31,211 nipype.workflow WARNING:
         [Node] Error on "deface_wf.pydeface" (/tmp/tmpfhxpmxjp/deface_wf/pydeface)
220308-17:31:31,214 nipype.workflow ERROR:
         Node pydeface failed to run on host f7a87785c116.
220308-17:31:31,216 nipype.workflow ERROR:
         Saving crash info to /tmp/crash-20220308-173131-UID1000-pydeface-af0df71f-7367-4d9d-bd06-4e6744477fb5.pklz
Traceback (most recent call last):
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/plugins/linear.py", line 46, in un
    node.run(updatehash=updatehash)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
    result = self._run_interface(execute=True)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
    return self._run_command(execute)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
    result = self._interface.run(cwd=outdir)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 434, in run
    runtime = self._run_interface(runtime)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/interfaces/utility/wrappers.py", line 142, in _run_interface
    out = function_handle(**args)
  File "<string>", line 19, in pydeface_cmd
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['pydeface', '/bids_dataset/sourcedata/bidsonym/sub-219/sub-219_ses-itbs_T1w.nii.gz', '--out', '/bids_dataset/sub-219/ses-itbs/anat/sub-219_ses-itbs_T1w.nii.gz', '--force']' returned non-zero exit status 1.

220308-17:31:31,217 nipype.workflow INFO:
         ***********************************
/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/bids/layout/models.py:152: FutureWarning: The 'extension' entity currently excludes the leading dot ('.'). As of version 0.14.0, it will include the leading dot. To suppress this warning and include the leading dot, use `bids.config.set_option('extension_initial_dot', True)`.
  FutureWarning)
220308-17:31:31,218 nipype.workflow ERROR:
         could not run node: deface_wf.pydeface
220308-17:31:31,218 nipype.workflow INFO:
         crashfile: /tmp/crash-20220308-173131-UID1000-pydeface-af0df71f-7367-4d9d-bd06-4e6744477fb5.pklz
220308-17:31:31,218 nipype.workflow INFO:
         ***********************************
Traceback (most recent call last):
  File "/opt/miniconda-latest/envs/bidsonym/bin/bidsonym", line 33, in <module>
    sys.exit(load_entry_point('bidsonym', 'console_scripts', 'bidsonym')())
  File "/home/bm/bidsonym/run_deeid.py", line 143, in run_deeid
    run_pydeface(source_t1w, T1_file)
  File "/home/bm/bidsonym/defacing_algorithms.py", line 52, in run_pydeface
    deface_wf.run()
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/engine/workflows.py", line 632,in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/plugins/linear.py", line 70, inrun
    report_nodes_not_run(notrun)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.6/site-packages/nipype/pipeline/plugins/tools.py", line 98, in report_nodes_not_run
    ("Workflow did not execute cleanly. " "Check log for details")
RuntimeError: Workflow did not execute cleanly. Check log for details