cleanX.dicom_processing.source module

class cleanX.dicom_processing.source.Source

Bases: ABC

This class is provided as a helper for those who want to implement their own sources.

It is not necessary to extend this class. cleanX code doesn’t do type checking, but if you want to ensure type checking on your side, you may inherit from this class.

abstract get_tag()

The value returned from this function should be suitable for pandas to name a column.

abstract items(reader, transformer=None)

This function will be expected to produce file names or file-like objects of DICOM files. The results will be then fed to either pydicom or SimpleITK libraries for metadata extraction.

This function should return a generator yielding a tuple of two elements. First element will be inserted into the source column (the one labeled by get_tag() method), the second is the result of calling reader.

Parameters:
  • reader – A function that takes an individual source, either a file path or a file-like object, and returns the processed metadata.

  • transformer – Optionally, the caller of this function will supply a transformer function that needs to be called on the value that will be stored in the source column of the resulting DataFrame

class cleanX.dicom_processing.source.DirectorySource(directory, tag)

Bases: object

Class to aid reading DICOMs, package agnostically

__init__(directory, tag)
get_tag()
items(reader, transformer=None)
class cleanX.dicom_processing.source.GlobSource(exp, tag, recursive=True)

Bases: object

Class to aid finding files from path (for later reading out DICOM)

__init__(exp, tag, recursive=True)
get_tag()
items(reader, transformer=None)
class cleanX.dicom_processing.source.MultiSource(tag, *sources)

Bases: object

__init__(tag, *sources)
get_tag()
items(reader, transformer=None)
cleanX.dicom_processing.source.rename_file(original, target, ext)