aslprep.utils.confounds module

Functions for calculating and collecting confounds.

average_cbf_by_tissue(cbf, gm, wm, csf, thresh)[source]

Compute mean GM, WM, and CSF CBF values.

Parameters:
  • cbf (str) – Path to CBF file.

  • gm, wm, csf (str) – Paths to GM, WM, and CSF tissue probability maps, in same space and resolution as cbf.

  • thresh (float) – Threshold to apply to the TPMs. Default is 0.7.

Returns:

mean_tissue_cbfs – Mean CBF values from binarized versions of the tissue maps.

Return type:

list of float

compute_qei(gm, wm, csf, img, thresh)[source]

Compute quality evaluation index (QEI) of CBF.

The QEI is based on Dolui et al.[1].

References

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 and .

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

jaccard(input1, input2)[source]

Compute Jaccard coefficient between the binary objects in 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 – The Jaccard coefficient between input1 and input2. It ranges from 0 (no overlap) to 1 (perfect overlap).

Return type:

float

negativevoxel(cbf, gm, thresh)[source]

Compute percentage of negative voxels within grey matter mask.

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 .

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

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