Utilities#

Simulation and test data#

tigre.utilities.CTnoise.add(projections, Gaussian=None, Poisson=None)#

Add realistic noise to simulated projections.

Converts the line integrals to photon counts, adds Poisson (quantum) noise and Gaussian (electronic) noise, and converts back. Available as tigre.utilities.CTnoise.add.

Parameters:
  • projections (numpy.ndarray) – Noise-free projections (line integrals).

  • Gaussian (numpy.ndarray, optional) – Mean and standard deviation of the electronic noise, in photon counts, shape (2,). Default [0, 0.5].

  • Poisson (float, optional) – Photon count of an unattenuated ray (I0). Lower values give noisier data. Default 60000, as MATLAB’s addCTnoise.

Returns:

numpy.ndarray – Noisy projections, float32, same shape.

Examples

>>> from tigre.utilities import CTnoise
>>> noisy = CTnoise.add(proj, Poisson=1e5, Gaussian=np.array([0, 10]))
tigre.utilities.sample_loader.load_head_phantom(number_of_voxels=None)#

The head phantom used in TIGRE’s demos and tests.

Parameters:

number_of_voxels (numpy.ndarray, optional) – Size (z, y, x) to resample the phantom to. Default (128, 128, 128).

Returns:

numpy.ndarray – The phantom, float32, with values roughly between 0 and 1.

Denoising#

tigre.utilities.im_3d_denoise.im3ddenoise(img, iter=50, lmbda=15.0, gpuids=None)#

Total variation denoising of a 3D image, on the GPU.

Parameters:
  • img (numpy.ndarray) – Image, float32, shape (z, y, x).

  • iter (int, optional) – Number of iterations. Default 50.

  • lmbda (float, optional) – Data-fidelity weight: larger values keep the result closer to img, so they denoise less. Default 15.

  • gpuids (tigre.utilities.gpu.GpuIds, optional) – GPUs to use. Default: all available.

Returns:

numpy.ndarray – The denoised image.

Image quality#

tigre.utilities.Measure_Quality.Measure_Quality(res_prev, res, QualMeasOpts)#
Parameters:
  • res_prev – (np.ndarray) object being compared to

  • res – (np.ndarray) true image

  • QualMeasOpts – (str or listof(str)) any of: ‘RMSE’, ‘nRMSE’ , ‘CC’, ‘MSSIM’, ‘UQI’, ‘SSD’

Returns:

GPUs#

See also GPUs and memory.

class tigre.utilities.gpu.GpuIds(nameGPU=None)#

A set of GPUs for TIGRE to use.

Pass it to any operator or algorithm with gpuids=.

Parameters:

nameGPU (str, optional) – Only GPUs with exactly this name (see getGpuNames()). Default: all GPUs.

devices#

CUDA device numbers. Set it to choose devices by number.

Type:

list of int

name#

The name the GPUs were selected by.

Type:

str

Examples

>>> from tigre.utilities.gpu import GpuIds, getGpuNames
>>> getGpuNames()
['NVIDIA RTX A6000', 'NVIDIA RTX A6000']
>>> gpuids = GpuIds()          # all GPUs
>>> gpuids.devices = [0]       # only the first one
tigre.utilities.gpu.getGpuNames()#

Names of the installed GPUs, one per device.

Returns:

list of str

tigre.utilities.gpu.getGpuIds(gpuName=None)#

GPUs whose name matches gpuName; the same as GpuIds(gpuName).

Returns:

GpuIds