skrt.patient module

Classes related to Patients and Studies.

class skrt.patient.Patient(path='', exclude=None, unsorted_dicom=None, id_mappings=None)

Bases: PathData

Object associated with a top-level directory whose name corresponds to a patient ID, and whose subdirectories contain studies.

__init__(path='', exclude=None, unsorted_dicom=None, id_mappings=None)

Create instance of Patient class.

Parameters:

pathstr/pathlib.Path/None, default=””

Relative or absolute path to a directory containing patient data. If None, the path used is the path to the current working directory.

excludelist, default=None

List of first-level sub-directories to disregard when loading patient data organised accoding to the VoxTox model (patient -> studies -> modalites). If None, then set to [“logfiles”]. Ignored if <unsorted_dicom> set to True.

unsorted_dicombool, default=False

If True, don’t assume that patient data are organised accoridng to the VoxTox model, and create data hierarchy based on information read from DICOM files.

id_mappingsdict, default=None

By default, the patient identifier is set to be the name of the directory that contains the patient data. The id_mappings dictionary allows mapping from the default name (dictionary key) to a different name (associated value).

add_study(subdir='', timestamp=None, images=None, image_type='ct')

Add a new study.

combined_files(attr, min_date=None, max_date=None)

Get list of all files of a given data type <attr> associated with this patient, within a given date range if specified.

combined_files_by_dir(attr, min_date=None, max_date=None)

Get dict of all files of a given data type <attr> associated with this patient, within a given date range if specified. The dict keys will be the directories that the files are in.

combined_objs(attr, subdir=None)

Get list of objects across all studies associated with this patient.

Optionally restrict to studies within a given sub-directory.

Parameters:

attrstr

Attribute name, identifying list of objects associated with a study. If attr ends with ‘_types’, then objects of all listed types are retrieved.

subdirstr, default=None

Subdirectory grouping studies. If specified, only studies in this subdirectory are considered.

combined_types(cls, subdir=None)

Get list of object types across all studies, for a given class.

Optionally restrict to studies within a given sub-directory.

Parameters:

clsstr

Class name (case insensitive), for which types of object are to be retrieved.

subdirstr, default=None

Subdirectory grouping studies. If specified, only studies in this subdirectory are considered.

copy(outdir='.', to_keep='all', overwrite=True, structure_set='all')

Copy patient dataset, with optional filtering.

Parameters:

outdirstr/pathlib.Path, default = ‘.’

Output directory to which patient dataset is to be copied.

to_keepstr/list, default = ‘all’

Specification of data types to be copied. If ‘all’, all data are copied. If a list, only data from the listed study ubdirectories are copied. For example, to_keep=[‘CT’, ‘RTSTRUCT/CT’] would result in copying of only CT images and associated structure sets.

overwritebool, default=True

If True, delete any existing patient directory, and its contents, in the output directory before copying.

structure_setstr/int/list, default = ‘all’

Select structure set(s) to copy. If ‘all’, all structure sets are copied. If an integer or list of integers, a sorted list of structure sets for each image set is created, and only structure sets at the indicated positions in this list are copied. For example, structure_set=[0, -1] would result in the first and last structure sets being copied.

copy_dicom(outdir='.', studies_to_copy=None, overwrite=True, **kwargs)

Copy patient dicom data.

Parameters: outdir - str, default=’.’

Top-level output directory. Within this, there will be a patient sub-directory, containing a sub-directory for each study, containing in turn a sub-directory for each data modality.

studies_to_copy: list/dict, default=None

List of indices of studies for which data are to be written, 0 being the earliest study and -1 being the most recent: or a dictionary where keys will be used as names of subdirectories grouping studies, and values are indices of studies to be grouped. If set to None, data for all studies are written, keeping any existing grouping.

overwritebool, default=True

If True, delete and recreate patient sub_directory before copying files. If False and the patient sub-directory exists already, copy files to the existing directory.

**kwargs
Keyword arguments passed on to

skrt.patient.Study.copy_dicom().

For details, see this method’s documentation.

get_age()

Get patient’s age.

(This will be missing, or approximate, in anonymised data.)

get_birth_date()

Get patient’s date of birth.

(This will be missing, or incomplete, in anonymised data.)

get_dose_info(collections=None, dose_types=None, df=False)

Retrieve information about dose.

Parameters:

collectionsdict, default=None

