6. Functions
6.1. dictwriter functions
- dicom_conversion.conversion_dictwriter.parse_args(startpatient, endpatient, sourcedir, miscdir, modalitylist, ROIs, maxdelineationdelay, maxstudydelay)
Parsing function that declares relevant variables for later use.
- Parameters:
startpatient – Starting point
endpatient – End point
sourcedir – directory for location of dicom files
miscdir – directory for miscellaneous output
modalitylist – list of relevant modalities
ROIs – list of relevant regions of interest
maxdelineationdelay – maximum allowed number of days between scan and delineation
maxstudydelay – maximum allowed number of days between primary and secondary study
- Returns:
parsing arguments
- dicom_conversion.conversion_dictwriter.main(args)
produces a dictionary consisting of patient studies, ROIs, Modalities and apertaining dates.
- Parameters:
args – arguement object from parse_args
- Returns:
excel dictionary
6.2. filewriter functions
- dicom_conversion.conversion_filewriter.parse_args(targetdir, miscdir, modalitylist, ROIs, includered, includeorange, includeyellow)
Parsing function that declares relevant variables for later use.
- Parameters:
targetdir – directory for output nifti files
miscdir – directory for miscellanous output
modalitylist – list of relevant modalities
ROIs – list of relevant regions of interest
includered – boolean variable which includes red flagged patients if True
includeorange – boolean variable which includes orange flagged patients if True
includeyellow – boolean variable which includes yellow flagged patients if True
- Returns:
parsing arguments
- dicom_conversion.conversion_filewriter.main(args)
produces converted nifti-files using an excel dictionary.
- Parameters:
args – arguement object from parse_args
- Returns:
nifti-files
6.3. Helper functions for the conversion scripts
- dicom_conversion.conversion_functions.read_dicts_from_excel(filepath, include_red, include_orange, include_yellow)
Read dictionaries from Excel-file via JSON.
- Parameters:
filepath – directory for excel-file
include_red – boolean variable which includes red flagged patients if True
include_orange – boolean variable which includes orange flagged patients if True
include_yellow – boolean variable which includes yellow flagged patients if True
- Returns:
series dictionary
- dicom_conversion.conversion_functions.highlight_rows(row, list_flagged)
flags patients with error codes.
- Parameters:
row – row of the flagged patient
list_flagged – list of flagged patients.
- Returns:
formatting options
6.4. evaluation functions
- evaluation.parse_args(startpatient, endpatient, sourcedir, miscdir, margin, flaggingthreshold)
Parsing function that declares relevant variables for later use.
- Parameters:
startpatient – Starting point
endpatient – End point
sourcedir – directory for location of registered images
miscdir – directory for miscellaneous output
margin – number of additional slices that should be removed
flaggingthreshold – evaluation threshold for flagging images
- Returns:
parsing arguments
- evaluation.main(args)
Calculates evaluation metric on registered images and flags low perfoming images.
- Parameters:
args – arguement object from parse_args
- Returns:
excel-file containing evaluation scores.
- evaluation.getCropParameters(moving, marginsize=0)
Finds the cropbox for an MR-scan, i.e. a cropbox around all voxels with values greater than or equal to 1.
- Parameters:
moving – the MR-scan to find a cropbox in
marginsize – margin to crop away in addition to cropbox. Default 0
- Returns:
a list containing where to crop in all 6 spatial directions
- evaluation.calcMI(fixed, moving)
Calculates Mutual Information between two images.
- Parameters:
fixed – the fixed image, usually a CT-scan
moving – the moving image, usually a PT- or MR-scan
- Returns:
the Mutual Information value as a float.
- evaluation.resample(image, tx=0.0, ty=0.0, tz=0.0, def_value=0.0)
Applies a directional shift in an image.
- Parameters:
image – the image to shift
tx – the number of voxels to shift by along the x-axis. Default 0.0
ty – the number of voxels to shift by along the y-axis. Default 0.0
tz – the number of voxels to shift by along the z-axis. Default 0.0
def_value – the default voxel value to use. Default 0.0
- Returns:
image shifted as specified.
6.5. registration functions
- registration.register_rigid_bspline.parse_args(sourcedir, targetdir, startpatient, endpatient)
Parsing function that declares relevant variables for later use.
- Parameters:
sourcedir – directory for images that needs to be registered
targetdir – directory for nifti-files output
startpatient – starting point
endpatient – end point
- Returns:
parsing arguments
- registration.register_rigid_bspline.main(args)
Executes rigid and deformable registration on nifti images.
- Parameters:
sourcedir – directory for images that needs to be registered
targetdir – directory for nifti-files output
startpatient – starting point
endpatient – end point
- Returns:
parsing arguements