LidcIdriSliceDataset#

class deepinv.datasets.LidcIdriSliceDataset(root=None, transform=None, hounsfield_units=False, use_dict_output=False)#

Bases: ImageDataset

Dataset for LIDC-IDRI that provides access to CT image slices.

Published in Armato III et al.[1].

The Lung Image Database Consortium image collection (LIDC-IDRI) consists
of diagnostic and lung cancer screening thoracic computed tomography (CT)
scans with marked-up annotated lesions.

Warning

To download the raw dataset, you will need to install the NBIA Data Retriever, then download the manifest file (.tcia file) here, and open it by double clicking.

Raw data file structure:

self.root --- LIDC-IDRI --- LICENCE
           |             -- LIDC-IDRI-0001 --- `STUDY_UID` --- `SERIES_UID` --- xxx.xml
           |             |                                                   -- 1-001.dcm
           |             -- LIDC-IDRI-1010                                   |
           |                                                                 -- 1-xxx.dcm
           -- metadata.csv
0) There are 1010 patients and a total of 1018 CT scans.
1) Each CT scan is composed of 2d slices.
2) Each slice is stored as a .dcm file
3) This class gives access to one slice of a CT scan per data sample.
4) Each slice is represented as an (512, 512) array.
Parameters:
  • root (str) – Root directory of dataset. Directory path from where we load and save the dataset.

  • transform: (Callable) – (optional) A function/transform that takes in a data sample and returns a transformed version.

  • hounsfield_units (bool) – If True, convert pixel values to Hounsfield Units (HU). Default is False.

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


Examples:

Instantiate dataset

import torch
from deepinv.datasets import LidcIdriSliceDataset
root = "/path/to/dataset/LIDC-IDRI"
dataset = LidcIdriSliceDataset(root=root)
dataloader = torch.utils.data.DataLoader(dataset, batch_size=2, shuffle=True)
batch = next(iter(dataloader))
print(batch.shape)

Note

This class requires the pandas and pydicom packages to be installed. Install them with pip install pandas and pip install pydicom.


References:

class SliceSampleIdentifier(slice_fname, scan_folder, patient_id)#

Bases: NamedTuple

Data structure for identifying slices.

In LIDC-IDRI, there are 1010 patients. Among them, 8 patients have each 2 CT scans.

Parameters:
  • slice_fname (str) – Filename of a dicom file containing 1 slice of the scan.

  • scan_folder (str) – Path to all dicom files from the same scan.

  • patient_id (str) – Foldername of one patient among the 1010.

patient_id: str#

Alias for field number 2

scan_folder: str#

Alias for field number 1

slice_fname: str#

Alias for field number 0