Load DICOM
imgtools.dicom.load_dicom
load_dicom(
dicom_input: imgtools.dicom.dicom_reader.DicomInput,
force: bool = True,
stop_before_pixels: bool = True,
**kwargs: typing.Any
) -> pydicom.dataset.FileDataset
Load a DICOM file and return the parsed FileDataset object.
This function supports various input types including file paths, byte streams,
and file-like objects. It uses the pydicom.dcmread
function to read the DICOM file.
Notes
- If
dicom_input
is already aFileDataset
, it is returned as is. - If
dicom_input
is a file path or file-like object, it is read usingpydicom.dcmread
. - If
dicom_input
is a byte stream, it is wrapped in aBytesIO
object and then read. - An
InvalidDicomError
is raised if the input type is unsupported.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
pydicom.dataset.FileDataset | str | pathlib.Path | bytes | typing.BinaryIO
|
Input DICOM file as a |
required |
|
bool
|
Whether to allow reading DICOM files missing the File Meta Information header, by default True. |
True
|
|
bool
|
Whether to stop reading the DICOM file before loading pixel data, by default True. |
True
|
|
typing.Any
|
Additional keyword arguments to pass to |
{}
|
Returns:
Type | Description |
---|---|
pydicom.dataset.FileDataset
|
Parsed DICOM dataset. |
Raises:
Type | Description |
---|---|
imgtools.exceptions.InvalidDicomError
|
If the input is of an unsupported type or cannot be read as a DICOM file. |