Skip to main content

Step 7: Denoising and Gibbs Ringing Removal

Overview​

This step applies two artifact corrections to the raw DWI data using MRtrix3:

  1. Denoising (dwidenoise): removes thermal noise using Marchenko-Pastur Principal Component Analysis (MP-PCA)
  2. Gibbs ringing removal (mrdegibbs): removes oscillatory artifacts near sharp tissue boundaries caused by Fourier truncation during image reconstruction

These corrections improve the quality of the diffusion data before eddy current and motion correction in the next step.

Further reading: DWI Denoising — MRtrix3 documentation on the MP-PCA method and why denoising must happen before other processing steps

Conceptual Background​

Thermal Noise and MP-PCA Denoising​

Every MRI image contains random thermal noise generated by the scanner electronics and the body itself. In diffusion imaging, this noise is especially problematic because:

  • DWI images have inherently lower SNR than structural images (the diffusion encoding deliberately attenuates signal)
  • Noise can bias diffusion metric estimates — particularly FA, which tends to be overestimated in noisy data

MP-PCA denoising is based on random matrix theory:

  1. Take a local patch of voxels across all DWI volumes
  2. Decompose the signal using PCA (Principal Component Analysis)
  3. According to the Marchenko-Pastur distribution, noise components have predictable eigenvalue patterns
  4. Identify and remove the noise components; keep the signal components
  5. Reconstruct the denoised data

Unlike spatial smoothing, MP-PCA removes noise without blurring tissue boundaries or reducing spatial resolution.

Gibbs Ringing Artifacts​

Gibbs ringing appears as oscillating bright and dark bands near sharp tissue boundaries — for example, where cortex meets CSF or at the brain/skull interface. These rings are caused by the truncation of k-space (Fourier space) during image reconstruction: the scanner samples a finite number of k-space lines, and abruptly cutting off the Fourier series creates ringing at sharp edges (the Gibbs phenomenon).

In diffusion imaging, Gibbs ringing can:

  • Create artificial diffusion signal variations near tissue boundaries
  • Bias FA estimates, particularly at the cortical surface
  • Introduce spurious patterns that look like real white matter structure

MRtrix3's mrdegibbs corrects this by estimating and removing the ringing pattern using local subvoxel shifts.

Processing Order: Denoise First, Then Degibbs​

The MP-PCA noise estimation relies on the statistical properties of unmodified data, so denoising has to come first. Applying Gibbs correction beforehand alters the noise characteristics and the denoising algorithm will not work correctly.

The correct order is:

  1. dwidenoise (on raw DWI data)
  2. mrdegibbs (on denoised data)

Prerequisites​

InputSourceDescription
Raw DWI dataStep 1: DICOM to NIfTIUnconverted 4D diffusion volume
.bvec fileStep 1: DICOM to NIfTIGradient directions
.bval fileStep 1: DICOM to NIfTIb-values

Commands​

Step 1: Denoise​

# ──────────────────────────────────────────────
# Define paths
# ──────────────────────────────────────────────
nifti_dir="$base_dir/nifti/$subj/dti"
output_dir="$base_dir/denoised/$subj"

mkdir -p "$output_dir"

# ──────────────────────────────────────────────
# MP-PCA Denoising
# ──────────────────────────────────────────────
dwidenoise "$nifti_dir/${subj}_dti.nii.gz" \
"$output_dir/${subj}_denoised.nii.gz" \
-noise "$output_dir/${subj}_noise_map.nii.gz"
FlagPurpose
-noiseOutputs the estimated noise map — useful for QC (noise should be spatially smooth)

Step 2: Gibbs Ringing Removal​

# ──────────────────────────────────────────────
# Remove Gibbs ringing from the denoised data
# ──────────────────────────────────────────────
mrdegibbs "$output_dir/${subj}_denoised.nii.gz" \
"$output_dir/${subj}_denoised_degibbs.nii.gz"

No additional flags are needed — mrdegibbs automatically detects the ringing parameters from the data.

Optional: Remove Unwanted B-Value Shells​

If your acquisition includes b-value shells that you do not plan to use in your analysis, you can remove them here. This is a data-dependent decision — check your .bval file to see which shells you have:

# Check what b-value shells are in your data
cat "$nifti_dir/${subj}_dti.bval"
# Example output: 0 250 250 1000 1000 1000 2000 2000 2000 ...

When to remove shells:

  • You have very low b-value shells (e.g., b=250) that are not useful for standard DTI or for your planned analysis
  • You want to reduce data size before eddy correction

When to keep all shells:

If you do want to remove shells at this stage:

