Abstract
White matter hyperintensities (WMH) are a hallmark of cerebrovascular disease and multiple sclerosis. Automated WMH segmentation methods enable quantitative analysis via estimation of total lesion load, spatial distribution of lesions, and number of lesions (i.e., number of connected components after thresholding), all of which are correlated with patient outcomes. While the two former measures can generally be estimated robustly, the number of lesions is highly sensitive to noise and segmentation mistakes – even when small connected components are eroded or disregarded. In this article, we present P-Count, an algebraic WMH counting tool based on persistent homology that accounts for the topological features of WM lesions in a robust manner. Using computational geometry, P-Count takes the persistence of connected components into consideration, effectively filtering out the noisy WMH positives, resulting in a more accurate count of true lesions. We validated P-Count on the ISBI2015 longitudinal lesion segmentation dataset, where it produces significantly more accurate results than direct thresholding.
Keywords: White matter lesion, Persistent homology, Multiple sclerosis
1. Introduction
White matter hyperintensities (WMH) are lesions that appear hyperintense on FLAIR MRI scans. WMH have many possible causes [3], but the two most common are multiple sclerosis (MS) [25] and vascular disorders causing small vessel disease, often leading to stroke [38]. Furthermore, WMH have also been found to be associated with cognitive impairment and Alzheimer’s disease (AD) [1]. Therefore, accurate quantification of WMH is valuable for the clinical assessment of these diseases and evaluation of potential treatment effect.
Automated lesion segmentation is a key preprocessing step for reproducible, quantitative analysis of WMH – particularly at large scale. Many image segmentation methods have been proposed for WMH. Representative classical methods include: BIANCA [19], which relies on k-nearest neighbor classification; LST-LGA[31], which uses a lesion growth algorithm; LST-LPA [30], which uses supervised logistic regression; atlas-based methods like Lesion-TOADS [32]; dictionary learning algorithms [39]; or unsupervised Bayesian methods that are contrast-adaptive and rely on outlier detection [37], such as BaMoS [33] or SAMSEG-lesion [9].
As in most medical image analysis domains, classical methods have been superseded by deep learning approaches [27]. Many of these methods rely on convolutional neural networks (CNNs) trained in a supervised fashion [6] – possibly equipped with enhancements like positional encoding [18], dedicated patch sampling strategies [20], ensembles [28,26], boundary losses to combat the large class imbalance [23], or longitudinal strategies for jointly exploiting information from multiple timepoints and detect changes [36,24,17]. Attempts have also been made to combine CNNs with ideas from the classical Bayesian literature to achieve resilience against changes in pulse sequence and image resolution [4].
Given segmentations, one can compute several quantitative metrics of interest, which are associated with patient outcomes. One such metric is the total lesion load (also known as lesion burden), which corresponds to the total amount of volume segmented as WMH – typically computed from soft segmentations, i.e., by weighting the volume of each voxel by the lesion probability estimated by the automated algorithm at the given location. Lesion load has been shown to correlate with long-term outcomes in MS [29] and stroke [16]. Another important feature of WMH is their spatial distribution. For example, the widespread Fazekas score for grading the amount of WHM in small vessel disease divides lesions into periventricular vs deep white matter [14].
Another metric of interest that can be computed from WMH segmentations is the number of lesions. The appearance of new lesions (or enlargement of existing ones) is used to track the progression of MS in clinical practice, and has been shown to be predictive of disability [7,35,34]. However, counting lesions is an inherently difficult problem, with moderate inter-rater agreement [5,2,41]. While automated segmentation has the potential to curb this variability, counting lesions from a probabilistic segmentation in a robust fashion is not trivial. The standard approach consists of thresholding the lesion probability maps, computing connected components, and removing the smallest components (e.g., less than 3mm in the major axis [15]) – either by erosion or by volume thresholding (e.g., volumes under 10mm3). However, the lesion count is highly sensitive to the choice of threshold, as connected components are created (by splitting) and destroyed as the threshold increases (see Fig. 1). As the experiments below show, this lack of robustness leads to highly variable lesion counts – which is particularly problematic in longitudinal data, as they obscure the real WMH progression.
Fig. 1.

