Automated opportunistic screening for low bone mineral density using routine CT brain imaging.
The 1 match
- [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
- import json
- from typing import Literal
- import numpy as np
- import pydicom
- import nibabel as nib
- import torch
- from pathlib import Path
- from monai.transforms import Resize, ResizeWithPadOrCrop
- from models import FE_Additional
- def load_nifti_volume(path: str) -> np.ndarray:
- """
- Load a NIfTI CT volume as a numpy array.
- Returns shape expected by the rest of the pipeline:
- (num_slices, height, width)
- """
- img = nib.load(path)
- img = nib.as_closest_canonical(img)
- arr = img.get_fdata().astype(np.float32)
- # Brainseg stores as (H, W, Z). Convert to (Z, H, W)
- if arr.ndim != 3:
- raise ValueError(f"Expected 3D NIfTI volume, got shape {arr.shape}")
- arr = np.moveaxis(arr, -1, 0)
- return arr
- def load_nifti_mask(path: str) -> np.ndarray:
- """
- Load a NIfTI segmentation mask.
- Returns shape:
- (num_slices, height, width)
- """
- img = nib.load(path)
- img = nib.as_closest_canonical(img)
- arr = img.get_fdata().astype(np.uint16)
- if arr.ndim != 3:
- raise ValueError(f"Expected 3D NIfTI mask, got shape {arr.shape}")
- arr = np.moveaxis(arr, -1, 0)
- return arr
- def load_config(config_path: str) -> dict:
- """
- Load the model configuration from a JSON file.
- Args:
- config_path (str): Path to the model configuration json file.
- Returns:
- dict: The loaded configuration as a dictionary.
- """
- with open(config_path, "r") as f:
- config = json.load(f)
- return config
- def load_model(config: dict, model_path: str, device: torch.device) -> FE_Additional:
- """
- Load a PyTorch model from the specified path and move it to the given device.
- Args:
- config_path (str): Path to the model configuration json file.
- model_path (str): Path to the model file.
- device (torch.device): Device to load the model onto (e.g., 'cuda' or 'cpu').
- Returns:
- torch.nn.Module: The loaded model.
- """
- # Create the model instance with the loaded configuration
- model = FE_Additional(
- model_name=config.get("model_name", "seresnet18"),
- dropout=config.get("dropout", 0.3),
- additional_features=config.get("additional_features", 2),
- pretrained=config.get("pretrained", False),
- device=device,
- sep_metadata_layer=config.get("sep_metadata_layer", False),
- activation=config.get("activation", "sigmoid"),
- ).to(device)
- # Load the model state dictionary
- model.load_state_dict(torch.load(model_path, map_location=device)[0])
- return model
- def create_metadata_tensor(
- age: int,
- sex: Literal["male", "female"],
- age_mean: float,
- age_std: float,
- device: torch.device,
- ) -> torch.Tensor:
- """
- Create a metadata tensor from age and sex features and normalize the age.
- Args:
- age (int): The age of the patient.
- sex (Literal["male", "female"]): The sex of the patient.
- age_mean (float): The mean age for normalisation.
- age_std (float): The standard deviation of age for normalisation.
- device (torch.device): Device to place the tensor on (e.g., 'cuda' or 'cpu').
- Raises:
- ValueError: If `sex` is not in male or female.
- Returns:
- torch.Tensor: A tensor containing the normalized age and sex.
- """
- if sex not in ["male", "female"]:
- raise ValueError(f"`sex` must be either male or female. Received: {sex}")
- # Convert sex to a numerical value
- sex = int(sex == "male")
- # Create a tensor with age and sex
- normalised_age = (age - age_mean) / age_std
- metadata = torch.tensor([normalised_age, sex], dtype=torch.float32)
- metadata = metadata.to(device) # Move to the specified device
- return metadata
- def load_slices(dir_path: str) -> list[np.array]:
- """
- Load DICOM slices from the specified directory and sort them.
- Args:
- dir_path (str): Path to the directory containing the DICOM slices.
- Returns:
- list[np.array]: List of loaded DICOM slices.
- """
- # Get the slice file paths
- slice_paths = sorted(Path(dir_path).glob("*.dcm"))
- if len(slice_paths) == 0:
- raise ValueError(f"No DICOM files found in directory: {dir_path}")
- # Load the slices
- slices = []
- for path in slice_paths:
- ct_slice = pydicom.dcmread(path)
- slices.append(ct_slice)
- # Sort slices by InstanceNumber to ensure correct order
- slices.sort(key=lambda x: int(x.InstanceNumber))
- return slices
- def transform_to_hu(slices: list[np.array]) -> list[np.array]:
- """
- Transform DICOM slices to Hounsfield Units (HU).
- Args:
- slices (list[np.array]): List of DICOM slices to be transformed.
- Returns:
- list[np.array]: List of transformed slices in Hounsfield Units.
- """
- return [
- pydicom.pixel_data_handlers.apply_modality_lut(slice_.pixel_array, slice_)
- for slice_ in slices
- ]
- def window(
- slices: list[np.array], window_center: int, window_width: int
- ) -> list[np.array]:
- """
- Apply a windowing operation to the slices.
- Args:
- slices (list[np.array]): List of slices to be windowed.
- window_center (int): Center of the window.
- window_width (int): Width of the window.
- Returns:
- list[np.array]: List of windowed slices.
- """
- lower_bound = window_center - (window_width / 2)
- upper_bound = window_center + (window_width / 2)
- slices = [np.clip(slice_, lower_bound, upper_bound) for slice_ in slices]
- return slices
- def zoom_resize(slices: torch.Tensor, dims: tuple[int, int]) -> torch.Tensor:
- """
- Resize slices to the specified dimensions.
- Args:
- slices (torch.Tensor): Tensor of slices to be resized.
- dims (tuple[int, int]): Target dimensions for resizing (height, width).
- Returns:
- torch.Tensor: Resized tensor of slices.
- """
- resize_func = Resize(max(dims), size_mode="longest")
- pad_func = ResizeWithPadOrCrop(
- spatial_size=dims, constant_values=slices.min(), mode="constant"
- )
- t = pad_func(resize_func(slices))
- return t
- def normalise_slices(slices: torch.Tensor, mean: float, std: float) -> torch.Tensor:
- """
- Normalize the slices using the specified mean and standard deviation.
- Args:
- slices (torch.Tensor): Tensor of slices to be normalized.
- mean (float): Mean value for normalization.
- std (float): Standard deviation value for normalization.
- Returns:
- torch.Tensor: Normalized tensor of slices.
- """
- if std <= 0:
- raise ValueError(
- "Standard deviation must be greater than zero for normalization."
- )
- return (slices - mean) / std
- def create_channels(slices: torch.Tensor) -> torch.Tensor:
- """
- Take a tensor of slices and create a 3-channel tensor with overlapping slices.
- Args:
- slices (torch.Tensor): Tensor of slices to be converted.
- Returns:
- torch.Tensor: Tensor containing the 3-channel overlapping slices with shape (batch, 3, 512, 512).
- """
- # Create three channels that are overlapping slices
- slices = slices.unfold(0, size=3, step=1)
- # Reshape to (batch, 3, 512, 512)
- slices = slices.reshape(-1, 3, 512, 512)
- return slices
- def calculate_optimal_slice(mask: np.array) -> int:
- """
- Calculate the optimal slice index above the lateral ventricles based on segmentation data.
- Args:
- mask (np.array): 3D numpy array where each slice corresponds to a segmentation mask
- generated from a CT scan.
- Returns:
- int: The index of the optimal slice above the lateral ventricles.
- """
- # Count the number of pixels in each slice corresponding with label 10
- # (ventricular system)
- pixel_count = np.zeros((len(mask)))
- for i, array in enumerate(mask):
- pixel_count[i] = np.sum(array == 10)
- max_pixel_count_index = np.argmax(pixel_count)
- # Define a slice limit to to stop looking
- # Defined as 1/5 of the series length from the slice with highest pixel
- # count corresponding with the ventricular system
- sequence_length = len(pixel_count)
- window_size = int(sequence_length * 0.2)
- window_end = max_pixel_count_index + window_size
- # Ensure the window doesn't exceed the bounds of the entire scan
- window_end = min(window_end, sequence_length)
- # Identify the minimum value in the defined window
- min_val = min(pixel_count[max_pixel_count_index:window_end])
- # Set the threshold value of to be 5% of the max pixel count
- threshold_value = pixel_count[max_pixel_count_index] / 20
- # Adjust the window end to not exceed the array bounds
- adjusted_window_end = min(max_pixel_count_index + window_size, len(pixel_count))
- if min_val <= threshold_value:
- # Look for the first value below 1/20 of the max value within the window
- for idx in range(max_pixel_count_index, adjusted_window_end):
- if pixel_count[idx] < threshold_value:
- optimal_slice_idx = idx
- break
- else:
- # Catch situation where all pixel counts are above threshold in the window
- optimal_slice_idx = max_pixel_count_index + np.argmin(
- pixel_count[max_pixel_count_index:window_end]
- )
- return optimal_slice_idx
- def extract_optimal_range(slices: np.array, optimal_slice_idx: int) -> np.array:
- """
- Extract a range of slices around the optimal slice index.
- Args:
- slices (np.array): 3D numpy array where each slice corresponds to a CT scan slice.
- optimal_slice_idx (int): The index of the optimal slice above the lateral ventricles.
- Returns:
- np.array: 3D numpy array containing the extracted range of slices.
- """
- n = len(slices)
- window = 12
- start_idx = optimal_slice_idx - 6
- start_idx = max(0, min(start_idx, n - window))
- end_idx = start_idx + window
- return slices[start_idx:end_idx]
utils.py at commit 9c2f2b9, under MIT · at the source
Overview
- Melbourne Bioinnovation Student Initiative (MBSI), Parkville, VIC, Australia
- Artificial Intelligence in Radiology Laboratory, Department of Radiology, Austin Health, Heidelberg, VIC, Australia
- Melbourne Medical School, The University of Melbourne, Parkville, VIC, Australia
- Department of Endocrinology, Austin Health, Heidelberg, VIC, Australia
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
9c2f2b952571be86a63c9a55f1344bcbac75af5c, 15 June 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
6 files
- demo.ipynb, Jupyter, 121 lines
- demo_nii.ipynb, Jupyter, 117 lines
- models.py, Python, 154 lines
- utils.py, Python, 321 lines, 1 match
- LICENSE, License, 21 lines
- README.md, Text, 89 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;
- 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://
BibTeX
@article{zhang2026automa
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/
url = {https://
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/
VL - 6
SP - 1901958
SN - 2673-8740
PB - Frontiers Media SA
DO - 10.3389/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.3389/
"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":
"volume": "6",
"page": "1901958",
"DOI": "10.3389/
"PMID": "42666401",
"PMCID": "PMC13522152",
"ISSN": "2673-8740",
"publisher": "Frontiers Media SA",
"URL": "https://
"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 biologyIn 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 intelligenceIn 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 anatomyIn 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 imagingIn 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 medicineIn 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 communicationsIn 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 methodsIn 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 neuroscienceIn 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 oneIn 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 AssociationIn 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.
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, 4 scripts, and 1 match 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:971f68b58e973c53…
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
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
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.
