OSCR

Automated opportunistic screening for low bone mineral density using routine CT brain imaging.

Code ↔ Paper

1 match between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 1 match
  1. [1] § Materials and methods › Study design › Data pre-processing ↔ utils.py, lines 250–299 · score 0.70 · highest pixel, ventricular system, lateral ventricles, segmented, threshold, slice

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 · 321 lines · 9.7 KB · MIT · 1 match

  1. import json
  2. from typing import Literal
  3. import numpy as np
  4. import pydicom
  5. import nibabel as nib
  6. import torch
  7. from pathlib import Path
  8. from monai.transforms import Resize, ResizeWithPadOrCrop
  9. from models import FE_Additional
  10. def load_nifti_volume(path: str) -> np.ndarray:
  11. """
  12. Load a NIfTI CT volume as a numpy array.
  13. Returns shape expected by the rest of the pipeline:
  14. (num_slices, height, width)
  15. """
  16. img = nib.load(path)
  17. img = nib.as_closest_canonical(img)
  18. arr = img.get_fdata().astype(np.float32)
  19. # Brainseg stores as (H, W, Z). Convert to (Z, H, W)
  20. if arr.ndim != 3:
  21. raise ValueError(f"Expected 3D NIfTI volume, got shape {arr.shape}")
  22. arr = np.moveaxis(arr, -1, 0)
  23. return arr
  24. def load_nifti_mask(path: str) -> np.ndarray:
  25. """
  26. Load a NIfTI segmentation mask.
  27. Returns shape:
  28. (num_slices, height, width)
  29. """
  30. img = nib.load(path)
  31. img = nib.as_closest_canonical(img)
  32. arr = img.get_fdata().astype(np.uint16)
  33. if arr.ndim != 3:
  34. raise ValueError(f"Expected 3D NIfTI mask, got shape {arr.shape}")
  35. arr = np.moveaxis(arr, -1, 0)
  36. return arr
  37. def load_config(config_path: str) -> dict:
  38. """
  39. Load the model configuration from a JSON file.
  40. Args:
  41. config_path (str): Path to the model configuration json file.
  42. Returns:
  43. dict: The loaded configuration as a dictionary.
  44. """
  45. with open(config_path, "r") as f:
  46. config = json.load(f)
  47. return config
  48. def load_model(config: dict, model_path: str, device: torch.device) -> FE_Additional:
  49. """
  50. Load a PyTorch model from the specified path and move it to the given device.
  51. Args:
  52. config_path (str): Path to the model configuration json file.
  53. model_path (str): Path to the model file.
  54. device (torch.device): Device to load the model onto (e.g., 'cuda' or 'cpu').
  55. Returns:
  56. torch.nn.Module: The loaded model.
  57. """
  58. # Create the model instance with the loaded configuration
  59. model = FE_Additional(
  60. model_name=config.get("model_name", "seresnet18"),
  61. dropout=config.get("dropout", 0.3),
  62. additional_features=config.get("additional_features", 2),
  63. pretrained=config.get("pretrained", False),
  64. device=device,
  65. sep_metadata_layer=config.get("sep_metadata_layer", False),
  66. activation=config.get("activation", "sigmoid"),
  67. ).to(device)
  68. # Load the model state dictionary
  69. model.load_state_dict(torch.load(model_path, map_location=device)[0])
  70. return model
  71. def create_metadata_tensor(
  72. age: int,
  73. sex: Literal["male", "female"],
  74. age_mean: float,
  75. age_std: float,
  76. device: torch.device,
  77. ) -> torch.Tensor:
  78. """
  79. Create a metadata tensor from age and sex features and normalize the age.
  80. Args:
  81. age (int): The age of the patient.
  82. sex (Literal["male", "female"]): The sex of the patient.
  83. age_mean (float): The mean age for normalisation.
  84. age_std (float): The standard deviation of age for normalisation.
  85. device (torch.device): Device to place the tensor on (e.g., 'cuda' or 'cpu').
  86. Raises:
  87. ValueError: If `sex` is not in male or female.
  88. Returns:
  89. torch.Tensor: A tensor containing the normalized age and sex.
  90. """
  91. if sex not in ["male", "female"]:
  92. raise ValueError(f"`sex` must be either male or female. Received: {sex}")
  93. # Convert sex to a numerical value
  94. sex = int(sex == "male")
  95. # Create a tensor with age and sex
  96. normalised_age = (age - age_mean) / age_std
  97. metadata = torch.tensor([normalised_age, sex], dtype=torch.float32)
  98. metadata = metadata.to(device) # Move to the specified device
  99. return metadata
  100. def load_slices(dir_path: str) -> list[np.array]:
  101. """
  102. Load DICOM slices from the specified directory and sort them.
  103. Args:
  104. dir_path (str): Path to the directory containing the DICOM slices.
  105. Returns:
  106. list[np.array]: List of loaded DICOM slices.
  107. """
  108. # Get the slice file paths
  109. slice_paths = sorted(Path(dir_path).glob("*.dcm"))
  110. if len(slice_paths) == 0:
  111. raise ValueError(f"No DICOM files found in directory: {dir_path}")
  112. # Load the slices
  113. slices = []
  114. for path in slice_paths:
  115. ct_slice = pydicom.dcmread(path)
  116. slices.append(ct_slice)
  117. # Sort slices by InstanceNumber to ensure correct order
  118. slices.sort(key=lambda x: int(x.InstanceNumber))
  119. return slices
  120. def transform_to_hu(slices: list[np.array]) -> list[np.array]:
  121. """
  122. Transform DICOM slices to Hounsfield Units (HU).
  123. Args:
  124. slices (list[np.array]): List of DICOM slices to be transformed.
  125. Returns:
  126. list[np.array]: List of transformed slices in Hounsfield Units.
  127. """
  128. return [
  129. pydicom.pixel_data_handlers.apply_modality_lut(slice_.pixel_array, slice_)
  130. for slice_ in slices
  131. ]
  132. def window(
  133. slices: list[np.array], window_center: int, window_width: int
  134. ) -> list[np.array]:
  135. """
  136. Apply a windowing operation to the slices.
  137. Args:
  138. slices (list[np.array]): List of slices to be windowed.
  139. window_center (int): Center of the window.
  140. window_width (int): Width of the window.
  141. Returns:
  142. list[np.array]: List of windowed slices.
  143. """
  144. lower_bound = window_center - (window_width / 2)
  145. upper_bound = window_center + (window_width / 2)
  146. slices = [np.clip(slice_, lower_bound, upper_bound) for slice_ in slices]
  147. return slices
  148. def zoom_resize(slices: torch.Tensor, dims: tuple[int, int]) -> torch.Tensor:
  149. """
  150. Resize slices to the specified dimensions.
  151. Args:
  152. slices (torch.Tensor): Tensor of slices to be resized.
  153. dims (tuple[int, int]): Target dimensions for resizing (height, width).
  154. Returns:
  155. torch.Tensor: Resized tensor of slices.
  156. """
  157. resize_func = Resize(max(dims), size_mode="longest")
  158. pad_func = ResizeWithPadOrCrop(
  159. spatial_size=dims, constant_values=slices.min(), mode="constant"
  160. )
  161. t = pad_func(resize_func(slices))
  162. return t
  163. def normalise_slices(slices: torch.Tensor, mean: float, std: float) -> torch.Tensor:
  164. """
  165. Normalize the slices using the specified mean and standard deviation.
  166. Args:
  167. slices (torch.Tensor): Tensor of slices to be normalized.
  168. mean (float): Mean value for normalization.
  169. std (float): Standard deviation value for normalization.
  170. Returns:
  171. torch.Tensor: Normalized tensor of slices.
  172. """
  173. if std <= 0:
  174. raise ValueError(
  175. "Standard deviation must be greater than zero for normalization."
  176. )
  177. return (slices - mean) / std
  178. def create_channels(slices: torch.Tensor) -> torch.Tensor:
  179. """
  180. Take a tensor of slices and create a 3-channel tensor with overlapping slices.
  181. Args:
  182. slices (torch.Tensor): Tensor of slices to be converted.
  183. Returns:
  184. torch.Tensor: Tensor containing the 3-channel overlapping slices with shape (batch, 3, 512, 512).
  185. """
  186. # Create three channels that are overlapping slices
  187. slices = slices.unfold(0, size=3, step=1)
  188. # Reshape to (batch, 3, 512, 512)
  189. slices = slices.reshape(-1, 3, 512, 512)
  190. return slices
  191. def calculate_optimal_slice(mask: np.array) -> int:
  192. """
  193. Calculate the optimal slice index above the lateral ventricles based on segmentation data.
  194. Args:
  195. mask (np.array): 3D numpy array where each slice corresponds to a segmentation mask
  196. generated from a CT scan.
  197. Returns:
  198. int: The index of the optimal slice above the lateral ventricles.
  199. """
  200. # Count the number of pixels in each slice corresponding with label 10
  201. # (ventricular system)
  202. pixel_count = np.zeros((len(mask)))
  203. for i, array in enumerate(mask):
  204. pixel_count[i] = np.sum(array == 10)
  205. max_pixel_count_index = np.argmax(pixel_count)
  206. # Define a slice limit to to stop looking
  207. # Defined as 1/5 of the series length from the slice with highest pixel
  208. # count corresponding with the ventricular system
  209. sequence_length = len(pixel_count)
  210. window_size = int(sequence_length * 0.2)
  211. window_end = max_pixel_count_index + window_size
  212. # Ensure the window doesn't exceed the bounds of the entire scan
  213. window_end = min(window_end, sequence_length)
  214. # Identify the minimum value in the defined window
  215. min_val = min(pixel_count[max_pixel_count_index:window_end])
  216. # Set the threshold value of to be 5% of the max pixel count
  217. threshold_value = pixel_count[max_pixel_count_index] / 20
  218. # Adjust the window end to not exceed the array bounds
  219. adjusted_window_end = min(max_pixel_count_index + window_size, len(pixel_count))
  220. if min_val <= threshold_value:
  221. # Look for the first value below 1/20 of the max value within the window
  222. for idx in range(max_pixel_count_index, adjusted_window_end):
  223. if pixel_count[idx] < threshold_value:
  224. optimal_slice_idx = idx
  225. break
  226. else:
  227. # Catch situation where all pixel counts are above threshold in the window
  228. optimal_slice_idx = max_pixel_count_index + np.argmin(
  229. pixel_count[max_pixel_count_index:window_end]
  230. )
  231. return optimal_slice_idx
  232. def extract_optimal_range(slices: np.array, optimal_slice_idx: int) -> np.array:
  233. """
  234. Extract a range of slices around the optimal slice index.
  235. Args:
  236. slices (np.array): 3D numpy array where each slice corresponds to a CT scan slice.
  237. optimal_slice_idx (int): The index of the optimal slice above the lateral ventricles.
  238. Returns:
  239. np.array: 3D numpy array containing the extracted range of slices.
  240. """
  241. n = len(slices)
  242. window = 12
  243. start_idx = optimal_slice_idx - 6
  244. start_idx = max(0, min(start_idx, n - window))
  245. end_idx = start_idx + window
  246. return slices[start_idx:end_idx]