Motivation for P-Count: lesion counting from an MRI scan (a) based on direct thresholding of the soft probability map (b) is usually noisy and highly sensitive to the choice of the threshold (c,d).
In this article, we present P-Count, a novel method for robust lesion count using persistent homology (PH) [13,12]. PH is a topological data analysis tool that has been applied to image segmentation of objects of known topology, both in medical (e.g., vessels, membranes, heart chambers [40,21,22,11]) and natural images [10]. Rather than leveraging PH in a supervised CNN as previous works, here we use it in an unsupervised fashion, to capture the full set of topological changes of the WMH probability map as a function of the threshold. This enables us to count lesions without having to explicitly threshold the probabilities, thus providing more robust estimates.
2. Methods
Our key innovation is to leverage the power of PH to count the number of lesions accurately. This is achieved through the insight that PH is robust to noisy information and able to capture the true signals effectively.
2.1. Persistence-based Counting
We first review the classical watershed algorithm for image segmentation, which is the basis of the proposed method.
Watershed algorithm.
By leveraging topographic information, the watershed algorithm divides a 2D/3D image into separated segments. It essentially treats the image as a terrain function (See Fig. 2(a) for a 1D illustration), and identifies basins based on pixel/voxel intensity. Starting from local minima, the “catchment” basins fill up until region boundaries are reached. Each basin is then labeled as a separate region (c1 and c2 in Fig. 2(a)), defining one single class / connected component.
Fig. 2.

