Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional flags used to deface 7T data #15

Merged
merged 7 commits into from
Dec 21, 2017

Conversation

ofgulban
Copy link
Collaborator

@ofgulban ofgulban commented Dec 9, 2017

Hi again,

I have made somewhat extensive changes to the interface, these are:

  • Using entry point instead of script (command line call is just pydeface now instead of pydeface.py) to have a flexible structure for adding additional options.
  • Usage can now be accessed with pydeface --help or pydeface -h
  • --force flag to overwrite previous results.
  • --template and --facemask optional arguments to allow custom template and defacing mask instead of the defaults.
  • --cost argument to select other fsl-flirt cost function options.
  • --applyto argument, which accepts multiple paths to apply defacing based on one image to other images.

I have needed these options to deface images with several contrasts acquired at 7T. First example is a set of MPRAGE data:

Original images:

01_orig
Stuff outside the head (in the posterior region) is a dielectric pad.

After using the default pydeface:

pydeface PDw.nii.gz
pydeface T1w.nii.gz
pydeface SI_T1w.nii.gz
pydeface T2*w.nii.gz

02_mutualinfo
It can be seen that the defacing fails with certain contrasts (T1w, SI-T1w, T2*w). Even in PDw image where it mostly succeeds it removes a small chunk from the frontal lobe.

After changing the cost function to normalized mutual information:

pydeface PDw.nii.gz --cost normmi
pydeface T1w.nii.gz --cost normmi
pydeface SI_T1w.nii.gz --cost normmi
pydeface T2*w.nii.gz --cost normmi

03_normmi
It can be seen that the defacing still fails with certain contrasts however succeeds with proton density weighted image.

After using --applyto argument:

pydeface PDw.nii.gz --cost normmi --applyto T1w.nii.gz SI_T1w.nii.gz T2*w.nii.gz

04_applyto
Defacing mask based on the proton density weighted image applied to other contrasts gives the best result.


Second example to show the new additional arguments is a set of MP2RAGE data:

Original images:

11_orig

After using the default pydeface:

pydeface T1.nii.gz
pydeface UNI.nii.gz
pydeface INV1.nii.gz
pydeface INV2.nii.gz

12_mutualinfo
It can be seen that defacing fails in all images,

After changing the cost function to normalized mutual information:

pydeface T1.nii.gz --cost normmi
pydeface UNI.nii.gz --cost normmi
pydeface INV1.nii.gz --cost normmi
pydeface INV2.nii.gz --cost normmi

13_normmi
Defacing was successful in T1 and UNI images.

After using --applyto argument:

pydeface T1.nii.gz --cost normmi --applyto UNI.nii.gz INV1.nii.gz INV2.nii.gz

14_applyto
Defacing mask based on the T1 (or UNI) image applied to other contrasts gives the best result.


I have tested the new command line interface with several 3T-7T data, it seems that everything works as it was (including exceptions etc.) so the previous users should see no difference other than making the command line call as pydeface instead of pydeface.py.

If you decide to merge this, I would recommend to first release the current version (pydeface 1.1) and then merge this PR in case if people still want to conveniently find the old version.

Also, let me know if you have any suggestions about the interface.

@chrisgorgo
Copy link
Contributor

Looks great! Thank you for the contribution!

@chrisgorgo chrisgorgo merged commit 4b92a46 into poldracklab:master Dec 21, 2017
@ofgulban
Copy link
Collaborator Author

Thanks :)

@chrisgorgo chrisgorgo mentioned this pull request Feb 22, 2018
leej3 pushed a commit to leej3/pydeface that referenced this pull request Aug 28, 2018
Additional flags used to deface 7T data
@ofgulban ofgulban mentioned this pull request Apr 20, 2021
@ofgulban ofgulban mentioned this pull request Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants