IQMs for diffusion images

Image quality metrics for diffusion MRI data

The names below are the columns of the group table (group_dwi.tsv). Volumes with a b-value of 50 or lower are considered b=0, and shells are sorted by increasing b-value. The efc_shell* and fber_shell* columns count the b=0 volumes as their first shell (shell01), whereas the snr_cc_shell* columns number b=0 as shell0 and the diffusion-weighted shells from shell1 on.

Shell descriptors

Number of shells and b-values (NumberOfShells, bValues, bValuesEstimation)

NumberOfShells is the number of diffusion-weighted shells (b=0 excluded), and bValuesEstimation lists the b-value of each of them. bValues lists the unique b-values in the .bval file, or reads Likely DSI when there are more than ten. Data with more than eleven distinct nonzero b-values (rounded to hundreds) are considered DSI, and their b-values are clustered into shells with k-means.

IQMs relating to spatial information

Definitions are given in the summary of structural IQMs.

  • Entropy-focus criterion (efc_shell*, efc()), calculated on each shell after head-motion correction.

  • Foreground-Background energy ratio (fber_shell*, fber(), [Shehzad2015]), calculated on each shell after head-motion correction, with the brain mask as foreground.

  • Summary statistics (summary_{bg,fg,wm}_*, summary_stats()) of the average b=0 image within the background (bg), the brain mask (fg), and a white-matter mask (wm, the largest connected component of FA above 0.35). For each region, MRIQC reports the mean, the median, the standard deviation (stdv), the median absolute deviation (mad), the kurtosis (k), the 5th and 95th percentiles (p05, p95), and the number of voxels (n).

IQMs relating to diffusion weighting

IQMs specific to diffusion weighted imaging.

SNR estimated in the Corpus Callosum (snr_cc_*, cc_snr())

The corpus callosum (CC) mask gathers the white-matter voxels, within a central bounding box, whose color FA is predominantly red (left-right orientation). snr_cc_shell0 is the mean of the average b=0 image within the CC, divided by sigma_cc. For each diffusion-weighted shell, snr_cc_shell<N>_worst takes the volume whose b-vector is closest to the left-right (X) axis, where diffusion along the callosal fibers attenuates the signal the most, and snr_cc_shell<N>_best averages the volumes closest to the Y and Z axes. Both are the mean signal within the CC divided by sigma_cc.

Signal variability in the Corpus Callosum (sigma_cc)

Robust standard deviation (normalized median absolute deviation) of the average b=0 image within the CC mask, used as the noise term of snr_cc_*.

Noise level estimated by PCA denoising (sigma_pca)

Median, within the brain mask, of the noise-level map that svht_denoise estimates while denoising the series (singular value shrinkage on local patches).

Noise in raw dMRI estimated with PIESNO (sigma_piesno)

Employs the PIESNO (Probabilistic Identification and Estimation of Noise) algorithm [Koay2009] to estimate the standard deviation (sigma) of the noise in each slice of the input 4D dMRI series, assuming four receiver channels. MRIQC reports the median across slices.

Number of not-a-number (NaN) values in the FA map (fa_nans)

Fraction of NaNs within the brain mask, in ppm. The FA map comes from a tensor (single-shell) or a kurtosis (multi-shell) model fitted on the denoised data.

Number of degenerate modeled voxels in the FA map (fa_degenerate)

Fraction of invalid FA values (i.e., outside the [0, 1] closed range) within the brain mask, in ppm.

Neighboring DWI correlation (ndc, neighboring_dwi_correlation())

Average Pearson correlation, within the brain mask, between each diffusion-weighted volume of the input series and its nearest neighbor in q-space [Yeh2019]. Low values (typically below 0.4) can indicate poor image quality.

IQMs relating artifacts and other

IQMs targeting artifacts that are specific of DWI images.

Global and slice-wise spike fractions (spikes_*, spike_ppm())

Fractions of voxels classified as spikes (in parts-per-million, ppm). A voxel is a spike when its intensity exceeds the mean plus three standard deviations of the brain voxels in its shell. spikes_global is the fraction of spiking voxels across the input series. For each axis, spikes_slice_{i,j,k} is the fraction of rows of voxels along that axis (one row per position on the other two axes and volume) where more than 5% of the voxels are spikes.

Head motion (fd_*)

Framewise displacement (FD) estimated by the head-motion correction, which aligns every volume to the average b=0 image with AFNI’s 3dvolreg. fd_mean is the average FD (in mm), fd_num the number of volumes with an FD above 0.2 mm, and fd_perc their percentage over the series.

Rotation of the b-vectors by head motion (bdiffs_*)

Angle (in radians) between each original b-vector and the same vector rotated by the head-motion correction. bdiffs_mean, bdiffs_median, bdiffs_min, and bdiffs_max summarize the volumes rotated by more than 1e-4 rad (b=0 volumes are therefore excluded).

Not reported

Smoothness (fwhm_*) is not computed on DWI data, and noise_b0() is not used by the DWI workflow.

References

[Koay2009]

Koay C.G., E. Ozarslan, C. Pierpaoli. Probabilistic Identification and Estimation of Noise (PIESNO): A self-consistent approach and its applications in MRI. JMR, 199(1):94-103, 2009.

exception mriqc.qc.diffusion.ExtremeValueWarning[source]

Bases: UserWarning

A warning type for dubious metric values.