Illustration of the proposed P-Count. (a) Illustration of the watershed algorithm in 1D. As basins fill up, each is associated with a “lifetime”. (b) Changes in connected components are captured by the persistence diagram as the threshold increases.
The result of the classical watershed algorithm relies heavily on the local minima. For example, c1 and c2 are both counted as valid connected components (i.e., lesions, in our context), regardless of the possibility that they may be noise. This poses significant challenges when quantifying lesions based on the segmentation algorithm, as every individual local minimum will be included in the count, irrespective of their size or persistence as the threshold varies.
To overcome this issue, we propose to leverage the tool of PH to capture the true lesion signals by suppressing the noisy ones. Specifically: instead of counting all the local minima, we seek to distinguish the ‘real’ lesions from noise based on persistence under a progressively increasing threshold. Fig. 2(a) shows an example of our intuition in 1D. Every basin/component is associated with a “lifetime” (μ1 for c1, μ2 for c2), which is a good indicator of how likely a connected component is to be a real lesion or not. Our method P-Count leverages PH to address the issue. This is achieved by considering the persistence of connected components, effectively filtering out the noisy WMH positives, thus resulting in a more accurate count of true lesions.
Persistence-based counting.
For each soft probability map, we use a persistence diagram to capture the changes of the topological structure, as illustrated in Fig.2(b). Each dot in the persistence diagram corresponds to one single connected component, existing at a certain range of threshold values. To distinguish the ‘real’ lesions from noise, we would like to decompose a diagram into ‘lesion’ and ‘noise’ parts.
For a connected component, which corresponds to one dot in the persistence diagram, its lifetime is the persistence of the corresponding dot, i.e., the difference between its death and birth time: per(p) = death(p) – birth(p). And the ‘persistence’ of a dot in Fig. 2(b) is truly the lifetime (μ1 and μ2) in Fig. 2(a). Persistence is a good metric indicating how likely a connected component is to be a real lesion or not: the greater the persistence, the longer the connected component exists through the whole “filtration”, and the more likely the connected component is a real ‘lesion’. In contrast, the connected components with low persistence are more likely to be ‘noise’.
As a result, we can filter out the real lesions based on the persistence using a predetermined threshold θ. Driven by this, we propose a novel algorithm called P-Count for white matter hyperintensities in brain MRI. The details are illustrated in Alg. 1. As we show in the experiments below, the proposed persistence-based counting algorithm is more robust and results in more accurate counting, especially for noisy inputs. The results also show that the choice of threshold: (i) has a much lesser impact on the variability of the lesion count than a threshold taken directly on the probability maps; and (ii) has very little impact on the longitudinal counts.
Algorithm 1:
P-Count
| Input: A 3D soft lesion probability map, and a threshold θ |
| Output: Number of lesions |
| Definition: G = (V, E) denote a graph; f(v) is the intensity value of node v; ; is the connected component id of node v. |
| 1: ; Build the proximity graph (6-connectivity) for 3D image; |
| 2: sorted according to f(v); T a sub-graph, which includes all the nodes and edges whose value < t. |
| 3: for v in U do |
| 4: , |
| 5: for (u, v) in do |
| 5: Assert |
| 6: if then |
| 6: Continue |
| 7: else |
| 7: |
| 7: |
| 7: |
| 8: if then |
| 9: for w in do |
| 9: |
| 10: end for |
| 11: end if |
| 11: |
| 12: end if |
| 13: end for |
| 14: end for |
| 15: return # of lesions = len(cc). |
2.2. Optimal threshold selection
Let us assume the availability of N training samples, and that the i-th sample has Ti time points. For a set of thresholds {θj}, sample i has yij1, yij2, …, yijTi number of lesions for time point 1, 2, …, Ti, respectively. The optimal value of threshold depends on the dataset. To find this optimal value, we propose a supervised and an unsupervised approach, depending on whether ground truth labels are available for some scans or not.
Supervised approach.
If ground truth labels are given, we use a supervised approach to select the optimal θ. Let’s use to denote the ground truth number of lesions for sample i at time point 1, 2, …, Ti, respectively. Then, we simply pick the threshold that minimizes the sum of absolute errors over all time points of all training samples:
| (1) |
Unsupervised approach.
If ground truth labels are not available, we utilize an unsupervised method to find the optimal θ. Specifically, we fit a linear model to the number of lesions over time. For sample i under a specific threshold θj, we have:
| (2) |
where is the regressed number of lesions at threshold j, time point t for sample i and ϵijt models the errors. We use least squares (L2 norm) to fit the linear curve. Different from the supervised setting, we minimize the following term:
| (3) |
The optimal θ can be found through Eq. (1) or Eq. (3) under supervised or unsupervised settings, respectively. The optimal θ is then applied to the test set.
3. Experiments and Results
Datasets.
To validate the effectiveness of the proposed method, we use the training subset of a longitudinal, multi-modality dataset of WMH (ISBI15 [8]), for which manual longitudinal segmentations are available. Each subject has 4 or 5 timepoints. We used the FLAIR scans, resampled to 1mm isotropic resolution – which is the native resolution of the manual segmentations.
Automated segmentation.
We used SAMSEG-lesion [9] as the automated segmentation method to obtain the soft probabilities from the original scans. We used SAMSEG-lesion because it’s adaptive to contrast and therefore generalizes very well to ISBI2015. The output was a soft segmentation of WMH at 1mm isotropic resolution.
Implementation details.
Our algorithm is computationally expensive, due to the need to monitor connected components at small threshold increases. To reduce its computational burden, we aggressively crop the imaging volumes around the brain, and downsample them to 2mm × 2mm × 2mm resolution. This yields volumes of approximately 40 × 80 × 40 voxels, which allows our Python implementation to process a volume in approximately 50sec on a modern desktop.
Baseline.
We use direct thresholding (which is the current standard in clinical practice) as the baseline to show the effectiveness of the proposed method. Specifically, we do direct thresholding on the obtained soft probability map, and then count the number of connected components to obtain the number of lesions. We note that we do not remove small components as the voxel size is 8mm3 which is approximately equal to the threshold suggested in [16].
Evaluation.
For the baseline method, we gradually increase the threshold from 0.1 to 1 (step size is 0.1), and plot the resulting lesion count vs time curves. For the proposed P-Count method, we similarly increase the persistence threshold (θ in Alg. 1) from 0 to 0.04 (step size is 0.004) to plot the same curves. To evaluate the algorithm quantitatively, we studied the absolute error in lesion count with respect to the ground truth, computed with five-fold cross-validation.
Results.
Fig. 3 shows the temporal evolution of the number of lesions for two sample subjects in the dataset (Subjects 2 and 4), while Tab. 1 shows the average errors in lesion counts, for the supervised and unsupervised choices of threshold.
Fig. 3.

