OSCR

Rule-based semi-automated method to segment black hole multiple sclerosis lesions on post-gadolinium 2D T1-weighted brain images.

Code ↔ Paper

The paper beside its authors' code: matches between them have not been computed for this paper yet.

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

  1. #!/usr/bin/env python3
  2. import warnings
  3. warnings.simplefilter(action='ignore', category=FutureWarning)
  4. from scipy import ndimage
  5. import nibabel as nb
  6. import numpy as np
  7. import argparse
  8. import sys
  9. import math
  10. parser = argparse.ArgumentParser(description="Keep only connected components that match specified filter. Default kernel is 6 connections.")
  11. parser.add_argument("nifti_in", help="Path to input nifti file", type=str)
  12. parser.add_argument("nifti_out", help="Path to nifti file where largest component should be saved", type=str)
  13. parser.add_argument('filter', help='Specify pass criterium for connected component size. Use one of > or < followed by number')
  14. parser.add_argument('--num_connect', help='For 3D: 6, 18, or 26 (default) for 2D: 4 or 8 (default)', type=int, default=None)
  15. parser.add_argument('--nrvox', help='Use number of voxels instead of volume', action='store_true')
  16. 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)
  17. args = parser.parse_args()
  18. if (len(args.filter) < 2 ):
  19. sys.exit('Error: specified filter is too short')
  20. if args.filter[0] not in '><':
  21. sys.exit('Error: specified filter should start with > or <')
  22. else:
  23. compar=args.filter[0]
  24. valstr=args.filter[1:]
  25. if valstr.isdigit():
  26. val = int(valstr)
  27. else:
  28. if args.nrvox:
  29. sys.exit('Specified volume should be an integer value if also --nrvox is specified')
  30. else:
  31. # May crash if not a float
  32. val = float(valstr)
  33. im_nii=nb.load(args.nifti_in)
  34. im=im_nii.get_fdata()
  35. vox_dims = im_nii.header.get_zooms()
  36. vox_vol = vox_dims[0] * vox_dims[1] * vox_dims[2]
  37. # Determine kernel
  38. if args.kernel2D < 0:
  39. if not args.num_connect:
  40. num_connect = 26
  41. else:
  42. num_connect = args.num_connect
  43. if num_connect == 26:
  44. struct_elem = ndimage.morphology.generate_binary_structure(3,3)
  45. elif num_connect == 18:
  46. struct_elem = ndimage.morphology.generate_binary_structure(3,2)
  47. elif num_connect == 6:
  48. struct_elem = ndimage.morphology.generate_binary_structure(3,1)
  49. else:
  50. sys.exit(f'Specified number of connections not implemented for 3D: {num_connect}')
  51. else:
  52. # 2D case
  53. print('When using 2D, watch out for image orientation')
  54. if not args.num_connect:
  55. num_connect = 8
  56. else:
  57. num_connect = args.num_connect
  58. if num_connect == 8:
  59. struct_elem_2D = ndimage.morphology.generate_binary_structure(2,2)
  60. elif num_connect == 4:
  61. struct_elem_2D = ndimage.morphology.generate_binary_structure(2,1)
  62. else:
  63. sys.exit(f'Specified number of connections not implemented for 2D: {num_connect}')
  64. print(struct_elem_2D)
  65. struct_elem = np.zeros((3,3,3), dtype=bool)
  66. # Better syntax?
  67. if args.kernel2D == 0:
  68. struct_elem[1,:,:] = struct_elem_2D
  69. elif args.kernel2D == 1:
  70. struct_elem[:,1,:] = struct_elem_2D
  71. elif args.kernel2D == 2:
  72. struct_elem[:,:,1] = struct_elem_2D
  73. else:
  74. sys.exit('f{Parameter kernel2D should be 0,1, or 2')
  75. print(f'vox dimension: {vox_dims}')
  76. print('2D struct element in 3D:')
  77. print(struct_elem)
  78. print(f'Using structure element: f{struct_elem}')
  79. #conn27 = s = ndimage.generate_binary_structure(3,2)
  80. #labels, nr_features = ndimage.measurements.label(im, structure=conn27)
  81. labels, nr_features = ndimage.measurements.label(im, structure=struct_elem)
  82. unique, counts = np.unique(labels, return_counts=True)
  83. print(unique, counts)
  84. labels_to_keep=set()
  85. if compar == '>':
  86. if args.nrvox:
  87. nr_vox = val
  88. else:
  89. # With > use floor
  90. nr_vox = int(math.floor(val / vox_vol))
  91. print(f'Keeping connected components larger then {nr_vox} voxels')
  92. for idx, c in enumerate(counts):
  93. if c > nr_vox:
  94. labels_to_keep.add(unique[idx])
  95. elif compar == '<':
  96. if args.nrvox:
  97. nr_vox = val
  98. else:
  99. # With < use ceil
  100. nr_vox = int(math.ceil(val / vox_vol))
  101. print(f'Keeping connected components smaller then {nr_vox} voxels')
  102. for idx, c in enumerate(counts):
  103. if c < nr_vox:
  104. labels_to_keep.add(unique[idx])
  105. else:
  106. sys.exit(f'Error: comparision operator not recognized: {compar}')
  107. # Now set labels we do not want to keep to zero
  108. all_labels = set(unique[:])
  109. labels_to_remove = all_labels - labels_to_keep
  110. print(labels)
  111. print(labels_to_remove)
  112. for label in labels_to_remove:
  113. im[labels==label] = 0
  114. print(im)
  115. new_im = nb.Nifti1Image(im, im_nii.affine, im_nii.header)
  116. nb.save(new_im, args.nifti_out )

