util¶
Implementation of useful function.
-
segmentation_rt.util.util.format_log(epoch, iteration, errors, t)¶ Generic format for print/log.
- Parameters
epoch (int) – epoch.
iteration (int) – iteration.
errors (dict[float]) – errors dictionary.
t (float) – time.
- Returns
message.
- Return type
str
-
segmentation_rt.util.util.get_subjects(path, structures, transform)¶ Browse the path folder to build a dataset. Folder must contains the subjects with the CT and masks.
- Parameters
path (str) – root folder.
structures (list[str]) – list of structures.
transform (
tio.transforms.Transform) – transforms to be applied.
- Returns
Base TorchIO dataset.
- Return type
tio.SubjectsDataset
-
segmentation_rt.util.util.listdir_full_path(path)¶ List files in path and return their absolute path.
- Parameters
path (str) – path.
- Returns
list of absolute path.
- Return type
list[str]
-
segmentation_rt.util.util.print_log(out_f, message)¶ Writes in log file.
- Parameters
out_f – I/O stream.
message (str) – message to display.
-
segmentation_rt.util.util.save_image(image, path, width=10, bitdepth=8, start=None, end=None, added_slices_step=5)¶ Save image in png format.
- Parameters
image (
np.ndarray) – 3D npy array.bitdepth (int) – encoding.
path (str) – output folder.
width (int) – number of kept slices before the first and after the last non empty slices.
added_slices_step (int) – the script saves slices from the first slice to the first non empty slices with this step (same at the end). if this added_slices_step ==0 , no slices are saved.
start (int) – first slice (default 0).
end (int) – last slice (default -1).