Lesion count vs time for Subjects 2 and 4 of ISBI2015 using different thresholds (purple=more liberal; red=more conservative), for direct thresholding and P-Count. The thick red line corresponds to the ground truth count derived from manual segmentations.
Table 1.
Mean absolute errors for lesion count (in number of lesions). The p-values are for two-tailed t-tests comparing the error rates of P-Count and direct thresholding.
| Method | Mean absolute errors | p-value |
|---|---|---|
| Direct thresholding - Unsupervised | 43.19 | |
| P-Count - Unsupervised | 16.81 | 3.48 * 10−5 |
|
| ||
| Direct thresholding - Supervised | 26.86 | |
| P-Count - Supervised | 19.14 | 1.07 * 10−3 |
Qualitatively speaking, Fig. 3 illustrates two major advantages of P-Count with respect to the baseline. First, and most obvious: the error in the lesion count is much lower. This is also apparent from Tab. 1, with strongly significant reductions in the error rate (despite the small sample size) – particularly for the unsupervised approach. The second improvement is the much lower dependence on the threshold. Direct thresholding of probability maps is very noisy, as illustrated in Fig. 4(a), which leads to a wide range of trajectories in Fig. 3(a) and Fig. 3(c). This variability is also noticeable in Tab. 1, where the thresholds obtained by the supervised and unsupervised approaches yield very different error rates (one almost as twice as the other). Our method, on the other one, thresholds the persistence, yielding curves that are much closer to each other (Figs. 3(b) and 3(d)), segmentations closer to the ground truth (Fig. 4(b)), and errors that are less dependent on the chosen method to determine the threshold (Tab. 1).
Fig. 4.

