Skip to content

correction

correction

Leakage correction for DSC-MRI (OSIPI: P.LC1.001).

This module implements the Boxerman-Schmainda-Weisskoff (BSW) method (OSIPI: M.LC1.001) for correcting contrast agent leakage effects in DSC-MRI. The correction estimates leakage coefficients K1 (OSIPI: Q.LC1.001) and K2 (OSIPI: Q.LC1.002) to separate intravascular from extravascular signal contributions.

GPU/CPU agnostic using the xp array module pattern. NO scipy dependency.

References

.. [1] OSIPI CAPLEX, https://osipi.github.io/OSIPI_CAPLEX/ .. [2] Boxerman JL, Schmainda KM, Weisskoff RM (2006). Relative cerebral blood volume maps corrected for contrast agent extravasation significantly correlate with glioma tumor grade, whereas uncorrected maps do not. AJNR Am J Neuroradiol 27(4):859-867. .. [3] Paulson ES, Schmainda KM (2008). Comparison of dynamic susceptibility- weighted contrast-enhanced MR methods: recommendations for measuring relative cerebral blood volume in brain tumors. Radiology 249(2):601-613. .. [4] Dickie BR et al. MRM 2024. doi:10.1002/mrm.30101

LeakageCorrectionParams dataclass

LeakageCorrectionParams(
    method="bsw",
    use_t1_correction=True,
    use_t2_correction=True,
    reference_tissue="white_matter",
    custom_reference_mask=None,
    fitting_range=None,
)

Parameters for leakage correction.

ATTRIBUTE DESCRIPTION
method

Correction method: 'bsw' (Boxerman-Schmainda-Weisskoff) or 'bidirectional'.

TYPE: str

use_t1_correction

Include T1 leakage correction (default True).

TYPE: bool

use_t2_correction

Include T2* leakage correction (default True).

TYPE: bool

reference_tissue

Reference tissue type: 'white_matter', 'normal_brain', or 'custom'.

TYPE: str

custom_reference_mask

Custom mask for reference tissue (if reference_tissue='custom').

TYPE: NDArray | None

fitting_range

Time frame range for fitting. If None, uses full range.

TYPE: tuple[int, int] | None

LeakageCorrectionResult dataclass

LeakageCorrectionResult(
    corrected_delta_r2,
    k1,
    k2,
    reference_curve,
    residual=None,
)

Result of leakage correction (OSIPI: P.LC1.001).

ATTRIBUTE DESCRIPTION
corrected_delta_r2

Leakage-corrected delta-R2* curves.

TYPE: NDArray

k1

T1 leakage coefficient K1 (OSIPI: Q.LC1.001) map.

TYPE: NDArray

k2

T2* leakage coefficient K2 (OSIPI: Q.LC1.002) map.

TYPE: NDArray

reference_curve

Reference tissue delta-R2* curve used for correction.

TYPE: NDArray

residual

Fitting residuals.

TYPE: NDArray | None

BSWCorrector

Bases: BaseLeakageCorrector

Boxerman-Schmainda-Weisskoff leakage correction (OSIPI: M.LC1.001).

Estimates K1 (OSIPI: Q.LC1.001) and K2 (OSIPI: Q.LC1.002) leakage coefficients via linear regression against the AIF.

name property

name

Return human-readable component name.

reference property

reference

Return primary literature citation.

correct

correct(delta_r2, aif, time, mask=None, **kwargs)

Perform BSW leakage correction (OSIPI: P.LC1.001).

BidirectionalCorrector

Bases: BaseLeakageCorrector

Bidirectional leakage correction strategy.

name property

name

Return human-readable component name.

reference property

reference

Return primary literature citation.

correct

correct(delta_r2, aif, time, mask=None, **kwargs)

Perform bidirectional leakage correction.

correct_leakage

correct_leakage(
    delta_r2, aif, time, mask=None, params=None
)

Apply leakage correction to DSC-MRI data (OSIPI: P.LC1.001).

The Boxerman-Schmainda-Weisskoff method (OSIPI: M.LC1.001) models the observed delta-R2* as a combination of intravascular and extravascular contributions:

dR2*(t) = K1 * Ca(t) + K2 * integral(Ca(tau) dtau)

where Ca is the AIF, K1 (OSIPI: Q.LC1.001) represents T1 leakage (positive for enhancement) and K2 (OSIPI: Q.LC1.002) represents T2* leakage (positive for signal loss).

PARAMETER DESCRIPTION
delta_r2

Uncorrected delta-R2* data, shape (..., n_timepoints).

TYPE: NDArray[floating]

aif

Arterial input function (delta-R2* or concentration).

TYPE: NDArray[floating]

time

Time points in seconds.

TYPE: NDArray[floating]

mask

Brain mask, shape (...).

TYPE: NDArray[bool_] | None DEFAULT: None

params

Correction parameters.

TYPE: LeakageCorrectionParams | None DEFAULT: None

RETURNS DESCRIPTION
LeakageCorrectionResult

Corrected delta-R2* and leakage coefficients.

RAISES DESCRIPTION
DataValidationError

If input data is invalid.

References

.. [1] OSIPI CAPLEX, https://osipi.github.io/OSIPI_CAPLEX/ .. [2] Dickie BR et al. MRM 2024. doi:10.1002/mrm.30101

Examples:

>>> import numpy as np
>>> from osipy.dsc.leakage import correct_leakage
>>> delta_r2 = np.random.rand(64, 64, 20, 60) * 10
>>> aif = np.random.rand(60) * 5
>>> time = np.linspace(0, 90, 60)
>>> result = correct_leakage(delta_r2, aif, time)

estimate_permeability

estimate_permeability(k1, k2)

Estimate permeability from leakage coefficients.

The K2 coefficient is related to the permeability-surface area product (PS) of the blood-brain barrier.

PARAMETER DESCRIPTION
k1

T1 leakage coefficient.

TYPE: NDArray

k2

T2* leakage coefficient.

TYPE: NDArray

RETURNS DESCRIPTION
NDArray

Estimated permeability (arbitrary units).