dosma.DicomWriter
- class dosma.DicomWriter(num_workers: int = 0, verbose: bool = False, fname_fmt: Optional[str] = None, sort_by: Optional[Union[str, int, Sequence[Union[str, int]]]] = None)[source]
A class for writing volumes in DICOM format.
- Variables
num_workers (int, optional) – Number of workers to use for writing.
verbose (bool, optional) – If
True, show writing progress bar.fname_fmt (str, optional) – Formatting string for filenames.
sort_by (
str(s)orint(s), optional) – DICOM attribute(s) used to define ordering of slices prior to writing. If not specified, this ordering will be defined by the order of blocks involume.data_format_code (ImageDataFormat) – The supported image data format.
Examples
>>> # Save MedicalVolume mv >>> dw = DicomWriter() >>> dw.save(mv, "/path/to/save/folder")
>>> dw = DicomWriter(fname_fmt="I%05d.dcm", sort_by="InstanceNumber") >>> dw.save(mv, "/path/to/save/folder")
- __init__(num_workers: int = 0, verbose: bool = False, fname_fmt: Optional[str] = None, sort_by: Optional[Union[str, int, Sequence[Union[str, int]]]] = None)[source]
- Parameters
num_workers (int, optional) – Number of workers to use for writing.
verbose (bool, optional) – If
True, show writing progress bar.fname_fmt (str, optional) – Formatting string for filenames. Must contain
%d, which correspopnds to slice number. Defaults to"I%0{max(4, ceil(log10(num_slices)))}d.dcm"(e.g."I0001.dcm").sort_by (str(s) or int(s), optional) – DICOM attribute(s) used to define ordering of slices prior to writing. If not specified, this ordering will be defined by the order of blocks in
volume.
Methods
__init__([num_workers, verbose, fname_fmt, ...])- param num_workers
Number of workers to use for writing.
load_state_dict(state_dict)Loads the state dictionary into the object.
save(volume, dir_path[, fname_fmt, sort_by])Save medical volume in dicom format.
state_dict()Returns the state dictionary for an object.
Attributes
data_format_code