How can I anonymize or deidentify an anatomical MRI?
You can deface an anatomical MRI using the FieldTrip ft_defacevolume function. It will show a graphical user interface that allows you to scale, rotate and translate a box, such that it overlaps with the facial details that you want to be removed.
mri = ft_read_mri('oostenveld_r.mri'); cfg = ; mri_anon = ft_defacevolume(cfg, mri);
You can use the standard MATLAB figure rotate button to look at the MRI from different angles.
Once you are happy with the size and position of the box, you close the figure and the function returns the defaced anatomical MRI.
You can call ft_defacevolume multiple times to sequentially mask out the identifying features. You might also want to remove the ears in two separate calls - one for each ear - as the ears are sometimes considered to be potentially identifying.
It is good practice to review the result of the defacing procedure using
cfg = ; ft_sourceplot(cfg, mri_anon);
Subsequently you can save it to a MATLAB file or to a NIFTI file using:
ft_write_mri('subjectXX_anon.nii', mri_anon.anatomy, 'transform', mri_anon.transform, 'dataformat', 'nifti');
See also this frequently asked question on how to anonimize a CTF MEG dataset.
In principle FieldTrip keeps full track of all analyses that you do. The consequence might be that the original file name (identifying the subject) is included in the provenance information. You can use the ft_anonimizedata function to scrub the provenance from unwanted information.
Better is not to use the subject's name, date of birth or other identifying information as the filename if you acquire the data. If you - or the person from whom you received the data - nevertheless did use identifying information in the file name: the earlier you rename it, the better!