Function Reference

Reference page

Functions and classes for interactively running CT simulations

This module provides classes and functions to interactively run CT simulations and make phantom datasets

pediatricIQphantoms.run_batch_sim(image_directory: str, model=['MITA-LCD'], diameter=[200], full_dose=300000.0, dose_level=[1.0], fbp_kernel='fbp', verbose=True, **kwargs) DataFrame

Running simulations in batch mode

run_batch_sim takes lists of parameters (phantoms, diameters, and dose levels) and iterates through all combinations, returns a pandas DataFrame summarizing file metadata including filename

Parameters:
  • image_directory (str) – Directory to save simulated outputs

  • model (list[str]) – Optional list, list of phantom models to simulate (can be length 1) options include [‘CTP404’, ‘Uniform’, ‘MITA-LCD’]

  • diameter – Optional list, list of simulated phantom diameters in mm (can be length 1)

  • full_dose – Optional int, units of photons per pixel, multiplied by dose_level to determine quantum noise level in projections

  • dose_level – Optional list, units of photons

  • verbose – Optional bool, whether to print update information

Returns:

pd.DataFrame

See CTobj for remaining keyword arguments

class pediatricIQphantoms.CTobj(phantom='CCT189', patient_diameter=200, reference_diameter=200, reference_fov=340, I0=300000.0, ndetectors=900, nangles=580, detector_size=1, sid=595, sdd=1085.6, detector_offset=1.25, down_sampling=1, has_bowtie=False, add_noise=True, aec_on=True, matrix_size=512, fov=340, fbp_kernel='hanning,2.05', nsims=1, lesion_diameter=False, age=0, patientname='', patientid=0, studyname='', studyid=0, seriesname='', seriesid=0, framework='MIRT')

A class to hold CT simulation data and run simulations

Parameters:
  • phantom – phantom object to be scanned, options include [‘CCT189’, ‘CTP404’, ‘Uniform’]

  • patient_diameter – Optional, effective diameter in mm. See AAPM TG220 for more details.

  • reference_diameter – Optional, reference effective diameter in mm for computing automatic exposure control (aec) noise index. For example if a 200 mm reference phantom has a noise level of 24 HU at I0=3e5, smaller phantoms will scale I0 to match that noise level. Note this only applies if ‘aec_on`=True.

  • I0 – Optional float, fluence at the detector in the projection data for determining quantum noise default 3e5 units of photons.

  • ndetectors – Optional int, number of detector columns

  • nangles – Optional int, number of views in a rotation (na=1160 based on Zeng et al 2015)

  • detector_size – Optional float, detector column size in mm

  • sid – Optional float, source-to-isocenter distance in mm

  • sdd – Optional float, source-to-detector distance in mm

  • detector_offset – Optional float, lateral shift of detector (1.25 = quarter pixel offset)

  • has_bowtie – Optional bool, whether to add a patient fitting bowtie (TODO add different bowtie sizes.)

  • add_noise – Optional bool, if true adds Poisson noise, noise magnitude set by reference_dose_level, noise texture set by reconstructed field of view (currently fov = 110% patient_diameter)

  • aec_on – Optional bool, ‘aec’ = automatic exposure control, when true, it ensures constant noise levels for all patient_diameters (see reference_dose_level for more info)

  • matrix_size – Optional int, reconstructed matrix size in pixels (square, equal on both sides)

  • fov – Optional float, reconstructed field of view (FOV) units mm

  • fbp_kernel – Optional str, hanning,xxx, xxx = the cutoff frequency, see fbp2_window.m in MIRT for details. E.g. ‘hanning,2.05’ approximates a sharp kernel D45 in Siemens Force and ‘hanning, 0.85’ approximates a smooth kernel B30.

  • nsims – Optional int, number of simulations to perform with different noise instantiations

  • lesion_diameter – Optional bool | list | float | int, if False lesions scale with phantom size, if model==’CTP404’ lesion_diameter > 1 interpret as absolute diameter in mm, if lesion_diameter < 1 interpret as scale relative to phantom diameter. If model==’CCT189’ a list of 4 diameters must be provided for the four inserts in contrast order 14, 7, 5, 3 HU. (only applies for CCCT189 MITA and CTP404 phantoms)

  • framework – Optional, CT simulation framework options include [‘MIRT’]

Returns:

None

run(verbose=False)

Runs the CT simulation using the stored parameters.

Parameters:

verbose – optional boolean, if True prints out status updates, if False they are suppressed.

write_to_dicom(fname: str | Path, groundtruth=False) list[Path]

write ct data to DICOM file, returns list of written dicom file names

Parameters:
  • fname – filename to save image to (preferably with ‘.dcm` or related extension)

  • groundtruth – Optional, whether to save the ground truth phantom image (no noise, blurring, or other artifacts). If True, ‘self.groundtruth` is saved, if False (default) self.recon which contains blurring (and noise if ‘add_noise`True)

Returns:

list[Path]