Rule-based semi-automated method to segment black hole multiple sclerosis lesions on post-gadolinium 2D T1-weighted brain images.
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 138 lines · 4.5 KB · no license
- #!/usr/bin/env python3
- import warnings
- warnings.simplefilter(action='ignore', category=FutureWarning)
- from scipy import ndimage
- import nibabel as nb
- import numpy as np
- import argparse
- import sys
- import math
- parser = argparse.ArgumentParser(description="Keep only connected components that match specified filter. Default kernel is 6 connections.")
- parser.add_argument("nifti_in", help="Path to input nifti file", type=str)
- parser.add_argument("nifti_out", help="Path to nifti file where largest component should be saved", type=str)
- parser.add_argument('filter', help='Specify pass criterium for connected component size. Use one of > or < followed by number')
- parser.add_argument('--num_connect', help='For 3D: 6, 18, or 26 (default) for 2D: 4 or 8 (default)', type=int, default=None)
- parser.add_argument('--nrvox', help='Use number of voxels instead of volume', action='store_true')
- parser.add_argument('--kernel2D', help='Use a 2D kernel, specify 0,1,2 for direction orthogonal to plane(x,y,z)', type=int, default=-1)
- args = parser.parse_args()
- if (len(args.filter) < 2 ):
- sys.exit('Error: specified filter is too short')
- if args.filter[0] not in '><':
- sys.exit('Error: specified filter should start with > or <')
- else:
- compar=args.filter[0]
- valstr=args.filter[1:]
- if valstr.isdigit():
- val = int(valstr)
- else:
- if args.nrvox:
- sys.exit('Specified volume should be an integer value if also --nrvox is specified')
- else:
- # May crash if not a float
- val = float(valstr)
- im_nii=nb.load(args.nifti_in)
- im=im_nii.get_fdata()
- vox_dims = im_nii.header.get_zooms()
- vox_vol = vox_dims[0] * vox_dims[1] * vox_dims[2]
- # Determine kernel
- if args.kernel2D < 0:
- if not args.num_connect:
- num_connect = 26
- else:
- num_connect = args.num_connect
- if num_connect == 26:
- struct_elem = ndimage.morphology.generate_binary_structure(3,3)
- elif num_connect == 18:
- struct_elem = ndimage.morphology.generate_binary_structure(3,2)
- elif num_connect == 6:
- struct_elem = ndimage.morphology.generate_binary_structure(3,1)
- else:
- sys.exit(f'Specified number of connections not implemented for 3D: {num_connect}')
- else:
- # 2D case
- print('When using 2D, watch out for image orientation')
- if not args.num_connect:
- num_connect = 8
- else:
- num_connect = args.num_connect
- if num_connect == 8:
- struct_elem_2D = ndimage.morphology.generate_binary_structure(2,2)
- elif num_connect == 4:
- struct_elem_2D = ndimage.morphology.generate_binary_structure(2,1)
- else:
- sys.exit(f'Specified number of connections not implemented for 2D: {num_connect}')
- print(struct_elem_2D)
- struct_elem = np.zeros((3,3,3), dtype=bool)
- # Better syntax?
- if args.kernel2D == 0:
- struct_elem[1,:,:] = struct_elem_2D
- elif args.kernel2D == 1:
- struct_elem[:,1,:] = struct_elem_2D
- elif args.kernel2D == 2:
- struct_elem[:,:,1] = struct_elem_2D
- else:
- sys.exit('f{Parameter kernel2D should be 0,1, or 2')
- print(f'vox dimension: {vox_dims}')
- print('2D struct element in 3D:')
- print(struct_elem)
- print(f'Using structure element: f{struct_elem}')
- #conn27 = s = ndimage.generate_binary_structure(3,2)
- #labels, nr_features = ndimage.measurements.label(im, structure=conn27)
- labels, nr_features = ndimage.measurements.label(im, structure=struct_elem)
- unique, counts = np.unique(labels, return_counts=True)
- print(unique, counts)
- labels_to_keep=set()
- if compar == '>':
- if args.nrvox:
- nr_vox = val
- else:
- # With > use floor
- nr_vox = int(math.floor(val / vox_vol))
- print(f'Keeping connected components larger then {nr_vox} voxels')
- for idx, c in enumerate(counts):
- if c > nr_vox:
- labels_to_keep.add(unique[idx])
- elif compar == '<':
- if args.nrvox:
- nr_vox = val
- else:
- # With < use ceil
- nr_vox = int(math.ceil(val / vox_vol))
- print(f'Keeping connected components smaller then {nr_vox} voxels')
- for idx, c in enumerate(counts):
- if c < nr_vox:
- labels_to_keep.add(unique[idx])
- else:
- sys.exit(f'Error: comparision operator not recognized: {compar}')
- # Now set labels we do not want to keep to zero
- all_labels = set(unique[:])
- labels_to_remove = all_labels - labels_to_keep
- print(labels)
- print(labels_to_remove)
- for label in labels_to_remove:
- im[labels==label] = 0
- print(im)
- new_im = nb.Nifti1Image(im, im_nii.affine, im_nii.header)
- nb.save(new_im, args.nifti_out )
conn_component_size_filter.py at commit 6a2da2c, no license · at the source
Overview
- MS Center Amsterdam, Radiology and Nuclear Medicine, Vrije Universiteit Amsterdam, Amsterdam Neuroscience, Amsterdam UMC,Amsterdam, The Netherlands
- Queen Square Institute of Neurology and Centre for Medical Image Computing, University College London,London, UK
Abstract
Objectives: To develop a semi-automated method to segment “black hole” lesions on post-gadolinium 2D T1-weighted images (GdT1) in multiple sclerosis (MS) that follows radiological intensity rules and perform multi-center validation.
Materials and methods: Multi-center spin-echo GdT1 images and accompanying proton-density (PD)/
Results: Optimization resulted in: (1) GM selection as minimally 0.8 total WM plus GM partial volume, masked by MNI cortex; (2) normalized mutual information-driven linear co-registration of T2 to GdT1 images, interpolating T2 lesion masks using trilinear interpolation and 0.6 threshold; (3) mean intensity inside GM mask used as upper intensity threshold. The optimized method had acceptable spatial accuracy (DSC: 0.39 ± 0.26) and good volumetric accuracy (ICC: 0.84, 95% CI [0.72, 0.90]. Lesion-wise sensitivity was 0.91 ± 0.19, and lesion-wise specificity was 0.62 ± 0.22.
Conclusion: The proposed method to semi-automatically segment black holes from post-gadolinium T1-weighted images shows acceptable performance. As a potential aid to radiologists, the method is not recommended to be used entirely without human intervention.
Key Points: Question T1-hypointense “black hole” lesions reflect disease severity in multiple sclerosis but are not routinely quantified due to a lack of reliable analysis methods.
Findings A rule-based semi-automated method for GdT1 “black hole” lesion segmentation was developed and optimized, and then validated in a large unseen multi-center test set.
Clinical relevance This method adds quantitative information about GdT1 “black hole” lesions to the radiological assessment of multiple sclerosis disease severity, when false positives are manually removed. This can enhance the characterization of individual patients and advance the understanding of the disease.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above.
sbig/blackhole_segmentation
6a2da2c5dbfea9110c9bab8de309ff5e7fb59de3, 11 June 2025Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
2 files
- conn_component_size_filt
er.py , Python, 138 lines - README.md, Text, 39 lines
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 1 script, each with its path and the digest of its content;
- no match between paragraphs and code yet;
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 2, 28 September 2026
- Publisher: n/a → Springer Science+Business Media
Version 1, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 5 keywords, 13 MeSH terms, 1 funder, 42 references.
Cite
This paper
Mattiesing, R. M., Groeneveld, F. A., Brouwer, I., van Schijndel, R. A., Barkhof, F., Mutsaerts, H. J. M. M., & Vrenken, H. (2026). Rule-based semi-automated method to segment black hole multiple sclerosis lesions on post-gadolinium 2D T1-weighted brain images. European radiology, 36(9), 7242-7255. https://
BibTeX
@article{mattiesing2026r
author = {Mattiesing, Rozemarijn M. and Groeneveld, Fleur A. and Brouwer, Iman and van Schijndel, Ronald A. and Barkhof, Frederik and Mutsaerts, Henk J. M. M. and Vrenken, Hugo},
title = {{Rule-based semi-automated method to segment black hole multiple sclerosis lesions on post-gadolinium 2D T1-weighted brain images}},
journal = {European radiology},
year = {2026},
month = may,
volume = {36},
number = {9},
pages = {7242--7255},
publisher = {Springer Science+Business Media},
issn = {0938-7994},
doi = {10.1007/
url = {https://
pmid = {42069957},
pmcid = {PMC13451240}
}
RIS
TY - JOUR
AU - Mattiesing, Rozemarijn M.
AU - Groeneveld, Fleur A.
AU - Brouwer, Iman
AU - van Schijndel, Ronald A.
AU - Barkhof, Frederik
AU - Mutsaerts, Henk J. M. M.
AU - Vrenken, Hugo
TI - Rule-based semi-automated method to segment black hole multiple sclerosis lesions on post-gadolinium 2D T1-weighted brain images
T2 - European radiology
J2 - Eur Radiol
PY - 2026
DA - 2026/
VL - 36
IS - 9
SP - 7242
EP - 7255
SN - 0938-7994
PB - Springer Science+Business Media
DO - 10.1007/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1007/
"type": "article-journal",
"title": "Rule-based semi-automated method to segment black hole multiple sclerosis lesions on post-gadolinium 2D T1-weighted brain images",
"container-title": "European radiology",
"author": [
{
"family": "Mattiesing",
"given": "Rozemarijn M."
},
{
"family": "Groeneveld",
"given": "Fleur A."
},
{
"family": "Brouwer",
"given": "Iman"
},
{
"family": "van Schijndel",
"given": "Ronald A."
},
{
"family": "Barkhof",
"given": "Frederik"
},
{
"family": "Mutsaerts",
"given": "Henk J. M. M."
},
{
"family": "Vrenken",
"given": "Hugo"
}
],
"container-title-short":
"volume": "36",
"issue": "9",
"page": "7242-7255",
"DOI": "10.1007/
"PMID": "42069957",
"PMCID": "PMC13451240",
"ISSN": "0938-7994",
"publisher": "Springer Science+Business Media",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
2
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41593-026-02342-9 [code]
- Interpretable abstractions of artificial neural networks predict behavior and neural activity during human information gathering.Journal: Nature neuroscienceIn common: NiBabel, SciPy, NumPy, 4 references
- [2] doi:10.1136/jnnp-2025-335884 [code]
- Diffusivity anisotropy signature of slowly expanding lesions predicts progression independent of relapse activity in multiple sclerosis.Journal: Journal of neurology, neurosurgery, and psychiatryIn common: NiBabel, SciPy, NumPy, multiple sclerosis, structural MRI / diffusion, 2 references
- [3] doi:10.7554/elife.108109 [code]
- Multimodal MRI marker of cognition explains the association between cognition and mental health in the UK Biobank.Journal: eLifeIn common: SciPy, NumPy, structural MRI / diffusion, 4 references
- [4] doi:10.1016/j.nicl.2026.104001 [code]
- Effect of vascular lesion preprocessing on Brain Intensity AbNormality Classification Algorithm (BIANCA) white matter hyperintensity segmentation.Journal: NeuroImage. ClinicalIn common: NiBabel, SciPy, NumPy, structural MRI / diffusion, 2 references
- [5] doi:10.64898/2026.07.15.26357954 [code]
- Portable Ultra-Low Field MRI Deep-Learning Algorithms for White Matter Lesion Segmentation Improve Accuracy and Reflect Clinical Disability in Multiple SclerosisJournal: medRxiv (preprint)In common: NiBabel, SciPy, NumPy, multiple sclerosis, structural MRI / diffusion, 1 reference
- [6] doi:10.1162/imag.a.1183 [code]
- Learning-based segmentation of diffusion-weighted MR images with arbitrary &
lt;i& gt;q& lt;/ i& gt;-space samplings. Journal: Imaging neuroscience (Cambridge, Mass.)In common: NiBabel, SciPy, NumPy, structural MRI / diffusion, 3 references - [7] doi:10.1093/braincomms/fcag129 [code]
- Longitudinal changes of choroid plexus volumes and MRI ratios in multiple sclerosis.Journal: Brain communicationsIn common: NiBabel, SciPy, NumPy, multiple sclerosis, structural MRI / diffusion, 1 reference
- [8] doi:10.3389/fnimg.2026.1873040 [code]
- A rapid streamline-based extension of Tractfinder for white matter tract segmentation.Journal: Frontiers in neuroimagingIn common: SciPy, NumPy, structural MRI / diffusion, 4 references
- [9] doi:10.1038/s41586-026-10345-6 [code]
- Population-scale repeat expansions elucidate disease risk and brain atrophy.Journal: NatureIn common: SciPy, NumPy, structural MRI / diffusion, 3 references
- [10] doi:10.1073/pnas.2603114123 [code]
- The human hippocampus can pattern separate memories by meaning.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: NiBabel, SciPy, NumPy, 3 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 1 script, and 0 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:5ce25901c36f858d…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[.
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
