LIDC_IDRI.py¶
Source: LION/data_loaders/LIDC_IDRI.py
PyTorch dataset adapter for processed LIDC-IDRI axial CT slices.
- class LION.data_loaders.LIDC_IDRI.LIDC_IDRI(mode, geometry_parameters=None, parameters=None)[source]¶
Bases:
DatasetLoad LIDC-IDRI data for image-prior, reconstruction, or segmentation tasks.
- Parameters:
mode ({"train", "validation", "test"}) – Dataset split.
geometry_parameters (Geometry, optional) – Backward-compatible geometry argument.
parameters (LIONParameter, optional) – Dataset settings returned by
default_parameters().
Notes
Processed slices are stored in HU. Image-prior and reconstruction targets are converted to LION normalised intensity. Spatial resizing is performed on CPU before the final device transfer to avoid retaining large 512-square tensors on the GPU for patch training.
- static default_parameters(geometry=None, task='reconstruction')[source]¶
Return default LIDC-IDRI split, sampling, and task parameters.
- get_slices_to_load(patient_list, non_nodule_slices_dict, nodule_slices_dict, num_slices_per_patient, pcg_slices_nodule, all_slices_dict=None)[source]¶
Returns a dictionary that contains patient_id’s as keys and list of slices to load as values for each patient.
- Parameters:
patient_list (List): List that contains patient_id of all patients.
non_nodule_slices_dict (Dict): Dict that contains all slices without nodule of each patient_id.
nodule_slices_dict (Dict): Dict that contains all slices with nodule of each patient_id.
num_slices_per_patient (int): Defines maximum number of slices we want per patient. If num_slices_per_patient=-1 take all slices we have of each patient.
pcg_slices_nodule (float): Defines amount of slices that should contain a nodule. Value between 0-1.
- Returns:
patient_id_to_slices_to_load_dict which contains patient_id as key and list of slices to load as values
- Parameters:
patient_list (List)
non_nodule_slices_dict (Dict)
nodule_slices_dict (Dict)
num_slices_per_patient (int)
pcg_slices_nodule (float)
all_slices_dict (Dict | None)
- get_patient_id_to_first_index_dict(patient_with_slices_to_load)[source]¶
Returns a dictionary that contains patient_id’s as keys and start index of each patient in self.slice_index_to_patient_id_list as value.
- Parameters:
patient_with_slices_to_load (Dict): Dict that defines which slices to load per patient.
- Returns:
patient_id_to_first_index_dict (Dict): Defines start index of each patient in self.slice_index_to_patient_id_list. Needed for mapping of global index to slice index.
- Parameters:
patient_with_slices_to_load (Dict)
- get_slice_index_to_patient_id_list(patient_with_slices_to_load)[source]¶
Returns a list that contains “number of slices” times each patient id.
- Parameters:
patient_with_slices_to_load (Dict): Dict that defines which slices to load per patient.
- Returns:
slice_index_to_patient_id_list (List): Contains number of slices times each patient id. Needed for mapping of global index to slice index.
- Parameters:
patient_with_slices_to_load (Dict)
- get_reconstruction_tensor(file_path)[source]¶
Load and resize one processed HU slice for reconstruction use.
- Parameters:
file_path (Path)
- Return type:
Tensor
- set_sinogram_transform(sinogram_transform)[source]¶
Set an optional transform applied to generated sinograms.