post_op
Closed this issue · 6 comments
I am running into a problem using the post_op method outlined in the config file as done here:
https://unfmontreal.github.io/Dcm2Bids/3.0.1/how-to/use-advanced-commands/?h=deface#how-to-use-advanced-configuration
When I follow the documentation instructions and use
"post_op": [{"cmd": "pydeface --outfile dst_file src_file",
"datatype": "anat",
"suffix": ["T1w"]}],
I get an error:
raise ValueError("post_op is not defined correctly."
ValueError: post_op is not defined correctly.Please check the documentation.
The logic in the sidecar.py code looks for substrings "dstFile" and "srcFile" -- so I tried replacing the command with "cmd": "pydeface --outfile dstFile srcFile”, but I still get errors:
traits.trait_errors.TraitError: The 'reference' trait of a FLIRTInputSpec instance must be a pathlike object or string representing an existing file, but a value of 'srcFile' <class 'str'> was specified.
It basically is not recognizing the source and destination path in either case. Any idea how to fix?
It's possible this person was running into the same problem:
https://neurostars.org/t/problem-using-pydeface-in-dcm2bids-config-file/26542
Thank you @raniaezzo for reporting this issue. I'll try to replicate it asap and fix it if needed.
@raniaezzo can you try with the PR #260 ? I think this should fix your issue.
@arnaudbore Yes, thanks. It fixed the original issue which was about getting pydeface to run. However, after it completes, the output is not actually defaced when doing it through dcm2bids function.
When I run dcm2bids, the output includes:
INFO | Running: pydeface --outfile /Users/rje257/Desktop/BIDS_testing/sub-0325/ses-01/anat/sub-0325_ses-01_run-01_T1w.nii.gz /Users/rje257/Desktop/BIDS_testing/tmp_dcm2bids/sub-0325_ses-01/032_Subject_0325_anat-T1w_20221003112735.nii.gz --verbose --debug --force
. . .
(it pauses and takes a while during the defacing step)
. . .
INFO | --- dcm2bids end ---
But the output /Users/rje257/Desktop/BIDS_testing/sub-0325/ses-01/anat/sub-0325_ses-01_run-01_T1w.nii.gz is NOT defaced.
I copied the output file back into the tmp directory and re-ran the pydeface command directly (not through dcm2bids), and the defacing works.
I fixed the issue I think you are referring. Can you check you test the PR with the latest commit.
commit 2dc01db96bcbd505ef6559e6ebffb877990582f0 (HEAD -> fix_post_op, origin/fix_post_op)
Author: Arnaud Bore <arnaud.bore@gmail.com>
Date: Mon Sep 11 17:14:15 2023 -0400
change cp to shutil copy
Yes, that worked. Thanks!
Perfect, everything you see in this PR will be in the next release end of this week I think.