Utilities

Input/Output Functions

synthqc.util.io

handle io operations for the synthit package

Author: Jacob Reinhold (jacob.reinhold@jhu.edu)

Created on: Jun 20, 2018

synthqc.util.io.split_filename(filepath)

split a filepath into the directory, base, and extension

synthqc.util.io.glob_nii(path)

grab all nifti files in a directory and sort them for consistency

Synthesis Quality

synthqc.util.quality

measure synthesis image quality for the synthit package

Author: Jacob Reinhold (jacob.reinhold@jhu.edu)

Created on: Jun 26, 2018

synthqc.util.quality.synth_quality(synth, truth, mask=None, use_mi=False)

compare a synthesized image to the truth image by calculating metrics associated with image quality, the metrics are: (entropy normalized) mutual information, normalized cross correlation [2], and MSSIM [3]

Parameters:
  • synth (np.ndarray) – synthesized image
  • truth (np.ndarray) – image we are trying to synthesize
  • mask (np.ndarray) – mask for the images
  • use_mi (bool) – use mutual info instead of enmi
Returns:

list of stats calculated from the corresponding metrics metrics (list): list of strings which define the calculated metrics

Return type:

stats (list)

References

[1] https://itk.org/Doxygen/html/classitk_1_1CorrelationImageToImageMetricv4.html [2] Z. Wang, A. C. Bovik, H. R. Sheikh, and E. P. Simoncelli,

“Image quality assessment: From error visibility to structural similarity,” IEEE Trans. Image Process., vol. 13, no. 4, pp. 600–612, 2004.
synthqc.util.quality.quality_simplex_area(stats)

area of the “quality simplex,” i.e., the area of the simplex defined in 2d by radially plotting the values of metrics mutual information, correlation, and ssim

Parameters:stats (list) – list of 3 statistics (whose entries are in the range [0,1])
Returns:area of the “quality simplex” normalized between 0 and 1
Return type:area (float)
synthqc.util.quality.normalized_cross_correlation(x, y, mask=None)

compute normalized cross correlation between two vectors/arrays

synthqc.util.quality.entropy_normalized_mutual_info(x, y, mask=None, bins=100)

compute an entropy normalized mutual information (i.e., mutual information divided by its maximum value, specifically, the entropy of y)

Parameters:
  • x (np.ndarray) – data, usually MRI image data
  • y (np.ndarray) – data, usually MRI image data
  • mask (np.ndarray) – mask of relevant data, usually a brain mask
  • bins (int) – number of bins to use in joint histogram on each axis
Returns:

normalized mutual information for x and y

Return type:

nmi (float)

References

https://matthew-brett.github.io/teaching/mutual_information.html

synthqc.util.quality.mutual_info(x, y, bins=200, return_joint=False)

calculate the mutual information for two data arrays

synthqc.util.quality.mssim(x, y, mask=None, multichannel=False)

mean structural similarity (over a mask)