utils.py at commit 9c2f2b9, under MIT · at the source

Overview

Authors: Rory Zhang1,2, Nishant Panchal1,2, Heinrik Choong1,2, Charlie Ding1,2, Haotian Huang1,2, Stefan Kachel2,3, Cherie Chiang4, Numan Kutaiba2, Ruth P Lim2,3
  1. Melbourne Bioinnovation Student Initiative (MBSI), Parkville, VIC, Australia
  2. Artificial Intelligence in Radiology Laboratory, Department of Radiology, Austin Health, Heidelberg, VIC, Australia
  3. Melbourne Medical School, The University of Melbourne, Parkville, VIC, Australia
  4. Department of Endocrinology, Austin Health, Heidelberg, VIC, Australia
Institutions: Austin Health (Australia); The University of Melbourne (Australia)
Journal: Frontiers in radiology, volume 6, article 1901958
Dates: received 6 June 2026; accepted 3 August 2026; published online 14 August 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3389/fradi.2026.1901958 · PMID 42666401 · PMCID PMC13522152 · OpenAlex W7203484417
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: other (modality), human (organism), clinical / translational (subfield)
Methods: Connectivity, Machine learning, Preprocessing, Statistics
Keywords: CT brain, deep learning—artificial intelligence, DEXA (Dual energy xray absorptiometry), opportunistic screening opportunistic screening with routine data, osteopenia and osteoporosis
Topic: Bone health and osteoporosis research (Orthopedics and Sports Medicine, Medicine), according to OpenAlex
Citations: not cited yet (Europe PMC); 29 references in the paper

