niftynet.utilities.util_common module¶
-
class
CacheFunctionOutput
(func)[source]¶ Bases:
object
this provides a decorator to cache function outputs to avoid repeating some heavy function computations
-
class
MorphologyOps
(binary_img, neigh)[source]¶ Bases:
object
Class that performs the morphological operations needed to get notably connected component. To be used in the evaluation
-
class
ParserNamespace
(**kwargs)[source]¶ Bases:
object
Parser namespace for representing parsed parameters from config file
e.g.:
system_params = ParserNamespace(action='train') action_str = system_params.action
-
damerau_levenshtein_distance
(s1, s2)[source]¶ Calculates an edit distance, for typo detection. Code based on : https://en.wikipedia.org/wiki/Damerau–Levenshtein_distance
-
has_bad_inputs
(input_args)[source]¶ Check if all input params have been properly set in the configuration file. :param input_args: :return:
-
list_depth_count
(input_list)[source]¶ This function count the maximum depth of a nested list (recursively) This is used to check compatibility of users’ input and system API only to be used for list or tuple
-
look_up_operations
(type_str, supported)[source]¶ This function validates the
type_str
against the supported set.if
supported
is aset
, returnstype_str
ifsupported
is adict
, returnsupported[type_str]
else:raise an error possibly with a guess of the closest match.Parameters: - type_str –
- supported –
Returns:
-
otsu_threshold
(img, nbins=256)[source]¶ Implementation of otsu thresholding
Parameters: - img –
- nbins –
Returns:
-
print_progress_bar
(iteration, total, prefix='', suffix='', decimals=1, length=10, fill='=')[source]¶ Call in a loop to create terminal progress bar
Parameters: - iteration – current iteration (Int)
- total – total iterations (Int)
- prefix – prefix string (Str)
- suffix – suffix string (Str)
- decimals – number of decimals in percent complete (Int)
- length – character length of bar (Int)
- fill – bar fill character (Str)