Dictionary where keys define types of patient grouping, and values are lists defining specific groupings of this type. For example, {‘cohort’ : [‘discovery’, ‘consolidation’]} defines two patient cohorts - a discovery cohort and a consolidation cohort. It’s assumed that specific groupings are included in data paths. If None, an empty dictionary is used.

dose_typeslist, default=None

List of strings indicating types of dose for which information is to be retrieved. If None, information is retrieved for all dose types in the patient dataset.

dfbool, default=False

If False, return summary information as a dictionary. If True, return summary information as a pandas dataframe.

get_dose_sum(strategies=[('FRACTION', 'PLAN'), ('BEAM',)], set_image=True, force=False)

Get dose summed over dose objects.

This method has been tested using datasets for patients from the IMPORT trials. It may not be generally valid.

Parameters:

strategieslist, default=[(“FRACTION”, “PLAN”,), (“BEAM”,)]

List of tuples of dose summation types to be used in a summation strategy. Each strategy is considered in turn, until a non-zero dose sum is obtained. The default strategy if first to try summing doses with summation type “FRACTION” or “PLAN”, and if this gives a null result to try summing doses with summation type “BEAM”.

set_imagebool/skrt.image.Image, default=True

If True or an Image object, associate an image to the summed dose, and resize the summed dose as needed to match the image geometry. The image associated is the input Image object, of for boolean input is the image with most voxels associated with any of the doses in the sum.

forcebool, default=False

If False, return the result of any previous dose summation. If True, sum doses independently of any previous result.

get_doses(subtypes=None, associations=None, subdirs=None)

Get list of patient-associated doses of specified subtype(s).

Doses may be taken across all studies, or across studies within specified sub-directories.

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of doses to be returned. A subtype may correspond to the modality of the image associated with a dose, or may be the generic identifier “rtdose” if there is no associated image. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the doses to be returned. For example, associations=[“image”] indicates that Dose objects without an associated Image object are to be disregarded. If None, there are no required associations.

subdirsstr/list, default=None

Subdirectory, or list of subdirectories, grouping studies. If specified, only studies in this subdirectory, or in these subdirectories, are considered.

get_groupings(collections=None)

Obtain dictionary of information on patient groupings.

collectionsdict, default=None

Dictionary where keys define types of patient grouping, and values are lists defining specific groupings of this type. For example, {‘cohort’ : [‘discovery’, ‘consolidation’]} defines two patient cohorts - a discovery cohort and a consolidation cohort. It’s assumed that specific groupings are included in patient data paths. If None, an empty dictionary is used.

get_image_info(collections=None, image_types=None, min_delta=4, unit='hour', df=False)

Retrieve information about images.

Parameters:

collectionsdict, default=None

Dictionary where keys define types of patient grouping, and values are lists defining specific groupings of this type. For example, {‘cohort’ : [‘discovery’, ‘consolidation’]} defines two patient cohorts - a discovery cohort and a consolidation cohort. It’s assumed that specific groupings are included in data paths. If None, an empty dictionary is used.

image_typeslist, default=None

List of strings indicating types of image for which information is to be retrieved, for example [‘ct’, ‘mr’]. If None, information is retrieved for all image types in the patient dataset.

min_deltaint/pandas.Timedelta, default=4

Minimum time interval required between image objects. If an integer, the unit must be specified.

unitstr, default=’hour’

Unit of min_delta if the latter is specified as an integer; ignored otherwise. Valid units are any accepted by pandas.Timedelta: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Timedelta.html

dfbool, default=False

If False, return summary information as a dictionary. If True, return summary information as a pandas dataframe.

get_images(subtypes=None, associations=None, subdirs=None)

Get list of patient-associated images of specified subtype(s).

Images may be taken across all studies, or across studies within specified sub-directories.

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of images to be returned. A subtype corresponds to an imaging modality, for example “ct”, “mr”, “us”. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the images to be returned. For example, associations=[“structure_sets”] indicates that Image objects without at least one associated StructureSet object are to be disregarded. If None, there are no required associations.

subdirsstr/list, default=None

Subdirectory, or list of subdirectories, grouping studies. If specified, only studies in this subdirectory, or in these subdirectories, are considered.

get_info(collections=None, data_labels=None, image_types=None, dose_types=None, plan_image_type=None, treatment_image_type=None, min_delta=4, unit='hour', df=False)

Retrieve patient summary information.

Parameters:

collectionsdict, default=None

