xcp_d.utils.qcmetrics module

Quality control metrics.

xcp_d.utils.qcmetrics.compute_dvars(*, datat, remove_zerovariance=True, variance_tol=1e-07)[source]

Compute standard DVARS.

Parameters:

datat (numpy.ndarray) – The data matrix from which to calculate DVARS. Ordered as vertices by timepoints.

Returns:

  • numpy.ndarray – The calculated DVARS array. A (timepoints,) array.

  • numpy.ndarray – The calculated standardized DVARS array. A (timepoints,) array.

xcp_d.utils.qcmetrics.compute_registration_qc(bold_mask_anatspace, anat_mask_anatspace, bold_mask_stdspace, template_mask)[source]

Compute quality of registration metrics.

This function will calculate a series of metrics, including:

  • Dice’s similarity index,

  • Pearson correlation coefficient, and

  • Coverage

between the BOLD-to-T1w brain mask and the T1w mask, as well as between the BOLD-to-template brain mask and the template mask.

Parameters:
  • bold_mask_anatspace (str) – Path to the BOLD brain mask in anatomical (T1w or T2w) space.

  • anat_mask_anatspace (str) – Path to the anatomically-derived brain mask in anatomical space.

  • bold_mask_stdspace (str) – Path to the BOLD brain mask in template space.

  • template_mask (str) – Path to the template’s official brain mask.

Returns:

  • reg_qc (dict) – Quality control measures between different inputs.

  • qc_metadata (dict) – Metadata describing the QC measures.

xcp_d.utils.qcmetrics.dice(input1, input2)[source]

Calculate Dice coefficient between two arrays.

Computes the Dice coefficient (also known as Sorensen index) between two binary images.

The metric is defined as

\[DC=\frac{2|A\cap B|}{|A|+|B|}\]

, where \(A\) is the first and \(B\) the second set of samples (here: binary objects). This method was first proposed in Dice[1] and Sorensen[2].

Parameters:

input1/input2 (numpy.ndarray) – Numpy arrays to compare. Can be any type but will be converted into binary: False where 0, True everywhere else.

Returns:

coef – The Dice coefficient between input1 and input2. It ranges from 0 (no overlap) to 1 (perfect overlap).

Return type:

float

References

xcp_d.utils.qcmetrics.overlap(input1, input2)[source]

Calculate overlap coefficient between two images.

The metric is defined as

\[DC=\frac{|A \cap B||}{min(|A|,|B|)}\]

, where \(A\) is the first and \(B\) the second set of samples (here: binary objects).

The overlap coefficient is also known as the Szymkiewicz-Simpson coefficient [3].

Parameters:

input1/input2 (numpy.ndarray) – Numpy arrays to compare. Can be any type but will be converted into binary: False where 0, True everywhere else.

Returns:

coef – Coverage between two images.

Return type:

float

References

xcp_d.utils.qcmetrics.pearson(input1, input2)[source]

Calculate Pearson product moment correlation between two images.

Parameters:

input1/input2 (numpy.ndarray) – Numpy arrays to compare. Can be any type but will be converted into binary: False where 0, True everywhere else.

Returns:

coef – Correlation between the two images.

Return type:

float