# Example: keep only b=0 and b=1000 (remove b=250)
dwiextract "$output_dir/${subj}_denoised_degibbs.nii.gz" \
"$output_dir/${subj}_dwi_cleaned.nii.gz" \
-fslgrad "$nifti_dir/${subj}_dti.bvec" "$nifti_dir/${subj}_dti.bval" \
-shells 0,1000 \
-export_grad_fsl "$output_dir/${subj}_cleaned.bvec" \
"$output_dir/${subj}_cleaned.bval"

If you are only doing standard DTI analysis (FA, MD maps), removing extra shells here reduces processing time for eddy. If you might want multi-shell analysis later, keep all shells and extract specific shells in Shell Extraction after eddy correction. The safest approach is to keep everything through eddy and extract later.

Batch Processing Script​

#!/bin/bash
# denoising_gibbs.sh — Denoise and remove Gibbs ringing for all subjects

base_dir="/path/to/project"
nifti_dir="$base_dir/nifti"
output_dir="$base_dir/denoised"

subjects=$(ls -d "$nifti_dir"/sub-* 2>/dev/null | xargs -n1 basename)

for subj in $subjects; do
echo "==========================================="
echo "Processing: $subj"
echo "==========================================="

input="$nifti_dir/$subj/dti/${subj}_dti.nii.gz"

if [ ! -f "$input" ]; then
echo " WARNING: Missing DWI for $subj — skipping"
continue
fi

mkdir -p "$output_dir/$subj"

# Step 1: Denoise
echo " Denoising..."
dwidenoise "$input" \
"$output_dir/$subj/${subj}_denoised.nii.gz" \
-noise "$output_dir/$subj/${subj}_noise_map.nii.gz"

# Step 2: Gibbs correction
echo " Removing Gibbs ringing..."
mrdegibbs "$output_dir/$subj/${subj}_denoised.nii.gz" \
"$output_dir/$subj/${subj}_denoised_degibbs.nii.gz"

echo " Done: $subj"
done

echo "Denoising and Gibbs correction complete."

Expected Output​

FileDescription
${subj}_denoised.nii.gzDenoised DWI (intermediate)
${subj}_noise_map.nii.gzEstimated noise map (for QC)
${subj}_denoised_degibbs.nii.gzFinal denoised + Gibbs-corrected DWI

Quality Check​

1. Visual Comparison: Before vs After Denoising​

Open the raw and denoised images side by side in FSLeyes:

fsleyes "$nifti_dir/$subj/dti/${subj}_dti.nii.gz" \
"$output_dir/$subj/${subj}_denoised.nii.gz" &

What to look for:

  • Noise should be visibly reduced (smoother background outside the brain)
  • Tissue boundaries should remain sharp (not blurred)
  • No new artifacts should appear

2. Inspect the Noise Map​

fsleyes "$output_dir/$subj/${subj}_noise_map.nii.gz" &

The noise map should be spatially smooth — noise levels vary slowly across the image (reflecting coil sensitivity patterns). If the noise map shows sharp edges or structures that look like brain anatomy, something went wrong with the denoising.

3. Check for Gibbs Correction​

Compare a single slice before and after mrdegibbs, looking at tissue boundaries:

fsleyes "$output_dir/$subj/${subj}_denoised.nii.gz" \
"$output_dir/$subj/${subj}_denoised_degibbs.nii.gz" &

Ringing artifacts near the cortical surface and near ventricles should be reduced.

Common Issues​

IssueCauseSolution
dwidenoise fails with dimension errorData has too few volumes for MP-PCANeed at least ~10 volumes; check your data with fslnvols
Denoised image looks blurryPossible if data has very few directionsThis is expected with fewer than ~30 directions; MP-PCA works better with more volumes
Noise map shows brain structureDenoising incorrectly removed signalPossible data quality issue; check if input data is corrupted
mrdegibbs produces striping artifactsRare edge case with certain acquisition parametersTry skipping Gibbs correction — it is less critical than denoising
Shell removal produces empty fileSpecified b-values do not match the dataCheck actual b-values with cat file.bval — scanners often produce e.g., 998 instead of 1000

References​

  • Veraart J, Novikov DS, Christiaens D, Ades-Aron B, Sijbers J, Fieremans E (2016). Denoising of diffusion MRI using random matrix theory. NeuroImage, 142, 394-406.
  • Kellner E, Dhital B, Kiselev VG, Reisert M (2016). Gibbs-ringing artifact removal based on local subvoxel-shifts. Magnetic Resonance in Medicine, 76(5), 1574-1581.
  • Cordero-Grande L, Christiaens D, Hutter J, Price AN, Hajnal JV (2019). Complex diffusion-weighted image estimation via matrix recovery under general noise models. NeuroImage, 200, 391-404.

Next Step​

Proceed to Step 8: Eddy Current & Motion Correction to correct for eddy current distortions and subject head motion.