Dictionary where keys define types of patient grouping, and values are lists defining specific groupings of this type. For example, {‘cohort’ : [‘discovery’, ‘consolidation’]} defines two patient cohorts - a discovery cohort and a consolidation cohort. It’s assumed that specific groupings are included in data paths. If None, an empty dictionary is used.

data_labelslist, default=None

List of strings specifying labels of data associated with a study. If None, the list used is: [‘image’, ‘structure_set’, ‘dose’, ‘plan’].

image_typeslist, default=None

List of strings indicating types of image for which information is to be retrieved, for example [‘ct’, ‘mr’]. If None, information is retrieved for all image types in the patient dataset. Ignored if ‘image’ isn’t included in data_labels.

plan_image_typestr, default=None

String identifying type of image recorded for treatment planning.

treatment_image_typestr, default=None

String identifying type of image recorded at treatment time.

min_deltaint/pandas.Timedelta, default=4

Minimum time interval required between image objects. If an integer, the unit must be specified.

unitstr, default=’hour’

Unit of min_delta if the latter is specified as an integer; ignored otherwise. Valid units are any accepted by pandas.Timedelta: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Timedelta.html

dfbool, default=False

If False, return summary information as a dictionary. If True, return summary information as a pandas dataframe.

get_objs(dtype, subtypes=None, associations=None, subdirs=None)

Get list of patient-associated objects of specified type and subtype(s).

Objects may be taken across all studies, or across studies within specified sub-directories.

Returned objects are sorted by timestamp (earliest first).

Parameters:

dtype: str

String identifying type of objects to be returned. This may be any of: “image”, “structure_set”, “dose”, “plan”.

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of objects to be returned. A subtype may correspond to an imaging modality, for example “ct”, “mr”, “us”, or may be a generic identifier, for example “rtstruct”, “rtdose”, “rtplan”. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the objects to be returned. For example, associations=[“image”] indicates that objects without an associated Image object are to be disregarded. If None, there are no required associations.

subdirsstr/list, default=None

Subdirectory, or list of subdirectories, grouping studies. If specified, only studies in this subdirectory, or in these subdirectories, are considered.

get_plan_info(collections=None, plan_types=None, df=False, plan_filter=None)

Retrieve information about treatment plans.

Parameters:

collectionsdict, default=None

Dictionary where keys define types of patient grouping, and values are lists defining specific groupings of this type. For example, {‘cohort’ : [‘discovery’, ‘consolidation’]} defines two patient cohorts - a discovery cohort and a consolidation cohort. It’s assumed that specific groupings are included in data paths. If None, an empty dictionary is used.

plan_typeslist, default=None

List of strings indicating types of plan for which information is to be retrieved. If None, information is retrieved for all plan types in the patient dataset.

dfbool, default=False

If False, return summary information as a dictionary. If True, return summary information as a pandas dataframe.

plan_filterstr, default=None

String specifying if filtering is to be performed: - “first_only” : retrieve information only for first plan found; - “first_of_each_type” : retrieve information only for the

first plan found of each type;

  • any other value : no filtering.

get_plans(subtypes=None, associations=None, subdirs=None)

Get list of patient-associated plans of specified subtype(s).

Plans may be taken across all studies, or across studies within specified sub-directories.

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of plans to be returned. A subtype may correspond to the modality of the image associated with a dose, or may be the generic identifier “rtplan” if there is no associated image. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the plans to be returned. For example, associations=[“structure_set”] indicates that Plan objects without an associated StructureSet object are to be disregarded. If None, there are no required associations.

subdirsstr/list, default=None

Subdirectory, or list of subdirectories, grouping studies. If specified, only studies in this subdirectory, or in these subdirectories, are considered.

get_sex()

Get patient’s sex.

get_structure_set_info(collections=None, roi_names=None, ss_types=None, df=False, ss_filter=None, origin=None)

Retrieve information about structure sets.

Parameters:

collectionsdict, default=None

Dictionary where keys define types of patient grouping, and values are lists defining specific groupings of this type. For example, {‘cohort’ : [‘discovery’, ‘consolidation’]} defines two patient cohorts - a discovery cohort and a consolidation cohort. It’s assumed that specific groupings are included in data paths. If None, an empty dictionary is used.

roi_namesdict, default=None

Dictionary of names for renaming ROIs, where the keys are new names and values are lists of possible names of ROIs that should be assigned the new name. These names can also contain wildcards with the ‘*’ symbol. Infomration is retrieved only relative to ROIs that, after renaming, have names included in the keys. If None, no renaming is performed, and information is retrieved relative to all ROIs.

