brats_toolkit.util package
Submodules
brats_toolkit.util.docker_functions module
- brats_toolkit.util.docker_functions.start_docker(exam_import_folder=None, exam_export_folder=None, dicom_import_folder=None, nifti_export_folder=None, mode='cpu', gpuid='0')
- brats_toolkit.util.docker_functions.stop_docker()
- brats_toolkit.util.docker_functions.update_docker()
brats_toolkit.util.filemanager module
Module containing functions to manage the BRATS files
- brats_toolkit.util.filemanager.bratsNormalize(image=None, bm=None, bias=0.0001)
Provides normalization of BRATS images to the intensity interval 0…1 and ensures that the background is entirely 0 The bias value ensures that no brain voxel becomes 0
- brats_toolkit.util.filemanager.clean(root, gz=False, dir=False)
Removes all subfolders and leaves only .nii and .nii.gz input files untouched root: path to folder with subfolers gz: If True, compressed Nifti files are also removed
- brats_toolkit.util.filemanager.completeclean(root)
- brats_toolkit.util.filemanager.conversion(segmentations, verbose=True)
- brats_toolkit.util.filemanager.convertLabels(originalFile, oldlabels, newlabels=[0, 1, 2, 4])
- brats_toolkit.util.filemanager.create_files(root, gz=False)
- brats_toolkit.util.filemanager.fileFinder(srcPath, filetofind, func=<function convertLabels>, verbose=True)
finds a file starting from the source path in subdirectories and runs an arbitrary function on them
- brats_toolkit.util.filemanager.fileIterator(directory, gt_root, verbose=True)
- brats_toolkit.util.filemanager.loadGT(path, patid, file='gt.nii.gz', verbose=True)
Loads the Ground Truth for a specified patient from a given Ground Truth root directory In: dir, path to the GT folder
patid, patient ID verbose: True/False terminal output
Out: itk image! -> convert to numpy array
- brats_toolkit.util.filemanager.reduce_filesize(root, gz=False)
- brats_toolkit.util.filemanager.remove_nii(root)
- brats_toolkit.util.filemanager.rename_fla(root)
Renames fla.nii files to flair.nii if required
- brats_toolkit.util.filemanager.rename_flair(root)
Renames flair.nii files to fla.nii if required
- brats_toolkit.util.filemanager.touchAndConvert(originalFile, gt, verbose=True)
Loads the ITK image and saves it with proper header data (and conversion to 8-bit unint)
- brats_toolkit.util.filemanager.validate_files(root)
Checks if all input directories contain the right files
brats_toolkit.util.own_itk module
Module containing functions enabling to read, make and write ITK images.
- brats_toolkit.util.own_itk.copy_image_info(input_path, ref_path)
Copy origin, direction and spacing information from ref_path into the header in input_path.
- brats_toolkit.util.own_itk.get_itk_array(path_or_image)
Get an image array given a path or itk image.
- Parameters:
path_or_image (str or itk image) – Path pointing to an image file with extension among TIFF, JPEG, PNG, BMP, DICOM, GIPL, Bio-Rad, LSM, Nifti (.nii and .nii.gz), Analyze, SDT/SPR (Stimulate), Nrrd or VTK images or an itk image.
- Returns:
arr – Image ndarray contained in the given path or the itk image.
- Return type:
ndarray
- brats_toolkit.util.own_itk.get_itk_data(path_or_image, verbose=False)
Get the image array, image size and pixel dimensions given an itk image or a path.
- Parameters:
path_or_image (str or itk image) – Path pointing to an image file with extension among TIFF, JPEG, PNG, BMP, DICOM, GIPL, Bio-Rad, LSM, Nifti (.nii and .nii.gz), Analyze, SDT/SPR (Stimulate), Nrrd or VTK images or an itk image.
verbose (boolean, optional) – If true, print image shape, spacing and data type of the image corresponding to path_or_image.
- Returns:
arr (ndarray) – Image array contained in the given path or the itk image.
shape (tuple) – Shape of the image array contained in the given path or the itk image.
spacing (tuple) – Pixel spacing (resolution) of the image array contained in the given path or the itk image.
- brats_toolkit.util.own_itk.get_itk_image(path_or_image)
Get an itk image given a path.
- Parameters:
path (str or itk.Image) – Path pointing to an image file with extension among TIFF, JPEG, PNG, BMP, DICOM, GIPL, Bio-Rad, LSM, Nifti (.nii and .nii.gz), Analyze, SDT/SPR (Stimulate), Nrrd or VTK images.
- Returns:
image – The itk image.
- Return type:
itk image
- brats_toolkit.util.own_itk.load_arr_from_paths(paths)
For every str in paths (paths can consis of nested lists), load the image at this path. If any str is not a path, an error is thrown. All other objects are preserved.
- brats_toolkit.util.own_itk.make_itk_image(arr, proto_image=None, verbose=True)
Create an itk image given an image array.
- Parameters:
arr (ndarray) – Array to create an itk image with.
proto_image (itk image, optional) – Proto itk image to provide Origin, Spacing and Direction.
- Returns:
image – The itk image containing the input array arr.
- Return type:
itk image
- brats_toolkit.util.own_itk.read_dicom(source_path, verbose=True)
Reads dicom series into an itk image.
- Parameters:
source_path (string) – path to directory containing dicom series.
verbose (boolean) – print out all series file names.
- Returns:
image – image volume.
- Return type:
itk image
- brats_toolkit.util.own_itk.reduce_arr_dtype(arr, verbose=False)
Change arr.dtype to a more memory-efficient dtype, without changing any element in arr.
- brats_toolkit.util.own_itk.write_itk_image(image, path)
Write an itk image to a path.
- Parameters:
image (itk image or np.ndarray) – Image to be written.
path (str) – Path where the image should be written to.
brats_toolkit.util.prep_utils module
- brats_toolkit.util.prep_utils.tempFiler(orgFilePath, modality, tempFolder)