3D rendering of WMH for a sample subject. (a) Direct thresholding. (b) P-Count. (c) Ground truth. We note that a segmentation like (b) cannot be obtained by thresholding the probability map at any level, as it is based on persistence.
4. Conclusion
We have presented P-Count, a PH method for counting WMH that accounts for their topological features in a robust manner. P-Count yields much lower errors than the standard thresholding currently used in clinical practice. P-Count also has limitations, notably its high computational complexity; future work will seek to address this issue. We believe that P-Count has great potential in increasing the accuracy of WMH quantification for the clinical assessment of several diseases and for the evaluation of the effect of treatments.
Acknowledgement
Supported by NIH grants 1RF1MH123195, 1R01AG070988, 1RF1AG080371, 1UM1MH130981. OP was supported by a grant from Lundbeckfonden (grant number R360–2021–395).
References
- 1.Alber J, Alladi S, Bae HJ, et al. : White matter hyperintensities in vascular contributions to cognitive impairment and dementia (VCID): Knowledge gaps and opportunities. Alzheimer’s & Dementia: Translational Research & Clinical Interventions (2019) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 2.Barkhof F, Filippi M, Waesberghe V, et al. : Interobserver agreement for diagnostic MRI criteria in suspected multiple sclerosis. Neuroradiology (1999) [DOI] [PubMed] [Google Scholar]
- 3.Barkhof F, Scheltens P: Imaging of white matter lesions. Cerebrovascular Diseases (2002) [DOI] [PubMed] [Google Scholar]
- 4.Billot B, Cerri S, Leemput V, et al. : Joint segmentation of multiple sclerosis lesions and brain anatomy in MRI scans of any contrast and resolution with CNNs. In: ISBI; (2021) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Bozsik B, Tóth E, Polyák I, et al. : Reproducibility of lesion count in various subregions on MRI scans in multiple sclerosis. Frontiers in Neurology (2022) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Brosch T, Tang LY, Yoo Y, et al. : Deep 3D convolutional encoder networks with shortcuts for multiscale feature integration applied to multiple sclerosis lesion segmentation. TMI; (2016) [DOI] [PubMed] [Google Scholar]
- 7.Calabrese M, Poretto V, Favaretto A, et al. : Cortical lesion load associates with progression of disability in multiple sclerosis. Brain (2012) [DOI] [PubMed] [Google Scholar]
- 8.Carass A, Roy S, Jog A, et al. : Longitudinal multiple sclerosis lesion segmentation: resource and challenge. NeuroImage (2017) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.Cerri S, Puonti O, Meier DS, et al. : A contrast-adaptive method for simultaneous whole-brain and lesion segmentation in multiple sclerosis. Neuroimage (2021) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10.Chazal F, Guibas LJ, Oudot SY, et al. : Persistence-based clustering in riemannian manifolds. Journal of the ACM (2013) [Google Scholar]
- 11.Clough JR, Byrne N, Oksuz I, et al. : A topological loss function for deep-learning based image segmentation using persistent homology. TPAMI; (2020) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Edelsbrunner H, Harer J, et al. : Persistent homology – a survey. Contemporary mathematics (2008) [Google Scholar]
- 13.Edelsbrunner H, Letscher D, Zomorodian A: Topological persistence and simplification. In: FOCS; (2000) [Google Scholar]
- 14.Fazekas F, Chawluk JB, Alavi A, et al. : MR signal abnormalities at 1.5 T in Alzheimer’s dementia and normal aging. American Journal of Neuroradiology (1987) [DOI] [PubMed] [Google Scholar]
- 15.Filippi M, Preziosa P, Banwell BL, et al. : Assessment of lesions on magnetic resonance imaging in multiple sclerosis: practical guidelines. Brain (2019) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16.Georgakis MK, Duering M, Wardlaw JM, et al. : WMH and long-term outcomes in ischemic stroke: a systematic review and meta-analysis. Neurology (2019) [DOI] [PubMed] [Google Scholar]
- 17.Gessert N, Krüger J, Opfer R, et al. : Multiple sclerosis lesion activity segmentation with attention-guided two-path cnns. Computerized Medical Imaging and Graphics 84, 101772 (2020) [DOI] [PubMed] [Google Scholar]
- 18.Ghafoorian M, Karssemeijer N, Heskes T, et al. : Location sensitive deep convolutional neural networks for segmentation of white matter hyperintensities. Scientific Reports (2017) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19.Griffanti L, Zamboni G, Khan A, et al. : BIANCA (Brain Intensity AbNormality Classification Algorithm): A new tool for automated segmentation of white matter hyperintensities. Neuroimage (2016) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20.Guerrero R, Qin C, Oktay O, et al. : White matter hyperintensity and stroke lesion segmentation and differentiation using convolutional neural networks. NeuroImage: Clinical (2018) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21.Hu X, Li F, Samaras D, et al. : Topology-preserving deep image segmentation. NeurIPS; (2019) [Google Scholar]
- 22.Hu X, Wang Y, Fuxin L, et al. : Topology-aware segmentation using discrete morse theory. ICLR; (2021) [PMC free article] [PubMed] [Google Scholar]
- 23.Kervadec H, Bouchtiba J, Desrosiers C, et al. : Boundary loss for highly unbalanced segmentation. In: MIDL; (2019) [DOI] [PubMed] [Google Scholar]
- 24.Krüger J, Opfer R, Gessert N, et al. : Fully automated longitudinal segmentation of new or enlarged multiple sclerosis lesions using 3D convolutional neural networks. NeuroImage: Clinical (2020) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 25.Lassmann H: Multiple sclerosis pathology. Cold Spring Harbor perspectives in medicine (2018) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 26.Li H, Jiang G, Zhang J, et al. : Fully convolutional network ensembles for white matter hyperintensities segmentation in MR images. NeuroImage (2018) [DOI] [PubMed] [Google Scholar]
- 27.Ma Y, Zhang C, Cabezas M, et al. : Multiple sclerosis lesion analysis in brain magnetic resonance images: techniques and clinical applications. JBHI; (2022) [DOI] [PubMed] [Google Scholar]
- 28.Manjón JV, Coupé P, Raniga P, et al. : MRI white matter lesion segmentation using an ensemble of neural networks and overcomplete patch-based voting. Computerized Medical Imaging and Graphics (2018) [DOI] [PubMed] [Google Scholar]
- 29.Popescu V, Agosta F, Hulst HE, et al. : Brain atrophy and lesion load predict long term disability in multiple sclerosis. Journal of Neurology, Neurosurgery & Psychiatry (2013) [DOI] [PubMed] [Google Scholar]
- 30.Schmidt P: Bayesian inference for structured additive regression models for large-scale problems with applications to medical imaging. Ph.D. thesis, lmu; (2017) [Google Scholar]
- 31.Schmidt P, Gaser C, Arsic M, et al. : An automated tool for detection of flair-hyperintense white-matter lesions in multiple sclerosis. Neuroimage (2012) [DOI] [PubMed] [Google Scholar]
- 32.Shiee N, Bazin PL, Ozturk A, et al. : A topology-preserving approach to the segmentation of brain images with multiple sclerosis lesions. NeuroImage (2010) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 33.Sudre CH, Cardoso MJ, Bouvy WH, et al. : Bayesian model selection for pathological neuroimaging data applied to white matter lesion segmentation. TMI; (2015) [DOI] [PubMed] [Google Scholar]
- 34.Treaba CA, Granberg TE, Sormani MP, et al. : Longitudinal characterization of cortical lesion development and evolution in multiple sclerosis with 7.0-T MRI. Radiology (2019) [DOI] [PMC free article] [PubMed] [Google Scholar]
- 35.Uher T, Vaneckova M, Sobisek L, et al. : Combining clinical and magnetic resonance imaging markers enhances prediction of 12-year disability in multiple sclerosis. Multiple Sclerosis Journal (2017) [DOI] [PubMed] [Google Scholar]
- 36.Vaidya S, Chunduru A, Muthuganapathy R, et al. : Longitudinal multiple sclerosis lesion segmentation using 3D convolutional neural networks. Proceedings of the 2015 longitudinal multiple sclerosis lesion segmentation challenge (2015) [Google Scholar]
- 37.Van Leemput K, Maes F, Vandermeulen D, et al. : Automated segmentation of multiple sclerosis lesions by model outlier detection. TMI; (2001) [DOI] [PubMed] [Google Scholar]
- 38.Vermeer SE, Hollander M, van Dijk EJ, et al. : Silent brain infarcts and white matter lesions increase stroke risk in the general population: the rotterdam scan study. Stroke (2003) [DOI] [PubMed] [Google Scholar]
- 39.Weiss N, Rueckert D, Rao A: Multiple sclerosis lesion segmentation using dictionary learning and sparse coding. In: MICCAI; (2013) [DOI] [PubMed] [Google Scholar]
- 40.Wu P, Chen C, Wang Y, et al. : Optimal topological cycles and their application in cardiac trabeculae restoration. In: MICCAI; (2017) [Google Scholar]
- 41.Zipoli V, Portaccio E, Siracusa G, et al. : Interobserver agreement on Poser’s and the new McDonald’s diagnostic criteria for multiple sclerosis. Multiple Sclerosis Journal (2003) [DOI] [PubMed] [Google Scholar]