ss_typeslist, default=None

List of strings indicating types of structure set for which information is to be retrieved. If None, information is retrieved for all structure-set types in the patient dataset.

dfbool, default=False

If False, return summary information as a dictionary. If True, return summary information as a pandas dataframe.

ss_filterstr, default=None

String specifying if filtering is to be performed: - “first_only” : retrieve information only for first structure

set found;

  • “first_of_each_type” : retrieve information only for the first structure set found of each type;

  • “last_only” : retrieve information only for last structure set found;

  • “last_of_each_type” : retrieve information only for the last structure set found of each type;

  • any other value : no filtering.

origintuple/str, default=None

Tuple specifying the (x, y, z) coordinates of the point with respect to which structure-set extents are to be determined, or a string specifying how to calculate this point:

  • foreground_centroid: take point to be the foreground centroid for the associated image.

If None, then (0, 0, 0) is used.

get_structure_set_with_image(roi_names=None, modality=None, study_index=None, structure_set_index=None, filter_rois=False, link_image=False, clone=False)

Get structure set containing specified ROIs, and with an associated image of a given modality.

The first encountered structure set satisfying constraints is returned. If no structure set satisfies constraints, None is returned.

Parameters:

roi_namesdict, default=None

Dictionary where keys are the nominal names of required ROIs, and values are lists of possible aliases. If None, there will be no selection on ROIs.

modalitystr, default=None

Modality of image that should be associated with the structure set returned. If None, there will be no selection on image modality.

study_indexint, default=None

Index of the study to be considered. If None, all studies are considered.

structure_set_indexint, default=None

Index of the structure set to be considered within a study. If None, all structure sets within the study are considered.

filter_roisbool, default=True

If True, filter and rename ROIs of selected structure set, to match the keys of <roi_names>. Otherwise, return structure set unmodified. Ignored if <roi_names> is None.

link_imagebool, default=False

If True, assign selected structure set to be the only structure set linked to its associated image. If False, the associated image won’t be modified, and may be linked to more than one structure set.

clonebool, default=False

If True, clone the selected structure set and its associated image, perform any modification (ROI filtering and renaming, one-to-one linking of structure set and image), and return the cloned structure set, associated to cloned image. If False, return the originals, with any modification performed on these.

get_structure_sets(subtypes=None, associations=None, subdirs=None)

Get list of patient-associated structure sets of specified subtype(s).

Structure sets may be taken across all studies, or across studies within specified sub-directories.

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of structure sets to be returned. A subtype may correspond to the modality of the image associated with a structure set, or may be the generic identifier “rtstruct” if there is no associated image. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the structure sets to be returned. For example, associations=[“image”] indicates that StructureSet objects without an associated Image object are to be disregarded. If None, there are no required associations.

subdirsstr/list, default=None

Subdirectory, or list of subdirectories, grouping studies. If specified, only studies in this subdirectory, or in these subdirectories, are considered.

get_studies(subdirs=None)

Get list of studies for this patient.

Optionally restrict to studies within specified sub-directories.

Parameter:

subdirsstr/list, default=None

Subdirectory, or list of subdirectories, grouping studies. If specified, only studies in this subdirectory, or in these subdirectories, are considered.

get_subdir_studies(subdir='')

Get list of studies within a given subdirectory.

last_in_interval(attr=None, min_date=None, max_date=None)

Get the last object of a given attribute <attr> in a given date interval.

Add to data objects a reference to the associated patient object.

load_demographics()

Load a patient’s birth date, age, and sex.

sort_dicom()

Create patient tree of data objects from unsorted DICOM files.

This method creates the hierarchy patient -> studies -> modalities, sorting through all files in the directory pointed to be the patient object’s path attribute, and in all sub-directories.

write(outdir='.', ext='.dcm', to_ignore=None, overwrite=True, structure_set='all', dose='all', root_uid=None)

Write files tree.

write_non_image_data(im=None, image_type=None, im_timestamp=None, items=None, modality=None, selection=None, outdir='.', overwrite=True, ext='.dcm')
class skrt.patient.Study(path='')

Bases: Archive

Class representing a single study; can contain images, dose fields, and structure sets.

__init__(path='')

Initialise a Study object from a given directory. Find any images, dose fields, and structure sets within this directory.

add_image(im, image_type='ct')

Add a new image of a given image type.

copy_dicom(outdir='.', images_to_copy=None, structure_sets_to_copy=None, doses_to_copy=None, plans_to_copy=None, overwrite=True, sort=True)

