xcp_d.utils.qcmetrics.dice

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:

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

Return type:

float

References