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

Bidsonym latest fails to run due to TraitError #87

Open palandh opened 1 week ago

palandh commented 1 week ago

Describe the bug At first I tried to get Bidsonym running with the repronim containers with a datalad containers run call with no usable results and many undecipherable errors from my perspective. I think the bidsonym package is a wonderful utility, sadly I did not manage to achieve a clean susscessful run. Therfore I obtained the latest Docker image and called a script containing the docker command with datalad run -m "testing docker-bidsonym" ./code/run-bidsonym.sh which fails with traits.trait_errors.TraitError: The 'in_file' trait of a BETInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/bids_dataset/sub-01011/ses-plc/anat/sub-01011_ses-plc_T1w.nii.gz' <class 'str'> was specified.

Direct execution of the command in the script file fails with the same error. Participant level execution also resulted in same error.

I am somewhat confused if I have a dumb error on my site or if there is a real bug. I would appreciate the helpful look on that error.

The long output is:

(base) hpx@imaging-research-vm:~/research/bidsonym-test$ datalad run -m "testing docker-bidsonym" ./code/run-bidsonym.sh
[INFO   ] == Command start (output follows) ===== 
Some packages in this Docker container are non-free
If you are considering commercial use of this container, please consult the relevant license:
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Licence
Input data will not be checked for BIDS compliance.
Found the following session(s) for participant 01011:
['bot', 'plc', 'top']
241009-14:41:36,8 nipype.workflow INFO:
         Workflow brainextraction_wf settings: ['check', 'execution', 'logging', 'monitoring']
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 220, in run_deeid
    run_brain_extraction_bet(T1_file, args.bet_frac[0],
  File "/home/bm/bidsonym/utils.py", line 331, in run_brain_extraction_bet
    brainextraction_wf.run()
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/pipeline/engine/workflows.py", line 628, in run
    execgraph = generate_expanded_graph(deepcopy(flatgraph))
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/pipeline/engine/utils.py", line 967, in generate_expanded_graph
    graph_in = _remove_nonjoin_identity_nodes(graph_in, keep_iterables=True)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/pipeline/engine/utils.py", line 847, in _remove_nonjoin_identity_nodes
    _remove_identity_node(graph, node)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/pipeline/engine/utils.py", line 875, in _remove_identity_node
    _propagate_root_output(graph, node, field, connections)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/pipeline/engine/utils.py", line 914, in _propagate_root_output
    destnode.set_input(inport, value)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 312, in set_input
    setattr(self.inputs, parameter, deepcopy(val))
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 330, in validate
    value = super(File, self).validate(objekt, name, value, return_pathlike=True)
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
    self.error(objekt, name, str(value))
  File "/opt/miniconda-latest/envs/bidsonym/lib/python3.10/site-packages/traits/base_trait_handler.py", line 74, in error
    raise TraitError(
traits.trait_errors.TraitError: The 'in_file' trait of a BETInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/bids_dataset/sub-01011/ses-plc/anat/sub-01011_ses-plc_T1w.nii.gz' <class 'str'> was specified.
[INFO   ] == Command exit (modification check follows) ===== 
[INFO   ] The command had a non-zero exit code. If this is expected, you can save the changes with 'datalad save -d . -r -F .git/COMMIT_EDITMSG' 
run(error): /home/hpx/research/bidsonym-test (dataset) [./code/run-bidsonym.sh]

To Reproduce run-bidsonym.sh:

docker run -it --rm -v /home/hpx/research/bidsonym-test/:/bids_dataset peerherholz/bidsonym:latest \
/bids_dataset group --deid pydeface --brainextraction bet --bet_frac 0.5 \
 --skip_bids_validation

Expected behavior Normal run.

OS/environment (please provide precise information on your OS/environment): Running in a VM with Ubuntu 22.04.4 LTS (Jammy Jellyfish) with VMWare Workstation 17 Player

Installed Docker Version Client: Docker Engine - Community Version: 27.3.1 API version: 1.47 Go version: go1.22.7 Git commit: ce12230 Built: Fri Sep 20 11:41:00 2024 OS/Arch: linux/amd64 Context: default

Server: Docker Engine - Community Engine: Version: 27.3.1 API version: 1.47 (minimum version 1.24) Go version: go1.22.7 Git commit: 41ca978 Built: Fri Sep 20 11:41:00 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.22 GitCommit: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c runc: Version: 1.1.14 GitCommit: v1.1.14-0-g2c9f560 docker-init: Version: 0.19.0 GitCommit: de40ad0

palandh commented 1 week ago

Found out that I have quite an old datalad version and tried on new dataset without datalad(git/git-annex) which managed to run on participant level without error. Will further investigate after datalad update.

datalad --version
datalad 0.19.5