Copy study dicom data.

Parameters:

overwrite - bool, default=True

If False, skip images with pre-existing output directories. If True, delete pre-existing output directories.

outdir - str, default=’.’

Top-level directory to which data will be copied.

images_to_copylist/str/dict, default=None

String specifiying image type for which all images are to be copied; list of strings specifying image types for which all images are to be copied; dictionary where the keys are image types and the values are lists of timestamp indices for the images to be copied, 0 being the earliest and -1 being the most recent. If set to None, all images are copied.

structure_sets_to_copylist/str/dict, default=None

String specifiying structure-set type for which all structure sets are to be copied; list of strings specifying structure-set types for which all structure sets are to be copied; dictionary where the keys are structure-set types and the values are lists of timestamp indices for the structure sets to be copied, 0 being the earliest and -1 being the most recent. If set to None, all structure sets are copied.

correct_dose_image_position(doses=[])

Correct for image positions from CheckTomo being offset by one slice relative to image positions.

get_description()

Load a study description.

get_doses(subtypes=None, associations=None)

Get list of study-associated doses of specified subtype(s).

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of doses to be returned. A subtype may correspond to the modality of the image associated with a dose, or may be the generic identifier “rtdose” if there is no associated image. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the doses to be returned. For example, associations=[“image”] indicates that Dose objects without an associated Image object are to be disregarded. If None, there are no required associations.

get_images(subtypes=None, associations=None)

Get list of study-associated images of specified subtype(s).

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of images to be returned. A subtype corresponds to an imaging modality, for example “ct”, “mr”, “us”. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the images to be returned. For example, associations=[“structure_sets”] indicates that Image objects without at least one associated StructureSet object are to be disregarded. If None, there are no required associations.

get_machine_sublist(dtype='', machine='', ignore_case=True)

Get list of doses or treatment plans corresponding to a specific machine.

get_mvct_selection(mvct_dict={}, min_delta_hours=0.0)

Get a selection of MVCT images which were taken at least <min_delta_hours> apart. <mvct_dict> is a dict where the keys are patient IDs, and the paths are directory paths from which to load images for that patient.

get_objs(dtype, subtypes=None, associations=None)

Get list of study-associated objects of specified type and subtype(s).

Returned objects are sorted by timestamp (earliest first).

Parameters:

dtype: str

String identifying type of objects to be returned. This may be any of: “image”, “structure_set”, “dose”, “plan”.

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of objects to be returned. A subtype may correspond to an imaging modality, for example “ct”, “mr”, “us”, or may be a generic identifier, for example “rtstruct”, “rtdose”, “rtplan”. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the objects to be returned. For example, associations=[“image”] indicates that objects without an associated Image object are to be disregarded. If None, there are no required associations.

get_patient()

Get patient object with which this study is associated.

get_patient_id()

Get patient identifier.

The patient identifier is taken to be the name of the folder containing the patient data.

get_plan_data(dtype='RtPlan', subdir='RTPLAN', exclude=[], images=[])

Get list of RT dose or plan objects specified by dtype=’RtDose’ or ‘RtPlan’ <dtype>, respectively) by searching within a given directory, <subdir> (or within the top level directory of this Study, if <subdir> is not provided).

Subdirectories with names in <exclude> will be ignored.

Each dose-like object will be matched by timestamp to one of the images in <images> (which should be a list of DatedStores), if provided.

get_plan_dose()

Get Dose object representing radiation field, summed over all fractions.

get_plans(subtypes=None, associations=None)

Get list of study-associated plans of specified subtype(s).

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of plans to be returned. A subtype may correspond to the modality of the image associated with a dose, or may be the generic identifier “rtplan” if there is no associated image. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the plans to be returned. For example, associations=[“structure_set”] indicates that Plan objects without an associated StructureSet object are to be disregarded. If None, there are no required associations.

get_structure_sets(subtypes=None, associations=None)

Get list of study-associated structure sets of specified subtype(s).

Parameter:

subtypes: str/list, default=None

String, or list of strings, identifying subtype(s) of structure sets to be returned. A subtype may correspond to the modality of the image associated with a structure set, or may be the generic identifier “rtstruct” if there is no associated image. If None, all subtypes are accepted.

associations: str/list, default=None

String, or list of strings, identifying required associations for the structure sets to be returned. For example, associations=[“image”] indicates that StructureSet objects without an associated Image object are to be disregarded. If None, there are no required associations.

