DICOM File Handling

class pumpia.file_handling.dicom_structures.Patient(patient_id: str, name: str)

Represents a patient from a DICOM file.

Parameters:
  • patient_id (str) – The ID of the patient.

  • name (str) – The name of the patient.

patient_id
Type:

str

name
Type:

str

studies
Type:

list[Study]

tag
Type:

str

id_string
Type:

str

menu_options
Type:

list[tuple[str, Callable[[], None]]]

add_study(study: Study)

Adds a study to the patient.

class pumpia.file_handling.dicom_structures.Study(patient: Patient, study_id: str, study_date: date, study_desc: str)

Represents a DICOM study.

Parameters:
  • patient (Patient) – The patient associated with the study.

  • study_id (str) – The ID of the study.

  • study_date (datetime.date) – The date of the study.

  • study_desc (str) – The description of the study.

patient

The patient associated with the study.

Type:

Patient

study_id

The ID of the study.

Type:

str

study_date

The date of the study.

Type:

datetime.date

study_description

The description of the study.

Type:

str

series
Type:

list[Series]

tag
Type:

str

id_string
Type:

str

menu_options
Type:

list[tuple[str, Callable[[], None]]]

add_series(series: Series)

Adds a series to the study.

class pumpia.file_handling.dicom_structures.Series(study: Study, series_id: str, series_description: str, series_number: int, acquisition_number: int, instance_number: int | None = None, is_stack: bool = False, open_dicom: Dataset | None = None, filepath: Path | None = None)

Represents a DICOM series. Has the same attributes and methods as ImageCollection unless stated below.

Parameters:
  • study (Study) – The study associated with the series.

  • series_id (str) – The ID of the series.

  • series_description (str) – The description of the series.

  • series_number (int) – The number of the series.

  • acquisition_number (int) – The acquisition number of the series.

  • instance_number (int) – The instance number of the series. Required if series is a stack, ignored otherwise.

  • is_stack (bool, optional) – Whether the series is a stack (default is False).

  • open_dicom (pydicom.Dataset, optional) – The open DICOM dataset (default is None).

  • filepath (Path, optional) – The file path of the series (default is None).

study

The study associated with the series.

Type:

Study

series_id

The ID of the series.

Type:

str

series_number

The number of the series.

Type:

int

acquisition_number

The acquisition number of the series.

Type:

int

instance_number

The instance number of the series. Int if series is a stack, None otherwise.

Type:

int

series_description

The description of the series.

Type:

str

is_stack

Whether the series is a stack.

Type:

bool

loaded

Whether the series is loaded.

Type:

bool

dicom_dataset
Type:

pydicom.Dataset | None

instances
Type:

list[Instance]

raw_array
Type:

np.ndarray

add_instance(instance: 'Instance')

Adds an instance to the series.

get_tags(tag: Tag) list

Gets the values of a dicom tag for all instances in the series.

get_tag(tag: Tag, instance_number: int)

Gets the value of a tag for a specific instance in the series.

class pumpia.file_handling.dicom_structures.Instance(series: Series, slice_number: int, filepath: Path | None = None, is_frame: bool = False, dimension_index_values: list | tuple | None = None, open_dicom: Dataset | None = None)

Represents a DICOM instance if file has 1 frame or a frame if file has multiple frames. Has the same attributes and methods as FileImageSet unless stated below.

Parameters:
  • series (Series) – The series associated with the instance.

  • slice_number (int) – The slice number of the instance. For a frame this will be the frame number, otherwise this will be the instance number.

  • filepath (Path, optional) – The file path of the instance (default is None).

  • is_frame (bool, optional) – Whether the instance is a frame (default is False).

  • dimension_index_values (list or tuple, optional) – The dimension index values of the instance (default is None).

series

The series associated with the instance.

Type:

Series

slice_number

The slice number of the instance.

Type:

int

is_frame

Whether the instance is a frame.

Type:

bool

dimension_index_values

The dimension index values of the instance.

Type:

tuple | None

loaded

Whether the instance is loaded.

Type:

bool

dicom_dataset
Type:

pydicom.Dataset | None

raw_array
Type:

np.ndarray

get_tag(tag: Tag)

Gets the value of a tag for the instance.