niftynet.utilities.user_parameters_helper module

This module mainly defines types and casting methods for input parameters

str2boolean(string_input)[source]

convert user input config string to boolean

Parameters:string_input – any string in TRUE_VALUE or FALSE_VALUE
Returns:True or False
int_array(string_input)[source]

convert input into a tuple of int values

Parameters:string_input
Returns:
float_array(string_input)[source]

convert input into a tuple of float values

Parameters:string_input
Returns:
str_array(string_input)[source]

convert input into a tuple of strings

Parameters:string_input
Returns:
make_input_tuple(input_str, element_type=(<type 'basestring'>, ))[source]

converting input into a tuple of input

Parameters:
  • input_str
  • element_type
Returns:

standardise_section_name(configparser, old_name)[source]

rename configparser section This helper is useful when user specifies complex section names

standardise_string(input_string)[source]

to make the user’s input consistent replace any characters not in set [0-9a-zA-Z] with underscore _

Parameters:input_string – to be standardised
Returns:capitalised string
has_section_in_config(config, required_custom_section)[source]

check if section name exists in a config file raises value error if it doesn’t exist

Parameters:
  • config
  • required_custom_section
Returns:

add_input_name_args(parser, supported_input)[source]

adding keywords that defines grouping of the input sections (mainly used for multi-modal input specifications)

Parameters:
  • parser
  • supported_input
Returns:

spatialnumarray(string_input)[source]

This function parses a 3-element tuple from a string input if the input has less than 3 elements, the last element is repeated as padding.

spatial_atleast3d(string_input)[source]

This function parses a 3-element tuple from a string input. The input will be padded with ones, if the length is less than 3.