Skip to content

ldctbench.evaluate.ldct_iqa

LDCTIQA(device=None)

Class to perform no-reference IQA on LDCT images using the winning model of the Low-dose Computed Tomography Perceptual Image Quality Assessment Grand Challenge 20231 which was organized in conjunction with MICCAI 2023.

The aim of the challenge was to develop no-reference IQA methods that correlate well with scores provided by radiologists. To this end, the organizers generated a total of 1,500 (1,000 train, 200 val, 300 test) images of various quality by introducing noise and streak artifacts into routine-dose abdominal CT images. Resulting images were rated by radiologists on a five-point Likert scale and their mean score was used as the ground truth.

The five-point Likert scale was defined as follows (see Table 1 in the paper1):

Numeric score Verbal descriptive scale Diagnostic quality criteria
0 Bad Desired features are not shown
1 Poor Diagnostic interpretation is impossible
2 Fair Images are suitable for limited clinical interpretation
3 Good Images are suitable for diagnostic interpretation
4 Excellent The anatomical structure is evident

The model that we use here is a slight variation of the winning model (agaldran). The differences to the model used in the challenge are:

  • We retrained including the additional 300 test images from the challenge
  • Only using the muli-head swin transformer (no ResNeXt)
  • No ensemble, only one model on a single training/validation split of the 1,500 images

Use with out-of-distribution (OOD) data

Be aware that any evaluation using this model will most likely be an OOD setting and predicted scores should be interpreted with caution. The model was

  • trained only using abodminal CT images. However, the paper1 performs some experiments using a clinical head CT dataset, to evaluate the methods generalization capabilities.
  • trained on four distinct noise levels only. These noise levels may not be representative of your data.
  • not trained on denoised images at all. It has only seen routine-dose images and various distorted versions thereof. It remains unclear how well the model generalizes to denoised images.

  1. Lee, Wonkyeong, Fabian Wagner, Adrian Galdran, Yongyi Shi, Wenjun Xia, Ge Wang, Xuanqin Mou, et al. 2025. “Low-Dose Computed Tomography Perceptual Image Quality Assessment.” Medical Image Analysis 99 (January):103343. https://doi.org/10.1016/j.media.2024.103343

Parameters:

  • device (device, default: None ) –

    Device to run LDCTIQA model on

__call__(x, preprocess=True)

Predict the IQA score for a given image

Parameters:

  • x (Union[Tensor, ndarray]) –

    if preprocess is True, expects numpy float array in HU + 1024 (i.e., air should have a value of ~24) of shape [1,512,512]. Otherwise, expects preprocessed torch tensor of shape [B,3,512,512]

  • preprocess (bool, default: True ) –

    Whether inputs should be preprocessed (i.e., windowed and normalized)

Returns:

  • Tensor

    Predicted score on a five-point Likert scale [0,4] in 0.2 increments

Examples:

Evaluate IQA on a single DICOM slice

>>> import pydicom
>>> ds = pydicom.filereader.dcmread("path/to/dicom")
>>> img = ds.pixel_array.astype("float32")
>>> # Ensure that image has expected offset and scaling
>>> assert ds.RescaleSlope == "1" and ds.RescaleIntercept == "-1024"
>>> iqa = LDCTIQA()
>>> score = iqa(img)

preprocess(x)

Preprocess a given CT image

The function takes a numpy float array in HU + 1024, applies windowing with (C,W) = (300, 1400) HU (as was done for the training data) and normalizes the image to the ImageNet mean and standard deviation.

Parameters:

  • x (ndarray) –

    A np.ndarray of shape [512,512] or [1,512,512] representing a CT image in HU + 1024

Raises:

  • ValueError

    If input is not a numpy array

  • ValueError

    If image shape is not [512,512] or [1,512,512]

Returns:

  • Tensor

    Preprocessed image as torch.Tensor of shape [1,3,512,512]

evaluate_dicom(dicom_path, savedir=None, device=None, disable_progress=False)

Evaluate LDCTIQA on a single DICOM file or a series of DICOM files in a folder

Parameters:

  • dicom_path (str) –

    Path to a single DICOM file or a folder containig one or more DICOM files

  • savedir (str, default: None ) –

    Foldername where to store evaluation results. If not provided, results are not saved, only returned

  • device (Optional[device], default: None ) –

    torch.device, optional

  • disable_progress (bool, default: False ) –

    Disable progress bar, by default False

Returns:

  • list

    List of IQA scores for each DICOM file

Raises:

  • ValueError

    If provided path is neither a DICOM file nor a folder containing at least one DICOM file

  • ValueError

    If image shape is not 512 x 512

Examples:

Evaluate a folder of DICOM files and save the results to a file scores.json in the provided savedir:

from ldctbench.evaluate import evaluate_dicom
scores = evaluate_dicom(dicom_path="path/to/dicom/series", savedir="path/to/save")
Evalauate a folder of DICOM files and return scores (don't save them):
from ldctbench.evaluate import evaluate_dicom
scores = evaluate_dicom(dicom_path="path/to/dicom/series")

The function is also documented in this example.