DeteCTDataset#

class deepinv.datasets.DeteCTDataset(root, problem='full', n_angles=3600, slice_ids='all', use_dict_output=False)[source]#

Bases: ImageDataset

2DeteCT dataset of 2D Computed Tomography acquisitions.

The dataset was acquired by Kiss et al.[1] and used for benchmarking CT reconstruction algorithms in Kiss et al.[2]. The data is industrial CT projection data (i.e. sinograms) of various materials acquired using a proprietary scanner from Centrum Wiskunde & Informatica. The samples contain materials resembling the attenuation of human anatomy; see Kiss et al.[1] for more details.

The projections (shape (1,n_angles,956)) are preprocessed (flat/dark-corrected, log-transformed, all in PyTorch) following LION such that the setup matches exactly Kiss et al.[2], such that the dataset can be used to compare DeepInverse image reconstruction methods with the values reported in Kiss et al.[2].

Each sample is scanned 3 times: mode1, mode2 and mode3. See below for their usage.

“Ground truth” x are also provided as iterative recons using all angles, of shape (1,1024,1024).

To download the data from Zenodo, use download_dataset, which extracts each archive into the 2DeteCT_slicesXXXX-YYYY (+ _RecSeg) subfolders in root. Note: for the test set, you only need to download slices 4001-5000, i.e. do dinv.datasets.DeteCTDataset.download_dataset(root='/path/to/2DeteCT', blocks='test').

Parameters:
  • root (str, pathlib.Path) – root dir, should contain subfolders named 2DeteCT_slicesXXXX-YYYY (+ _RecSeg)

  • problem (str) – benchmarking problem from 2DeteCT. - full: mode2 acquired data (3600 projections) - sparse_view: mode2 acquired data then evenly subsampled - limited_angle: mode2 acquired data then limited angles taken - low_dose: mode1 acquired data (3W instead of 90W) - beam_hardening: mode3 acquired data (acquired without a filter, leading to beam-hardening)

  • n_angles (int) – kept projections for sparse_view/limited_angle, defaults to 3600 (i.e. all angles).

  • slice_ids (str) – all (default, every slice found from 1-5000), train/val/test (LION 3930/550/470 sample split), or ood (out-of-distribution slices 5521-6370).

  • use_dict_output (bool) – whether to return output as dict with keys “x”, “y”, “params” instead of tuple (default False).

Examples:

Download a single sample slice (ID 4531) from HuggingFace and load it:

>>> import shutil, deepinv as dinv
>>> from deepinv.datasets import DeteCTDataset, download_archive
>>> download_archive(dinv.utils.get_image_url("2DeteCT_slices_4001-5000_slice04531.zip"), "2DeteCT/data.zip", extract=True)
>>> x, y = DeteCTDataset("2DeteCT", slice_ids="test")[0]
>>> print(x.shape, y.shape) # (1,H,W), (1, num_angles, detector length)
torch.Size([1, 1024, 1024]) torch.Size([1, 3600, 956])
>>> shutil.rmtree("2DeteCT")


References:

static download_dataset(root, blocks='all', force_download=False)[source]#

Download and extract the 2DeteCT archives from Zenodo into root.

Each block’s raw data and reference reconstructions (RecSeg) are extracted into the 2DeteCT_slicesXXXX-YYYY (+ _RecSeg) subfolders expected by the dataset.

Warning

The archives are very large (up to ~34GB each); blocks="all" needs several hundred GB of disk.

Parameters:
  • root (str, pathlib.Path) – dir to download into (same root passed to init).

  • blocks (str, list) – which slice ranges to download: "all" (slices 1-5000), "test" (only slices 4001-5000, i.e. the benchmark test set), "ood" (out-of-distribution slices 5521-6370), or a list of ranges from ["1-1000", "1001-2000", "2001-3000", "3001-4000", "4001-5000", "OOD"].

  • force_download (bool) – re-download even if the archive already exists.

static get_astra_geometry(problem='full', n_angles=None)[source]#

Get astra object geometry and project geometry for 2DeteCT setup.

Construct geometry objects to pass to deepinv.physics.TomographyWithAstra in order to test physics-conditioned algorithms on the 2DeteCT benchmark.

The object geometry values and fan-beam projection geometry values are taken from LION.

The projection geometry is defined as conebeam with one detector row.

Usage

import deepinv as dinv
obj_geom, proj_geom = dinv.datasets.DeteCTDataset.get_astra_geometry()
physics = dinv.physics.TomographyWithAstra(
    object_geometry=obj_geom,
    projection_geometry=proj_geom,
    is_2d=True, # important
    normalize=True,
    device=device,
    noise_model=dinv.physics.PoissonGaussianNoise(),
)
Parameters:
  • problem (str) – 2DeteCT benchmark problem, either “sparse_view” or “limited_angle”, for how to undersample angles.

  • n_angles (int) – for sparse_view or limited_angle, how many angles.

Return tuple:

obj_geom dict, proj_geom dict

Return type:

tuple

Examples using DeteCTDataset:#

Reconstruct real CT sinograms with the 2DeteCT benchmark

Reconstruct real CT sinograms with the 2DeteCT benchmark