Abstract

Objectives: CT brain (CTB) scans are frequently performed in older adults, a population at increased risk of osteoporosis and low bone mineral density (BMD), presenting an opportunity for opportunistic screening. This study aims to evaluate an automated deep learning approach for opportunistic screening of low BMD and osteoporosis from routine CTB imaging.

Materials and methods: A single-centre retrospective analysis was conducted on 2,014 patients (mean age 69.7 ± 14.9 years; 61% female) who underwent non-contrast CTB and dual-energy x-ray absorptiometry (DEXA) within one year of each other. A convolutional neural network incorporating automatically selected CTB slices cranial to the lateral ventricles, as well as age and sex, was trained to perform two binary classification tasks: low BMD screening (T-score < –1.0) and osteoporosis screening (T-score ≤ –2.5). Model performance was evaluated on a 10% hold-out test set using AUC, balanced accuracy, sensitivity, specificity, positive predictive value, and negative predictive value, with subgroup analysis by sex.

Results: 22% of patients scanned had normal BMD, 44% had osteopenia, and 34% had osteoporosis. For low BMD screening, the model achieved an AUC of 0.83 (95% CI: 0.76–0.90), with AUCs of 0.88 in females and 0.76 in males. For osteoporosis screening, the model achieved an AUC of 0.78 (95% CI: 0.72–0.85), with AUCs of 0.78 in females and 0.74 in males.

