FastSurferCNN.utils.arg_types

FastSurferCNN.utils.arg_types.float_gt_zero_and_le_one(a)[source]

Check whether a parameters are a float between 0 and one.

Parameters:
astr

String of a number or none, infinity.

Returns:
float or None

If a is a valid float between 0 and 1, return the float value. If a is ‘none’ or ‘infinity’, return None.

Raises:
argparse.ArgumentTypeError

If a is neither a float between 0 and 1.

FastSurferCNN.utils.arg_types.int_ge_zero(value)[source]

Convert to integers greater 0.

Parameters:
valuestr

Integer to convert.

Returns:
valint

Given value if bigger or equal to zero.

Raises:
argparse

ArgumentTypeError: Invalid value, must be greater than 0.

FastSurferCNN.utils.arg_types.int_gt_zero(value)[source]

Convert to positive integers.

Parameters:
valueUnion[str, int]

Integer to convert.

Returns:
valint

Converted integer.

Raises:
argparse

ArgumentTypeError: Invalid value, must not be negative.

FastSurferCNN.utils.arg_types.target_dtype(a)[source]

Check for valid dtypes.

Parameters:
astr

Datatype descriptor.

Returns:
str

The validated data type.

Raises:
argparse.ArgumentTypeError

Invalid dtype.

See also

numpy.dtype

For more information on numpy data types and their properties.

FastSurferCNN.utils.arg_types.unquote_str(value)[source]

Unquote a (single quoted) string, i.e. remove one level of single-quotes.

Parameters:
valuestr

String to be unquoted.

Returns:
valstr

A string of the value without leading and trailing single-quotes.

FastSurferCNN.utils.arg_types.vox_size(a)[source]

Convert the vox_size argument to ‘min’ or a valid voxel size.

Parameters:
astr

Vox size type. Can be auto, bin or a number between 1 an 0.

Returns:
str or float

If ‘auto’ or ‘min’ is provided, it returns a string(‘auto’ or ‘min’). If a valid voxel size (between 0 and 1) is provided, it returns a float.

Raises:
argparse.ArgumentTypeError

If the arguemnt is not “min”, “auto” or convertible to a float between 0 and 1.