Link plan to doses derived from it.

Parameter:

planskrt.dose.Plan

Plan object for which dose associations are to be determined.

load_from_subdir(dtype, subdir, attr_name, **kwargs)

Create objects of type <dtype> from each directory in <subdir> and attempt to assign the corresponding image. The created objects will be assign to self.<IMAGE_TYPE>_<attr_name>, where <image_type> is inferred from the subdirectory from which the objects were created.

Parameters:

dtypetype

Data type to use when creating objects.

subdirstr

Subdirectory in which to search for objects.

attr_namestr

Name of attribute to which loaded objects should be assigned.

`**`kwargs :

Keyword args to pass to object initialisation.

load_images()

Load images of various types by attempting to load from all files in subdirectories not named RTDOSE, RTSTRUCT, or RTPLAN.

save_images_as_nifti(outdir='.', image_types=None, times=None, verbose=True, image_size=None, voxel_size=None, fill_value=None, bands=None, require_structure_set=None)

Save study’s image data as nifti files.

Parameters:

outdir - str, default=’.’

Directory to which nifti files will be saved.

image_types - list/str/None, default=None

Images types to be saved: None to save all, otherwise a list of image types to save, or a string specifying a single image type to save.

timesdict, default=None

Dictionary where the keys are image types and the values are lists of timestamp indices for the images to be saved, 0 being the earliest and -1 being the most recent. If set to None, all images are saved.

verbose - bool, default=True

Flag indicating whether to report progress.

image_size - tuple, default=None

Image dimensions (dx, dy, dz) in voxels for image resizing prior to writing. If None, original image size is kept.

voxel_size - tuple, default=None

Voxel dimensions (dx, dy, dz) in mm for image resizing prior to writing. If None, original voxel size is kept.

fill_value - int/float, default=None

Value used when extrapolating image outside data area. If None, use mininum value inside data area.

bands - dict, default=None

Nested dictionary of value bandings to be applied before image saving. The primary key defines the type of image to which the banding applies. Secondary keys specify band limits, and associated values indicte the values to be assigned. For example:

  • bands{‘mvct’ : {-100: -1024, 100: 0, 1e10: 1024}}

will band an image of type ‘mvct’:

  • value <= -100 => -1024;

  • -100 < value <= 100 => 0;

  • 100 < value <= 1e10 => 1024.

require_structure_set - list, default=None

List of image types for which data are to be written only if there is an associated structure set.

save_structure_sets_as_nifti(outdir='.', image_types=None, times=None, files=None, verbose=True, image_size=None, voxel_size=None, roi_names=None, force_roi_nifti=False, bilateral_names=None)

Save study’s structure-set data as nifti files.

Parameters:

outdir - str, default=’.’

Directory to which nifti files will be saved.

image_types - list/str/None, default=None

Images types for which structure sets are to be saved: None to save for all, otherwise a list of image types, or a string specifying a single image type.

timesdict, default=None

Dictionary where the keys are image types and the values are lists of timestamp indices for the images for which structure sets are to be saved, 0 being the earliest and -1 being the most recent. If set to None, structure sets are saved for all images.

filesdict, default=None

Dictionary where the keys are image types and the values are lists of file indices for structure sets to be saved for a given image, 0 being the earliest and -1 being the most recent. If set to None, all of an image’s structure sets are saved.

verbose - bool, default=True

Flag indicating whether to report progress.

image_size - tuple, default=None

Image dimensions (dx, dy, dz) in voxels for image resizing prior to writing. If None, original image size is kept.

voxel_size - tuple, default=None

Voxel dimensions (dx, dy, dz) in mm for image resizing prior to writing. If None, original voxel size is kept.

roi_namesdict, default=None

Dictionary of names for renaming ROIs, where the keys are new names and values are lists of possible names of ROIs that should be assigned the new name. These names can also contain wildcards with the ‘*’ symbol.

force_roi_niftibool, default=False

If True, force writing of dummy NIfTI file for all named ROIs not found in structure set. If False, named ROIs not found in structure set are disregarded.

bilateral_nameslist, default=None

List of names of ROIs that should be split into left and right parts.

sum_dose_plans(dose_dict={}, sum_type='')

Sum over doses using a given summation type.

skrt.patient.find_matching_object(obj, possible_matches)

For a given object <obj> and a list of potential matching objects <possible_matches>, find an object that matches <obj>’s path, <obj>’s date and time, or SOP Instance UID.