opentps.core.processing.imageSimulation package

Submodules

opentps.core.processing.imageSimulation.DRRToolBox module

computeDRRSequence(dynamic3DSequence, angleAndOriList, library='tomopy', nCores=1)

compute a DRR Set for each image in a list

Parameters:
  • dynamic3DSequence (Dynamic3DSequence or list) – The dynamic 3D sequence to be projected.

  • angleAndOriList (list) – A list of tuples containing the angles and axes at which the image should be projected.

  • library (string) – The library to be used for the forward projection. Either ‘tomopy’ or ‘tigre’.

  • nCores (int) – The number of cores to be used for the forward projection.

Returns:

DRRSetSequence – A list of DRR sets.

Return type:

list

computeDRRSet(image, angleAndAxisList, sourceImageName='', library='tomopy', nCores=1)

if image is a CTImage, this should copy the patient info and image ID to be given to the XRayImage else (if it is a numpy array), it should be set to None or created.

Parameters:
  • image (CTImage or numpy array) – The image to be projected.

  • angleAndAxisList (list) – A list of tuples containing the angles and axes at which the image should be projected.

  • sourceImageName (string) – The name of the image to be projected.

  • library (string) – The library to be used for the forward projection. Either ‘tomopy’ or ‘tigre’.

  • nCores (int) – The number of cores to be used for the forward projection.

Returns:

DRRSet – A list of DRRs.

Return type:

list

createDRRDynamic2DSequences(dynamic3DSequence, angleAndAxeList, library='tomopy', nCores=1)

create a DRR Dynamic2DSequence for each image in a list

Parameters:
  • dynamic3DSequence (Dynamic3DSequence or list) – The dynamic 3D sequence to be projected.

  • angleAndAxeList (list) – A list of tuples containing the angles and axes at which the image should be projected.

  • library (string) – The library to be used for the forward projection. Either ‘tomopy’ or ‘tigre’.

  • nCores (int) – The number of cores to be used for the forward projection.

Returns:

dyn2DSeqList – A list of DRR Dynamic2DSequences.

Return type:

list

forwardProjection(image, angleInDeg=0, axis='Z', library='tomopy', nCores=1)

This function takes an image and an angle and returns the forward projection of the image at the given angle.

Parameters:
  • image (CTImage or numpy array) – The image to be projected.

  • angleInDeg (float) – The angle at which the image should be projected.

  • axis (string) – The axis around which the image should be rotated. Either ‘X’, ‘Y’ or ‘Z’.

  • library (string) – The library to be used for the forward projection. Either ‘tomopy’ or ‘tigre’.

  • nCores (int) – The number of cores to be used for the forward projection.

Returns:

drrImage – The forward projection of the image at the given angle.

Return type:

numpy array

getImageInCorrectOrientation(imageArray, orientation)

This function takes an image array and an orientation and returns the image array in the correct orientation. The orientation is given as a string, either ‘X’, ‘Y’ or ‘Z’.

Parameters:
  • imageArray (numpy array) – The image array to be rotated.

  • orientation (string) – The orientation of the image array. Either ‘X’, ‘Y’ or ‘Z’.

Returns:

imageToUse – The image array in the correct orientation.

Return type:

numpy array

opentps.core.processing.imageSimulation.ForwardProjectorTigre module

forwardProjectionTigre(ct, angles, axis='Z', ctIsocenter=None, SAD=1000, SID=1550, flatpanelGridSize=[1440, 1440], flatpanelPixelSpacing=[0.296, 0.296], poissonNoise=100000.0, gaussianNoise=10)

Forward projection of CT image using Tigre toolbox ( https://github.com/CERN/TIGRE/blob/master/Frontispiece/python_installation.md ).

Parameters:
  • ct (CT) – CT object

  • angles (float or list or numpy.ndarray) – Projection angles in radians

  • axis (str, optional) – Axis of CT image to be used for forward projection. The default is ‘Z’.

  • ctIsocenter (numpy.ndarray, optional) – Isocenter of CT image. The default is None.

  • SAD (float, optional) – Source to axis distance in mm. The default is 1000.

  • SID (float, optional) – Source to detector distance in mm. The default is 1550.

  • flatpanelGridSize (list, optional) – Flatpanel grid size in pixels. The default is [1440,1440].

  • flatpanelPixelSpacing (list, optional) – Flatpanel pixel spacing in mm. The default is [0.296,0.296].

  • poissonNoise (float, optional) – Poisson noise level. The default is 1e5.

  • gaussianNoise (float, optional) – Gaussian noise level. The default is 10.

Returns:

projections – Forward projections.

Return type:

numpy.ndarray

opentps.core.processing.imageSimulation.multiProcForkMethods module

DRRsBinarizeAndCrop(image, mask, projectionAngle=0, projectionAxis='Z', outputSize=[])

This function is used to generate a DRR from an image and a mask. It also crops the DRR to remove the black borders.

Parameters:
  • image (numpy array) – Image.

  • mask (numpy array) – Mask.

  • projectionAngle (float, optional) – Projection angle in degrees. The default is 0.

  • projectionAxis (str, optional) – Projection axis. Can be ‘X’, ‘Y’ or ‘Z’. The default is ‘Z’.

  • outputSize (list, optional) – Output size of the DRR. It is a list of two elements: number of rows and number of columns. The default is [].

Returns:

List of DRR, mask and 2D center of mass. Each element of the list is a list of three elements: DRR, mask and 2D center of mass.

Return type:

list

multiProcDRRs(dataList, projAngle, projAxis, outputSize, ncore=None)

This function is used to generate DRRs from a list of images and masks. It uses multiprocessing to speed up the process.

Parameters:
  • dataList (list) – List of images and masks. Each element of the list is a list of two elements: image and mask.

  • projAngle (float) – Projection angle in degrees.

  • projAxis (str) – Projection axis. Can be ‘X’, ‘Y’ or ‘Z’.

  • outputSize (list) – Output size of the DRRs. It is a list of two elements: number of rows and number of columns.

  • ncore (int, optional) – Number of cores used for multiprocessing. If None, all the logical cores of the machine are used. The default is None.

Returns:

croppedImgAndMaskDRRsPlus2DCOM – List of DRRs, masks and 2D center of mass. Each element of the list is a list of three elements: DRR, mask and 2D center of mass.

Return type:

list

Module contents