conn_component_size_filter.py at commit 6a2da2c, no license · at the source

Overview

Authors: Rozemarijn M. Mattiesing1, Fleur A. Groeneveld1, Iman Brouwer1, Ronald A. van Schijndel1, Frederik Barkhof1,2, Henk J. M. M. Mutsaerts1, Hugo Vrenken1
  1. MS Center Amsterdam, Radiology and Nuclear Medicine, Vrije Universiteit Amsterdam, Amsterdam Neuroscience, Amsterdam UMC,Amsterdam, The Netherlands
  2. Queen Square Institute of Neurology and Centre for Medical Image Computing, University College London,London, UK
Institutions: Vrije Universiteit Amsterdam (Netherlands); University College London (United Kingdom)
Journal: European radiology, volume 36, issue 9, pages 7242-7255
Dates: received 17 June 2025; accepted 4 April 2026; published online 2 May 2026; in print 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1007/s00330-026-12577-6 · PMID 42069957 · PMCID PMC13451240 · OpenAlex W7159987368
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: structural MRI / diffusion (modality), human (organism), multiple sclerosis (population)
Methods: Connectivity, Statistics
Keywords: Brain, Computer-assisted, Image processing, Magnetic resonance imaging, Multiple sclerosis
MeSH: Brain*, Gadolinium*, Image Interpretation, Computer-Assisted*, Magnetic Resonance Imaging*, Multiple Sclerosis*, Adult, Algorithms, Contrast Media, Female, Humans, Male, Reproducibility of Results, Sensitivity and Specificity (* major topic)
Journal subjects: Neuro
Topic: Multiple Sclerosis Research Studies (Pathology and Forensic Medicine, Medicine), according to OpenAlex
Funding: Merck (CrossRef Funder ID: 10.13039/100009945) (NA)
Citations: not cited yet (Europe PMC); 42 references in the paper

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)/T2-weighted images and manual T2 lesion masks of the REFLEXION study (NCT00813709) of suspected/early MS were used. Briefly, the proposed method segments cortical gray matter (GM) to derive a T1-weighted intensity threshold, which is applied inside co-registered T2 lesion masks to segment black hole lesion voxels. It was optimized on a training set (N = 40, 57.5% female, mean age 31.4 ± 8.7 (standard deviation) years), and 274 patients formed the test set (61.3% female, age 31.8 ± 8.4 years). Performance was quantified by the Dice similarity coefficient (DSC) and the intraclass correlation coefficient (ICC) for absolute agreement with manual segmentations. Lesion-wise sensitivity and specificity were calculated.

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

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 6a2da2c5dbfea9110c9bab8de309ff5e7fb59de3, 11 June 2025
Languages: Python (1)
Size: 5 files, 1 script
Software Heritage: not archived
Found in: the text, “Brief overview”
Holds: README, environment (requirements.txt)
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: NiBabel (1 file), NumPy (1 file), SciPy (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
2 files

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://doi.org/10.1007/s00330-026-12577-6

BibTeX

@article{mattiesing2026rule,
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/s00330-026-12577-6},
url = {https://doi.org/10.1007/s00330-026-12577-6},
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/05/02
VL - 36
IS - 9
SP - 7242
EP - 7255
SN - 0938-7994
PB - Springer Science+Business Media
DO - 10.1007/s00330-026-12577-6
UR - https://doi.org/10.1007/s00330-026-12577-6
LA - en
ER -

CSL-JSON

{
"id": "10.1007/s00330-026-12577-6",
"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": "Eur Radiol",
"volume": "36",
"issue": "9",
"page": "7242-7255",
"DOI": "10.1007/s00330-026-12577-6",
"PMID": "42069957",
"PMCID": "PMC13451240",
"ISSN": "0938-7994",
"publisher": "Springer Science+Business Media",
"URL": "https://doi.org/10.1007/s00330-026-12577-6",
"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 neuroscience
In 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 psychiatry
In 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: eLife
In 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. Clinical
In 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 Sclerosis
Journal: 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 communications
In 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 neuroimaging
In 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: Nature
In 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 America
In 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.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

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.