ENH: Make MRI defacing function public (cf issue: #1529) #1544
ENH: Make MRI defacing function public (cf issue: #1529) #1544nordme wants to merge 5 commits intomne-tools:mainfrom
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
| from nibabel.spatialimages import SpatialImage | ||
|
|
||
| defaced_mri = deface_mri(t1_image, mri_landmarks, None) | ||
| assert isinstance(defaced_mri, SpatialImage) |
There was a problem hiding this comment.
I would go a little farther than this... for example if you get_fdata() on the original image and the defaced image, ravel the results, and np.corrcoef(x.ravel(), y.ravel())[0, 1], I'd expect the result to be high but not 1. So maybe between 0.8 and 0.9 or something? (Not sure how many voxels get zeroed, but adjust upper and lower as needed. If you have to adjust upper to 1 it's a problem, if you have to adjust lower to 0 it's a problem). Or maybe better, np.isclose(x, y, atol=...).mean() (for a suitable atol given the voxel values) gives you the proportion of voxels that remained the same, which should be quite high.
| deface : None | dict | ||
| Dict should have two keys with positive numeric values. "Inset" | ||
| controls how close the blackout plane sits to the nasion point in | ||
| mm (a value of 5 will set the blackout plane 5 mm behind the | ||
| nasion); "theta" controls the angle of the blackout plane with | ||
| respect to vertical. Inset and theta values default to 5 and 15, | ||
| respectively. |
There was a problem hiding this comment.
This is a weird public API, let's make it better if we can. When making this public I'd expect something more like
def deface_mri(image, *, landmarks, inset=5, theta=15):
then adjust internal uses accordingly
PR Description
This PR exposes a previously private function for defacing MRI's to the public API. It addresses Issue #1529
Additionally, tests are added for testing the defacing function, and fixtures necessary for testing are added as well.
Merge checklist
Maintainer, please confirm the following before merging.
If applicable: