poldracklab / pydeface

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

nibabel.deprecator.ExpiredDeprecationError #46

Closed asadmalik85 closed 2 years ago

asadmalik85 commented 2 years ago

Hi,

I get the following exception when I deface, and issue appears to be line 124 in utils.py where get_affine() is used, which is deprecated. Has anyone addressed this issue? Thanks!

pydeface 2.0.0
--------------
Temporary files:
  /tmp/tmp_c45u0hf.mat
  /tmp/tmp9_yxyidm.nii.gz
Defacing...
  /mnt/c/data/temp/PRISM2_NL-98-9998_V1_Struc.nii.gz
Traceback (most recent call last):
  File "/home/amalik/anaconda3/bin/pydeface", line 8, in <module>
    sys.exit(main())
  File "/home/amalik/anaconda3/lib/python3.9/site-packages/pydeface/__main__.py", line 95, in main
    pdu.deface_image(**vars(args))
  File "/home/amalik/anaconda3/lib/python3.9/site-packages/pydeface/utils.py", line 124, in deface_image
    masked_brain = Nifti1Image(outdata, infile_img.get_affine(),
  File "/home/amalik/anaconda3/lib/python3.9/site-packages/nibabel/deprecator.py", line 181, in deprecated_func
    raise error_class(message)
nibabel.deprecator.ExpiredDeprecationError: get_affine method is deprecated.
Please use the ``img.affine`` property instead.

* deprecated from version: 2.1
* Raises <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
asadmalik85 commented 2 years ago

Hi. This is resolved now. Just needed to update line 124 in utils.py to use the affine and header properties of img instead of img.get_affine() and img.get_header().

ofgulban commented 2 years ago

Thanks @asadmalik85 , I have fixed the lines you mentioned and a few others too.