niftynet.utilities.util_common module

class niftynet.utilities.util_common.CacheFunctionOutput(func)

Bases: object

this provides a decorator to cache function outputs to avoid repeating some heavy function computations

class niftynet.utilities.util_common.MorphologyOps(binary_img, neigh)

Bases: object

Class that performs the morphological operations needed to get notably connected component. To be used in the evaluation

border_map()

Creates the border for a 3D image :return:

foreground_component()
niftynet.utilities.util_common.average_gradients(multi_device_gradients)
niftynet.utilities.util_common.has_bad_inputs(input_args)

Check if all input params have been properly set in the configuration file. :param input_args: :return:

niftynet.utilities.util_common.list_depth_count(input_list)

This function count the maximum depth of a nested list (recursively) This is used to check compatibility of users’ input and sysmte API only to be used for list or tuple

niftynet.utilities.util_common.look_up_operations(type_str, supported)
niftynet.utilities.util_common.otsu_threshold(img, nbins=256)

Implementation of otsu thresholding

Parameters:
  • img
  • nbins
Returns:

niftynet.utilities.util_common.print_progress_bar(iteration, total, prefix='', suffix='', decimals=1, length=10, fill='=')

Call in a loop to create terminal progress bar @params:

iteration - Required : current iteration (Int) total - Required : total iterations (Int) prefix - Optional : prefix string (Str) suffix - Optional : suffix string (Str) decimals - Optional : number of decimals in percent complete (Int) length - Optional : character length of bar (Int) fill - Optional : bar fill character (Str)
niftynet.utilities.util_common.print_save_input_parameters(args, txt_file=None)
niftynet.utilities.util_common.set_cuda_device(cuda_devices)