cleanX.dicom_processing.simpleitk_adapter module¶
- class cleanX.dicom_processing.simpleitk_adapter.MetadataHelper(reader)¶
Bases:
object
Class for getting DICOM metadata with SimpleITK.
- __init__(reader)¶
Initializes this helper with the instance of SimpleITK.ImageFileReader
- Parameters:
reader (SimpleITK.ImageFileReader) – The SimpleITK redader used to read DICOM to extract metadata.
- fetch_metadata(dicom_file)¶
Reads enough of the DICOM file to fetch its metadata.
- class cleanX.dicom_processing.simpleitk_adapter.SimpleITKDicomReader(date_fields=None, time_fields=None, exclude_fields=None)¶
Bases:
object
Class for reading DICOM metadata with SimpleITK.
- __init__(date_fields=None, time_fields=None, exclude_fields=None)¶
Initializes this reader with flags.
- Parameters:
date_fields (Iterable) – Overrides the default values from
date_fields
.time_fields – Overrides the default values from
time_fields
.exclude_fields (Iterable) – Overrides the default values from
exclude_fields
.
- date_fields = {'Content Date', 'Series Date', 'Study Date'}¶
Default fields in the parsed DICOM file to be interpreted as date.
- time_fields = {'Content Time', 'Study Time'}¶
Default fields in the parsed DICOM file to be interpreted as datetime.
- exclude_fields = {}¶
Default fields to exclude from dataframe generated form DICOM files.
- dicom_time_to_time(source)¶
Utility method to help translate DICOM date and time objects to python
datetime
.Warning
This isn’t implemented yet. Needs research on DICOM time representation.
- rip_out_jpgs(source, destination)¶
Extract image data from DICOM files and save it as JPG in
destination
.- Parameters:
source (
Source
) – A source generator. For extended explanation seeSource
.destination (Compatible with
os.path.join()
) – The name of the directory where JPG files should be stored.
- cleanX.dicom_processing.simpleitk_adapter.rip_out_jpgs_sitk(dicomfile_directory, output_directory)¶
This function is for users with simpleITK library only. If you do not have the library it will throw an error. The function function jpeg files out of a dicom file directory, one by one, each of them (not just the first series as), and puts them in an out put directory. It also returns the images for inspection (as arrays), which you can look at the [0] layer with
matplotlib
- Parameters:
- Returns:
List of images represented as NumPy arrays.
- Return type:
List[numpy.ndarray]