mriqc.qc.diffusion.cc_snr(in_b0: ndarray, dwi_shells: list[ndarray], cc_mask: ndarray, b_values: ndarray, b_vectors: ndarray, bval_thres: int = 50, decimals: int = 2) → dict[int, (<class 'float'>, <class 'float'>)][source]

Calculates the worst-case and best-case signal-to-noise ratio (SNR) within the corpus callosum.

This function estimates the SNR in the corpus callosum (CC) by comparing the mean signal intensity within the CC mask to the standard deviation of the background signal (extracted from the b0 image). It performs separate calculations for each diffusion-weighted imaging (DWI) shell.

Worst-case SNR: The mean signal intensity along the diffusion direction with the lowest signal is considered the worst-case scenario.

Best-case SNR: The mean signal intensity averaged across the two diffusion directions with the highest signal is considered the best-case scenario.

Parameters:
  • in_b0 (ndarray (float, 3D)) – T1-weighted or b0 image used for background signal estimation.

  • dwi_shells (list[ndarray (float, 4D)]) – List of DWI data for each diffusion-weighted shell (excluding b=0).

  • cc_mask (ndarray (bool, 3D)) – Boolean mask of the corpus callosum.

  • b_values (ndarray (int)) – Array of b-values, one per shell in dwi_shells.

  • b_vectors (ndarray (float)) – Array of diffusion-encoding vectors for each DWI volume in dwi_shells.

Returns:

cc_snr_estimates – Dictionary containing SNR estimates for each b-value. Keys are the b-values (integers), and values are tuples containing two elements:

  • The first element is the worst-case SNR (float).

  • The second element is the best-case SNR (float).

The SNR estimates are zero if there are no sufficient voxels to calculate them (may occur if the number of orientations in the file is very low).

Return type:

dict

mriqc.qc.diffusion.neighboring_dwi_correlation(dwi_data: ndarray, neighbor_indices: list[tuple[int, int]], mask: ndarray | None = None, decimals: int = 4) → float[source]

Calculates the Neighboring DWI Correlation (NDC) from diffusion MRI (dMRI) data.

The NDC is a measure of the correlation between signal intensities in neighboring diffusion-weighted images (DWIs) within a mask. A low NDC (typically below 0.4) can indicate poor image quality, according to Yeh et al. [Yeh2019].

Parameters:
  • dwi_data (4D ndarray) – DWI data on which to calculate NDC

  • neighbor_indices (list of tuple) – List of (from, to) index neighbors.

  • mask (3D ndarray, optional) – optional mask of voxels to include in the NDC calculation

Returns:

The NDC value.

Return type:

float

References

[Yeh2019] (1,2)

Yeh, Fang-Cheng, et al. “Differential tractography as a track-based biomarker for neuronal injury.” NeuroImage 202 (2019): 116131.

Notes

This is a copy of DIPY’s code to be removed (and just imported) as soon as a new release of DIPY is cut including dipy/dipy#3156.

mriqc.qc.diffusion.noise_b0(in_b0: ndarray, percentiles: tuple[float, float, float] = (25.0, 50.0, 75.0), mask: ndarray | None = None) → dict[str, float][source]

Estimates noise levels in raw dMRI data using the variance of the $b$=0 volumes.

This function calculates the variance of the $b$=0 volumes in a 4D dMRI array within a provided mask. It then computes the noise estimates at specified percentiles of the variance distribution. This approach assumes that noise primarily contributes to the lower end of the variance distribution. MRIQC does not report these estimates among the DWI IQMs.

Parameters:
  • in_b0 (ndarray) – The 3D or 4D dMRI data array. If 4D, the first volume (assumed to be the $b$=0 image) is used for noise estimation.

  • percentiles (tuple (float, float, float), optional (default=(25, 50, 75))) – A tuple of three integers specifying the percentiles of the variance distribution to use for noise estimation. These percentiles represent different noise levels within the data.

  • mask (ndarray, optional (default=``None``)) – A boolean mask used to restrict the noise estimation to specific brain regions. If None, a mask of ones with the same shape as the first 3 dimensions of in_b0 is used.

Returns:

A dictionary containing the noise estimates at the specified percentiles:

  • keys: str - Percentile values (e.g., ‘25’, ‘50’, ‘75’).

  • values: float - Noise level estimates at the corresponding percentiles.

Return type:

dict

mriqc.qc.diffusion.spike_ppm(spike_mask: ndarray, slice_threshold: float = 0.05, decimals: int = 2) → dict[str, float | ndarray][source]

Calculates fractions (global and slice-wise) of voxels classified as spikes in ppm.

This function computes two metrics:

  • Global spike parts-per-million [ppm]: Fraction of voxels exceeding the spike threshold across the entire data array.

  • Slice-wise spiking [ppm]: The fraction of slices along each dimension of the data array where the average fraction of spiking voxels within the slice exceeds a user-defined threshold (slice_threshold).

Parameters:
  • spike_mask (ndarray (bool, same shape as data)) – The binary mask indicating spike voxels (True) and non-spike voxels (False).

  • slice_threshold (float, optional (default=0.05)) – The minimum fraction of voxels in a slice that must be classified as spikes for the slice to be considered spiking.

  • decimals (int) – The number of decimals to round the fractions.

Returns:

A dictionary containing the calculated spike percentages:

  • ’global’: float - global spiking voxels ppm.

  • ’slice_{i,j,k,t}’: float - Slice-wise spiking voxel fractions in ppm for each dimension of the data array.

Return type:

dict