importers
Methods that assist in importing CT scans of rock cores.
- core_ct.importers.dicom(dir: str | None = None, files: list[str] | None = None, force: bool = False, ignore_hidden_files: bool = True, ignore_file_extensions: bool = False) Core[source]
Load a DICOM dataset into a Core object.
This is used to load a set of images into one core object. All images must come from the same CT scan of the same core.
Files containing the DICOM dataset can be specified by providing a directory or a list of files. If both dir and files are provided, dir will be ignored.
When specifying a directory all files in that directory will be treated as part of the DICOM dataset. If this is undesirable, use files instead.
Subfolders/directories are ignored. All dicom data files must be explicitly specified via files or located in the dir provided.
- Parameters:
dir (str) – Path to directory containing DICOM dataset; ignored if files is specified
files (list[str]) – List of filepaths belonging to DICOM dataset
force (bool) – If set to True, files that produce errors will be ignored
ignore_hidden_files (bool) – If set to True, hidden files (names starting with “.”) will be ignored
- Raises:
ValueError – If no files are found. Caused by providing an empty directory (dir) or an empty files list. Also raised when files are missing header information.
RuntimeError – If no data was loaded. Happens when no files can be parsed and force is set to True
pydicom.InvalidDicomError – If pydicom fails to parse a file
- core_ct.importers.dicom_slice(file: str, force: bool = False) Slice[source]
Load a DICOM dataset into a Slice object.
This function should be used when you only want to load one image/scan instead of a collection.
- Parameters:
- Raises:
ValueError – If the file is missing header information.
pydicom.InvalidDicomError – If pydicom fails to parse the file