Conclusion: Automated analysis of routine CT brain imaging showed good discriminatory performance for opportunistic low BMD screening, particularly among females. With further validation, this approach could support earlier identification of at-risk individuals using imaging already acquired in routine clinical care.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.

AH-AI-in-Radiology/CTB_Osteoporosis_Screening

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 9c2f2b952571be86a63c9a55f1344bcbac75af5c, 15 June 2026
Languages: Jupyter (2), Python (2)
Size: 10 files, 4 scripts
Software Heritage: not archived
Found in: the text, “Saliency map visualisation”
Holds: README, license file, 2 notebooks
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: PyTorch (4 files), NumPy (3 files), Matplotlib (2 files), MONAI (1 file), NiBabel (1 file), pydicom (1 file), SimpleITK (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
6 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;
  • 4 scripts, each with its path and the digest of its content;
  • 1 match between paragraphs of the paper and lines of the code (method lexical-v1);
  • 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.

Data availability statement

The datasets presented in this article are not readily available because of institutional and ethical restrictions but are available from the corresponding author on reasonable request, subject to approval by the Austin Health Human Research Ethics Committee. Requests to access the datasets should be directed to.

Reproduced under the paper's license (CC BY), from the paper cited above.

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 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 9 authors, 5 keywords, 23 references.

Cite

This paper

Zhang, R., Panchal, N., Choong, H., Ding, C., Huang, H., Kachel, S., Chiang, C., Kutaiba, N., & Lim, R. P. (2026). Automated opportunistic screening for low bone mineral density using routine CT brain imaging. Frontiers in radiology, 6, 1901958. https://doi.org/10.3389/fradi.2026.1901958

BibTeX

@article{zhang2026automated,
author = {Zhang, Rory and Panchal, Nishant and Choong, Heinrik and Ding, Charlie and Huang, Haotian and Kachel, Stefan and Chiang, Cherie and Kutaiba, Numan and Lim, Ruth P},
title = {{Automated opportunistic screening for low bone mineral density using routine CT brain imaging}},
journal = {Frontiers in radiology},
year = {2026},
month = aug,
volume = {6},
pages = {1901958},
publisher = {Frontiers Media SA},
issn = {2673-8740},
doi = {10.3389/fradi.2026.1901958},
url = {https://doi.org/10.3389/fradi.2026.1901958},
pmid = {42666401},
pmcid = {PMC13522152}
}

RIS

TY - JOUR
AU - Zhang, Rory
AU - Panchal, Nishant
AU - Choong, Heinrik
AU - Ding, Charlie
AU - Huang, Haotian
AU - Kachel, Stefan
AU - Chiang, Cherie
AU - Kutaiba, Numan
AU - Lim, Ruth P
TI - Automated opportunistic screening for low bone mineral density using routine CT brain imaging
T2 - Frontiers in radiology
J2 - Front Radiol
PY - 2026
DA - 2026/08/14
VL - 6
SP - 1901958
SN - 2673-8740
PB - Frontiers Media SA
DO - 10.3389/fradi.2026.1901958
UR - https://doi.org/10.3389/fradi.2026.1901958
LA - en
ER -

CSL-JSON

{
"id": "10.3389/fradi.2026.1901958",
"type": "article-journal",
"title": "Automated opportunistic screening for low bone mineral density using routine CT brain imaging",
"container-title": "Frontiers in radiology",
"author": [
{
"family": "Zhang",
"given": "Rory"
},
{
"family": "Panchal",
"given": "Nishant"
},
{
"family": "Choong",
"given": "Heinrik"
},
{
"family": "Ding",
"given": "Charlie"
},
{
"family": "Huang",
"given": "Haotian"
},
{
"family": "Kachel",
"given": "Stefan"
},
{
"family": "Chiang",
"given": "Cherie"
},
{
"family": "Kutaiba",
"given": "Numan"
},
{
"family": "Lim",
"given": "Ruth P"
}
],
"container-title-short": "Front Radiol",
"volume": "6",
"page": "1901958",
"DOI": "10.3389/fradi.2026.1901958",
"PMID": "42666401",
"PMCID": "PMC13522152",
"ISSN": "2673-8740",
"publisher": "Frontiers Media SA",
"URL": "https://doi.org/10.3389/fradi.2026.1901958",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
14
]
]
}
}

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.1371/journal.pcbi.1014555 [code]
Body surface potential driven personalisation of electrophysiological digital twins in hypertrophic cardiomyopathy.
Journal: PLoS computational biology
In common: MONAI, pydicom, SimpleITK, 4 other tools, other
[2] doi:10.3389/frai.2026.1771088 [code]
Few-shot deployment of pretrained MRI transformers in brain imaging tasks.
Journal: Frontiers in artificial intelligence
In common: MONAI, pydicom, SimpleITK, 4 other tools
[3] doi:10.1111/joa.70203 [code]
Two-step workflow integrating automatic registration and manual refinement for the accurate alignment of serial histological sections in 3D reconstruction.
Journal: Journal of anatomy
In common: MONAI, pydicom, SimpleITK, 4 other tools
[4] doi:10.1186/s13244-026-02296-3 [code]
A pre-trained foundation model framework for multiplanar MRI classification of extramural vascular invasion and mesorectal fascia invasion in rectal cancer.
Journal: Insights into imaging
In common: MONAI, pydicom, SimpleITK, 4 other tools
[5] doi:10.1080/07853890.2026.2685416 [code]
Pulmonary and cerebral damage in COVID-19 survivors: is there any association?
Journal: Annals of medicine
In common: pydicom, SimpleITK, NiBabel, 3 other tools, other, clinical / translational
[6] doi:10.1038/s41467-026-76011-7 [code]
Human cortex organizes dynamic co-fluctuations along the sensorimotor-association axis.
Journal: Nature communications
In common: MONAI, SimpleITK, NiBabel, 3 other tools
[7] doi:10.1016/j.crmeth.2026.101473 [code]
AmygdalaGo-BOLT for boundary-aware segmentation of the human amygdala.
Journal: Cell reports methods
In common: MONAI, SimpleITK, NiBabel, 3 other tools
[8] doi:10.3389/fnins.2026.1870124 [code]
An end-to-end pipeline for automated fetal brain segmentation and biometry from 3D SSFP MRI.
Journal: Frontiers in neuroscience
In common: MONAI, SimpleITK, NiBabel, 3 other tools
[9] doi:10.1371/journal.pone.0344600 [code]
Robust disease prognosis via diagnostic knowledge preservation: A sequential learning approach.
Journal: PloS one
In common: NiBabel, PyTorch, Matplotlib, 1 other tool, clinical / translational, 2 references
[10] doi:10.1002/alz.71530 [code]
Differential associations of plasma biomarkers with Alzheimer's disease and small vessel disease: A multimodal imaging study.
Journal: Alzheimer's & dementia : the journal of the Alzheimer's Association
In common: SimpleITK, NiBabel, PyTorch, 2 other tools, other, clinical / translational

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.