Added new functions for parsing (converting from NRRD string to Python equivalent type) and formatting (conversion from Python equivalent type to NRRD string). These are public functions (no underscore before them), neatly organized and well-documented so users will know how to use the functions.
The purpose of having these functions is that it is quite common to add custom fields to the NRRD header for some reason and you may want to parse these fields. A great example is 3D Slicer for their segmentation NRRD files that add a bunch of fields.
The following NRRD types are defined as follows: (I've excluded any basic types like int, float, str or str list because they are pretty basic to convert to/from):
vector - (1,2,3,4)
optional vector - (1,2,3,4) or none
matrix - (1,2,3) (4,5,6) (7,8,9)
optional matrix - none (1,2,3) (4,5,6) (7,8,9)
number list - 5 4 3 2 1
Each function is named using underscores and prefixed with parse or format depending on which method you want to use.
Previously, a vector, matrix or number list would return a Python list of numbers. This is changed to convert to a Numpy array. I think this will be worthwhile because most of the time the user will want the extended functionality that Numpy has for numerical arrays.
Note: A small change I made to the formatting of numbers is changing .17f to .17g. The former option (f) prints 17 decimal points while the latter prints 17 significant digits. The g option is correct because 17 significant digits is the resolution of a 64-bit float.
An example:
This is a 17 significant digit number:
12.312312312312312
This is what the f format specifier would print:
12.312312312312312XX where the last two digits would be random numbers and incorrect
This is sort of discussed in #37
Added new functions for parsing (converting from NRRD string to Python equivalent type) and formatting (conversion from Python equivalent type to NRRD string). These are public functions (no underscore before them), neatly organized and well-documented so users will know how to use the functions.
The purpose of having these functions is that it is quite common to add custom fields to the NRRD header for some reason and you may want to parse these fields. A great example is 3D Slicer for their segmentation NRRD files that add a bunch of fields.
The following NRRD types are defined as follows: (I've excluded any basic types like int, float, str or str list because they are pretty basic to convert to/from):
Each function is named using underscores and prefixed with parse or format depending on which method you want to use.
Previously, a vector, matrix or number list would return a Python list of numbers. This is changed to convert to a Numpy array. I think this will be worthwhile because most of the time the user will want the extended functionality that Numpy has for numerical arrays.
Note: A small change I made to the formatting of numbers is changing .17f to .17g. The former option (f) prints 17 decimal points while the latter prints 17 significant digits. The g option is correct because 17 significant digits is the resolution of a 64-bit float.
An example:
This is a 17 significant digit number:
12.312312312312312
This is what the f format specifier would print:
12.312312312312312XX
where the last two digits would be random numbers and incorrect