Visual Neuroscience Lab
  • Home
  • Neurodesktop
  • Behavioral
  • Labmeeting
  • DICOM to GLM
  • MRI
  • People
  • Internship
  • Other Topics
  • Archive
  1. MRI: from DICOM to GLM Analysis
  2. 04 - Defacing
  • Home
  • Neurodesktop
  • MRI: from DICOM to GLM Analysis
    • 00 - Overview
    • 01 - DICOM to BIDS
    • 02 - Check IntendedFor field of the fmap’s JSON
    • 03 - T1w for PBn
    • 04 - Defacing
    • 05 - Removing Noise Scan
    • 06 - fMRIprep
    • 07 - Retinotopic Mapping
    • 08 - first level GLM
    • 09- second level GLM
    • Troubleshooting
  • MRI
    • MRI-Studies: General Information
    • 3D printing a brain
    • 7T anatomical analysis on neurodesk
    • MRI BIDS and OSF
    • fMRIprep analysis
    • MNI space
    • Old MRI setup
    • Update to the MRI lab setup
    • Physiological noise correction
  • Behavioral
    • Vision tests
    • BIDS for behavioral studies
    • Custom-built chin rests
  • People
    • Stipends and prizes for master and PhD students
    • Coffee time
    • Participant compensation
    • Things to do if you are leaving the lab
    • Scientific writing in practice
    • Research funding opportunities
  • Internship
    • Pflichtpraktikum
    • Internship Checklist
    • internship/claustrum_segmentation.qmd
  • Other Topics
    • Calculating a priori sample size using G Power
    • Gamma correction
    • Contribute to the website
    • Older ways to access the server
  • Labmeeting
  • Archive

On this page

  • 1 General Information
  • 2 Defacing your T1w-Scan
    • 2.1 Start Pydeface (v.2.0.2)
    • 2.2 Get the path to your original T1w scan
    • 2.3 The pydeface command
    • 2.4 The next steps
  1. MRI: from DICOM to GLM Analysis
  2. 04 - Defacing

04 - Defacing

MRI
Preprocessing
Neurodesk
Step by step description of how to deface your data
Author

MG

Published

April 13, 2025

Ensure Defacing!

Defacing your T1w scans is an important preprocessing step that has to be done before running fmriprep as you´ll probably run into errors otherwise!

BUT: don´t run the defacing by default! You should always check first if the T1w-file is already defaced. Running the defacing algorithm multiple times(even though not necessary) can potentially harm the quality of your data!

1 General Information

When we acquired data “ourselves”, we definetely have to deface the T1w-scan (after converting the DICOMs to niftis) before we can continue!

When acquiring data during regular scanner times, we already get nifti files. There should be a directory rawdata, which contains the data in BIDS-Format. Additionally there is a directory faced.

In theory, the directory faced should contain the original T1w-niftis that you can send to the participant and the T1w-niftis within rawdata should already be defaced (and thus be ready to further work with them, e.g. fmriprep).

However, sometimes the automatic defacing at the MRI-Lab does not work as intended, potentially resulting in “non-defaced” T1w-niftis in the rawdata directory! Thus, you should always check the T1w-nifti in rawdata to ensure that it is defaced and avoid potential subsequent problems.

To check the T1w files, you can just load them in freeview, MRIcroGL,…

Alternatively you can also run python /shared/website/showT1.py in the terminal. When you indicate the path to your bids-directory and press enter, this script will open all (be aware of that! Depending on how many subjects are in the directory, this will take some time and open as many T1w files as you have participants!) T1w-files that are stored in the bids-directory.

Don´t forget your participants!

If you promised participants that they´ll get their T1w scan: When the data was acquired outside the regular scanning times (i.e. we start with the DICOMs), make sure to save the T1w-nifti once separately before defacing!

2 Defacing your T1w-Scan

2.1 Start Pydeface (v.2.0.2)

To deface your t1w, you first have to open pydeface:

  1. Click on the Birds-Symbol at the bottom left

  2. Hover Neurodesk

  3. Hover All Applications

  4. Scroll down until you find pydeface

  5. Click on pydeface 2.0.2 Pydeface 2.0.2

After it opens, it may need some time to load everything - be patient!

Finally, it should look like this: Pydeface Started

2.2 Get the path to your original T1w scan

  1. Navigate to the anatomical scan of the participant within your BIDS directory

  2. Right-click on the anatomical nifti file

  3. Select `Copy Path(s) Get Path(s) of anat-scan

2.3 The pydeface command

  1. Go back to the terminal window, where pydeface is loaded (or start it again)

  2. Type pydeface

  3. Enter the path to your T1w scan (right-click + paste or type in the path)

  4. Type --outfile

  5. Repeat Step 3 (with this approach, you “overwrite” the initial T1w with the then defaced T1w file)

  6. Type --force

It should look like this: Pydeface Command

pydeface /home/jovyan/Website/bids/sub-999/ses-1/anat/sub-999_ses-1_T1w.nii.gz --outfile /home/jovyan/Website/bids/sub-999/ses-1/anat/sub-999_ses-1_T1w.nii.gz --force

Then, press enter. Again, it might take a few moments, until pydeface finishes, be patient! At the end, it should look like this: Pydeface Finished

2.4 The next steps

Congratulations, you successfully defaced a T1w-scan and you are one step closer to analyzing your data!

To continue in your journey to your Analysis, please return to the Overview-Page to check what to do next.

Alternatively, here is a list of potential next steps to continue with

  1. Provide Participants their T1w file

  2. Remove Noise Scans from your data?

  3. Check the IntendedFor field of the fmap

  4. run fmriprep

Back to top