poldracklab / pydeface

defacing utility for MRI images
MIT License
110 stars 42 forks source link

pydeface will choke on '(' in filename #49

Closed vincentkersten closed 1 year ago

vincentkersten commented 1 year ago

Hi all, just ran into this error today:

pydeface --outfile /tmp/test.nii '/Library/researchdata/1220/20170616-103118_MRI/1220-VERBG_PRE15(t-test,_MC)-602.nii'
--------------
pydeface 2.0.2
--------------
Temporary files:
  /tmp/tmpgadexfnj.mat
  /tmp/tmpov9w01f0.nii.gz
Defacing...
  /Library/researchdata/1220/20170616-103118_MRI/1220-VERBG_PRE15(t-test,_MC)-602.nii
221216-13:27:34,90 nipype.interface INFO:
     stderr 2022-12-16T13:27:34.090563:/bin/sh: 1: Syntax error: "(" unexpected
221216-13:27:34,130 nipype.interface INFO:
     stderr 2022-12-16T13:27:34.130592:/bin/sh: 1: Syntax error: "(" unexpected
Traceback (most recent call last):
  File "/usr/local/bin/pydeface", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/pydeface/__main__.py", line 95, in main
    pdu.deface_image(**vars(args))
  File "/usr/local/lib/python3.9/dist-packages/pydeface/utils.py", line 117, in deface_image
    warped_mask_img = load(warped_mask)
  File "/usr/local/lib/python3.9/dist-packages/nibabel/loadsave.py", line 94, in load
    raise ImageFileError(f"Empty file: '{filename}'")
nibabel.filebasedimages.ImageFileError: Empty file: '/tmp/tmpov9w01f0.nii.gz'

where it seems nipype(?) chocked on the '(' on the command line.

ofgulban commented 1 year ago

@vincentkersten , thanks for reporting this. It seems that the issue is indeed coming from how nipype executes the commands. I have considered several workarounds but I think they do not worth changing the pydeface source code for now. Therefore, my advice for you would be either removing the parentheses, or automatize temporary string replacements for these problematic characters. E.g. replace ( with PARANTHESIS_LEFT in the filename string and then once pydeface runs replace it back to (.

vincentkersten commented 1 year ago

Thanks for the follow up and the workaround!

On 7 Mar 2023, at 12:15, Omer Faruk Gulban @.***> wrote:

@vincentkersten https://github.com/vincentkersten , thanks for reporting this. It seems that the issue is indeed coming from how nipype executes the commands. I have considered several workarounds but I think they do not worth changing the pydeface source code for now. Therefore, my advice for you would be either removing the parentheses, or automatize temporary string replacements for these problematic characters (e.g. replace ( with PARANTHESIS_LEFT in the filename string and then once pydeface runs replace it back to ().

— Reply to this email directly, view it on GitHub https://github.com/poldracklab/pydeface/issues/49#issuecomment-1457988886, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJNRGM27WQRHLNJ3CAJJJTW24KELANCNFSM6AAAAAATA4DHIM. You are receiving this because you were mentioned.