mideface - a tool for minimally invasive defacing MRI images


MRI images of the brain inevitably include the head and so the face. These images can be processed in a way to reconstruct the outside of the head which can often yield a near-photo quality image of the face (see image). Before sharing such MRIs, it is usually a good idea to remove the information about the face so as to protect the subject's privacy. However, removing too much information could degrade the utility of the MRIs. This page describes a tool for defacing MRI images in a way that is both minimally invasive and achieves goals of privacy. Here, "minimally invasive" means changing the image in the smallest way to still be private.

Basic Usage

In the basic usage, one passes the MRI volume to mideface and specifies an output volume

mideface --i volume.mgz --o volume.defaced.mgz --samseg-fast

This should take roughly 15min to run. The original and defaced volumes can be viewed with freeview:

freeview volume.mgz volume.defaced.mgz

Quality Assurance (QA)

One can run the above freeview command to verify that the voxels of the face have been replaced with random values, but a more extensive QA is possible by adding and output folder:

mideface --i volume.mgz --o volume.defaced.mgz --samseg-fast --odir qa

The qa folder will have many files in it that can be used for QA, but the most important will be head.surf and head.defaced.surf which can be viewed with

freeview volume.mgz volume.defaced.mgz -f qa/head.surf:edgecolor=yellow -f qa/head.defaced.surf:edgecolor=red:visible=0

In the surface view, you will see head.surf. This is a rendering of the entire original head, including the face. Hit the Alt-C button to turn off head.surf and display head.defaced.surf. This is the head after defacing. You should see something like image where the face now has a wave in it and you may be able to read the "MIDEFACE" watermark across the eyes. This is the replacement face. If you see the wave and the watermark, then you know that the face has been replaced. Hit Alt-C a few times to switch back and forth. Rotate the head to verify that the ears have been removed.