Formatting NRRD fields

nrrd.format_number(x)

Format number to string

nrrd.format_number_list(x)

Format a (N,) numpy.ndarray into a NRRD number list.

nrrd.format_vector(x)

Format a (N,) numpy.ndarray into a NRRD vector string

nrrd.format_optional_vector(x)

Format a (N,) numpy.ndarray into a NRRD optional vector string

nrrd.format_matrix(x)

Format a (M,N) numpy.ndarray into a NRRD matrix string

nrrd.format_optional_matrix(x)

Format a (M,N) numpy.ndarray of float into a NRRD optional matrix string

nrrd.format_matrix(x: ~nptyping.base_meta_classes.NDArray[~nptyping.base_meta_classes.Shape[*, *], ~typing.Any]) str[source]

Format a (M,N) numpy.ndarray into a NRRD matrix string

See int matrix and double matrix for more information on the format.

Parameters
x(M,N) numpy.ndarray

Matrix to convert to NRRD vector string

Returns
matrixstr

String containing NRRD matrix

nrrd.format_number(x: Union[int, float]) str[source]

Format number to string

Function converts a number to string. For numbers of class float, up to 17 digits will be used to print the entire floating point number. Any padding zeros will be removed at the end of the number.

See int and double for more information on the format.

Note

IEEE754-1985 standard says that 17 significant decimal digits are required to adequately represent a 64-bit floating point number. Not all fractional numbers can be exactly represented in floating point. An example is 0.1 which will be approximated as 0.10000000000000001.

Parameters
xint or float

Number to convert to string

Returns
vectorstr

String of number x

nrrd.format_number_list(x: ~nptyping.base_meta_classes.NDArray[~nptyping.base_meta_classes.Shape[*], ~typing.Any]) str[source]

Format a (N,) numpy.ndarray into a NRRD number list.

See int list and double list for more information on the format.

Parameters
x(N,) numpy.ndarray

Vector to convert to NRRD number list string

Returns
liststr

String containing NRRD list

nrrd.format_optional_matrix(x: ~typing.Optional[~nptyping.base_meta_classes.NDArray[~nptyping.base_meta_classes.Shape[*, *], ~typing.Any]]) str[source]

Format a (M,N) numpy.ndarray of float into a NRRD optional matrix string

Function converts a (M,N) numpy.ndarray of float into a string using the NRRD matrix format. For any rows of the matrix that contain all NaNs for each element, the row will be replaced with a ‘none’ indicating the row has no vector.

See double matrix for more information on the format.

Note

x must have a datatype of float because NaN’s are only defined for floating point numbers.

Parameters
x(M,N) numpy.ndarray of float

Matrix to convert to NRRD vector string

Returns
matrixstr

String containing NRRD matrix

nrrd.format_optional_vector(x: ~typing.Optional[~nptyping.base_meta_classes.NDArray[~nptyping.base_meta_classes.Shape[*], ~typing.Any]]) str[source]

Format a (N,) numpy.ndarray into a NRRD optional vector string

Function converts a (N,) numpy.ndarray or None into a string using NRRD vector format. If the input x is None, then vector will be ‘none’

See int vector and double vector for more information on the format.

Parameters
x(N,) numpy.ndarray or None

Vector to convert to NRRD vector string

Returns
vectorstr

String containing NRRD vector

nrrd.format_vector(x: ~nptyping.base_meta_classes.NDArray[~nptyping.base_meta_classes.Shape[*], ~typing.Any]) str[source]

Format a (N,) numpy.ndarray into a NRRD vector string

See int vector and double vector for more information on the format.

Parameters
x(N,) numpy.ndarray

Vector to convert to NRRD vector string

Returns
vectorstr

String containing NRRD vector