xdesign.metrics

Functions:

ImageQuality(original, reconstruction[, method]) Stores information about image quality.
probability_mask(phantom, size[, ratio, uniform]) Returns the probability mask for each phase in the phantom.
compute_quality(reference, reconstructions) Computes image quality metrics for each of the reconstructions.
compute_PCC(A, B[, masks]) Computes the Pearson product-moment correlation coefficients (PCC) for the two images.
compute_likeness(A, B, masks) Predicts the likelihood that each pixel in B belongs to a phase based on the histogram of A.
compute_background_ttest(image, masks) Determines whether the background has significantly different luminance than the other phases.
compute_mtf(phantom, image[, Ntheta]) Uses method described in Friedman et al to calculate the MTF.
compute_nps(phantom, A[, B, plot_type]) Calculates the noise power spectrum from a unit circle image.
compute_neq(phantom, A, B) Calculates the NEQ according to recommendations by JT Dobbins.
compute_mtf_siemens(phantom, image) Calculates the MTF using the modulated Siemens Star method in Loebich et al.
class xdesign.metrics.ImageQuality(original, reconstruction, method=u'')[source]

Bases: object

Stores information about image quality.

orig

numpy.ndarray

recon

numpy.ndarray

qualities

list of scalars

maps

list of numpy.ndarray

scales

list of scalars

add_quality(quality, scale, maps=None)[source]
Parameters:
  • quality (scalar, list) – The average quality for the image
  • map (array, list of arrays, optional) – the local quality rating across the image
  • scale (scalar, list) – the size scale at which the quality was calculated
sort()[source]

Sorts the qualities by scale

xdesign.metrics.probability_mask(phantom, size, ratio=8, uniform=True)[source]

Returns the probability mask for each phase in the phantom.

Parameters:
  • size (scalar) – The side length in pixels of the resulting square image.
  • ratio (scalar, optional) – The discretization works by drawing the shapes in a larger space then averaging and downsampling. This parameter controls how many pixels in the larger representation are averaged for the final representation. e.g. if ratio = 8, then the final pixel values are the average of 64 pixels.
  • uniform (boolean, optional) – When set to False, changes the way pixels are averaged from a uniform weights to gaussian weights.
Returns:

image (list of numpy.ndarray) – A list of float masks for each phase in the phantom.

xdesign.metrics.compute_quality(reference, reconstructions, method=u'MSSSIM', L=1)[source]

Computes image quality metrics for each of the reconstructions.

Parameters:
  • reference (array) – the discrete reference image. In a future release, we will determine the best way to compare a continuous domain to a discrete reconstruction.
  • reconstructions (list of arrays) – A list of discrete reconstructions
  • method (string, optional) – The quality metric desired for this comparison. Options include: SSIM, MSSSIM
  • L (scalar) – The dynamic range of the data. This value is 1 for float representations and 2^bitdepth for integer representations.
Returns:

metrics (list of ImageQuality)

xdesign.metrics.compute_PCC(A, B, masks=None)[source]

Computes the Pearson product-moment correlation coefficients (PCC) for the two images.

Parameters:
  • A,B (ndarray) – The two images to be compared
  • masks (list of ndarrays, optional) – If supplied, the data under each mask is computed separately.
Returns:

covariances (array, list of arrays)

xdesign.metrics.compute_likeness(A, B, masks)[source]

Predicts the likelihood that each pixel in B belongs to a phase based on the histogram of A.

Parameters:
  • A (ndarray)
  • B (ndarray)
  • masks (list of ndarrays)
Returns:

likelihoods (list of ndarrays)

xdesign.metrics.compute_background_ttest(image, masks)[source]

Determines whether the background has significantly different luminance than the other phases.

Parameters:
  • image (ndarray)
  • masks (list of ndarrays) – Masks for the background and any other phases. Does not autogenerate the non-background mask because maybe you want to compare only two phases.
Returns:

  • tstat (scalar)
  • pvalue (scalar)

xdesign.metrics.compute_mtf(phantom, image, Ntheta=4)[source]

Uses method described in Friedman et al to calculate the MTF.

Parameters:
  • phantom (UnitCircle) – Predefined phantom with single circle whose radius is less than 0.5.
  • image (ndarray) – The reconstruction of the above phantom.
  • Ntheta (scalar) – The number of directions at which to calculate the MTF.
Returns:

  • wavenumber (ndarray) – wavelenth in the scale of the original phantom
  • MTF (ndarray) – MTF values
  • bin_centers (ndarray) – the center of the bins if Ntheta >= 1

References

S. N. Friedman, G. S. K. Fung, J. H. Siewerdsen, and B. M. W. Tsui. “A simple approach to measure computed tomography (CT) modulation transfer function (MTF) and noise-power spectrum (NPS) using the American College of Radiology (ACR) accreditation phantom,” Med. Phys. 40, 051907-1 - 051907-9 (2013). http://dx.doi.org/10.1118/1.4800795

xdesign.metrics.compute_nps(phantom, A, B=None, plot_type=u'frequency')[source]

Calculates the noise power spectrum from a unit circle image. The peak at low spatial frequency is probably due to aliasing. Invesigation into supressing this peak is necessary.

References

S. N. Friedman, G. S. K. Fung, J. H. Siewerdsen, and B. M. W. Tsui. “A simple approach to measure computed tomography (CT) modulation transfer function (MTF) and noise-power spectrum (NPS) using the American College of Radiology (ACR) accreditation phantom,” Med. Phys. 40, 051907-1 - 051907-9 (2013). http://dx.doi.org/10.1118/1.4800795

Parameters:
  • phantom (UnitCircle) – The unit circle phantom.
  • A (ndarray) – The reconstruction of the above phantom.
  • B (ndarray) – The reconstruction of the above phantom with different noise. This second reconstruction enables allows use of trend subtraction instead of zero mean normalization.
  • plot_type (string) – ‘histogram’ returns a plot binned by radial coordinate wavenumber ‘frequency’ returns a wavenumber vs wavenumber plot
Returns:

  • bins – Bins for the radially binned NPS
  • counts – NPS values for the radially binned NPS
  • X, Y – Frequencies for the 2D frequency plot NPS
  • NPS (2Darray) – the NPS for the 2D frequency plot

xdesign.metrics.compute_neq(phantom, A, B)[source]

Calculates the NEQ according to recommendations by JT Dobbins.

Parameters:
  • phantom (UnitCircle) – The unit circle class with radius less than 0.5
  • A (ndarray) – The reconstruction of the above phantom.
  • B (ndarray) – The reconstruction of the above phantom with different noise. This second reconstruction enables allows use of trend subtraction instead of zero mean normalization.
Returns:

  • mu_b – The spatial frequencies
  • NEQ – the Noise Equivalent Quanta

xdesign.metrics.compute_mtf_siemens(phantom, image)[source]

Calculates the MTF using the modulated Siemens Star method in Loebich et al. (2007).

Parameters:
  • phantom (SiemensStar)
  • image (ndarray) – The reconstruciton of the SiemensStar
Returns:

  • frequency (array) – The spatial frequency in cycles per unit length
  • M (array) – The MTF values for each frequency