Modules#
okapy.dicomconverter.converter#
- class okapy.dicomconverter.converter.ExtractorConverter(okapy_extractors=None, result_format='long', additional_dicom_tags=None, combine_segmentation=False, **kwargs)[source]#
This class represents an instance used for converting a folder containing DICOM files to NIfTI files. The DICOM files are initially sorted using okapy.dicomconverter.dicom_walker.DicomWalker. Subsequently, the files are organized based on StudyInstanceUID, creating instances of okapy.dicomconverter.study.Study. The processing is then carried out sequentially on each Study instance, enabling the application of the same segmentation (in the form of RTSTRUCT or SEG) across different modalities within the same study.
Additionally, this class performs feature extraction on the NIfTI files if segmentation is provided. To instantiate this class, use the ExtractorConverter.from_params(params_path) method. The params_path is a path pointing to a .yaml file containing all the relevant parameters. An example of a parameters file can be found in the parameters/ folder.
Once the features are extracted, the NIfTI files are deleted. By default they are stored in a temp folder using the python function
tempfile.mkdtemp
.Example usage:
from okapy.dicomconverter.converter import ExtractorConverter params_path = "path/to/parameters.yaml" converter = ExtractorConverter.from_params(params_path) results = converter(folder_path)
results is a pandas dataframe with the features values for each different images and modalities.
- class okapy.dicomconverter.converter.NiftiConverter(output_folder='.', labels_startswith=None, **kwargs)[source]#
This class represents an instance used for converting a folder containing DICOM files to NIfTI files. The DICOM files are initially sorted using okapy.dicomconverter.dicom_walker.DicomWalker. Subsequently, the files are organized based on StudyInstanceUID, creating instances of
okapy.dicomconverter.study.Study
. The processing is then carried out sequentially on each Study instances. This approach allows for application of the same segmentation (in the form of RTSTRUCT or SEG) across different modalities within the same study.
okapy.dicomconverter.dicom_walker#
TODO: Is it better to create a class for just the header and another for the files?
- class okapy.dicomconverter.dicom_walker.DicomWalker(input_dirpath=None, cores=None, additional_dicom_tags=None, submodalities=False)[source]#
Instances of this class are used to crawl in the arborescence of a directory and sort all the DICOM found and order them into
okapy.dicomconverter.study.Study
okapy.dicomconverter.study#
- class okapy.dicomconverter.study.Study(study_instance_uid=None, study_date=None, submodalities=False, additional_dicom_tags=None, patient_id=None)[source]#
This class serves as an abstraction for the StudyInstanceUID in the DICOM context.
Instances of this class are created by the
okapy.dicomconverter.dicom_walker.DicomWalker
and are designed to store DICOM file paths, organized by modality (and optionally by submodalities).
okapy.dicomconverter.dicom_file#
TODO: check NumberOfSlices as dicom tag
- class okapy.dicomconverter.dicom_file.DicomFileBase(dicom_header=None, dicom_paths=[], reference_frame=None, study=None, additional_dicom_tags=None, submodalities=False, slices=None)[source]#
Subclasses of this class represent abstractions of DICOM series, each corresponding to a specific modality (e.g., CT, PT, MR, RTSTRUCT, and SEG). These classes store the DICOM paths of the series and provide a method
get_volume()
that returns aokapy.dicomconverter.volume.Volume
. The Volume class encapsulates a 3D image along with its reference frame.The
get_volume()
method is unique for each subclass and defines how to compute pixel values from DICOM files based on the specific modality.