Allow custom field map to override default field types #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for writing this library! The nrrd spec says that the
space directionsfield must be a list of some combination of vectors (for spatial axes) andnone(for non-spatial axes like color). It looks to me like pynrrd insists thatspace directionsis a matrix and so it does not support the ability to addnoneentries. I made a small change to enable this.With this commit, it becomes possible to override the default type of a header field. By overriding the default type of
space directionswith'string', users can provide a string value for this that is directly put into the file header. Users will have to know that the proper format of thespace directionsfield is something liketo produce a valid .nrrd header, but at least this is now possible.
As a result, a command like this succeeds in producing a nrrd file that has a correctly specified header for a dataset that is xyz plus a color channel:
And get a proper header:
I have confirmed that this is a proper header according to the nrrd spec using the
unutool from teem, (which the devs have said here is the recommended way to confirm header conformance):Note that if I remove the
nonefrom the header, I get the appropriate complaint fromunu:I would guess this commit wouldn't cause any issues in existing code anywhere in the world, since before this the custom field map would just be ignored for any standard metadata fields, and the behavior is only changed when providing custom field types for the standard fields.
Feel free to merge this PR if you agree this change is a move in the correct direction. Thanks!