-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
passing a header dict to the write method #37
Comments
Can you elaborate on what you mean by this? In If so, another example is with 3D Slicer when writing segmentation NRRD files. There are quite a few specific parameters that are written to the NRRD file that should ideally be preserved to allow loading back into 3D Slicer at a later point. |
Hello Addison,
Yes. Writing custom fields like in Slicer is a good example of it.
But more generally, say you want to build your nrrd from a numpy array and specify the metadata that you want like spacing and orientation or change the type of image from float to int.
Or for example you have multiple numpy arrays and you want to save them as one nrrd file, this example could be 2D slices of a volume or volumes of a sequence that you want to combine and save. In these cases you want to specify what your full headers are going to be like.
So what I see is that the ability to design your own header is rather limited with pynrrd. In libraries like SimpleITK, for example, you have absolute control over your metadata. I think pynnrd should provide the same when writing a nrrd file.
Thanks,
Diego
… On Apr 5, 2018, at 9:47 AM, Addison Elliott ***@***.***> wrote:
Can you elaborate on what you mean by this?
In nrrd.write, you are able to pass in an options dictionary that will be written to the NRRD file. However, the limitation is that pynrrd only writes approved keys to the file. So custom keys such as look-at or camera would be ignored. Is this what you mean?
If so, another example is with 3D Slicer when writing segmentation NRRD files. There are quite a few specific parameters that are written to the NRRD file that should ideally be preserved to allow loading back into 3D Slicer at a later point.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
If I'm understanding you correctly, what you are describing is possible in NRRD. You can load in a NRRD file, change the type from int to float, and save it and it will work. You can also change any of the parameters in the metadata and then save it. Let me give you an example.
Note: There are some limitations such that space origin should be a list of strings instead of a list of integers. I am planning on fixing this soon and submitting pull request. Also, you make a good point that documentation is nice to have. |
@d13g0 Did this solve your problem? Is there anything else you needed help with, in regard to pynrrd? |
Bump again. I'm assuming you've solved your issue, can you close this then please? |
So what I understand is that in the current version you can't edit/add custom metadata. That's a limitation.
I am currently working on segmenting prostates on Slicer and those segmentations are saved to NRRD with custom fields in a dictionary in the header. I should be able to edit any field in the header but currently with pynrrd this is not possible. So I can't edit these segmentation files. That is the problem. I am looking at other libraries but I would like to keep it simple and keep using pynrrd.
Thanks,
Diego
… On Apr 27, 2018, at 8:47 AM, Addison Elliott ***@***.***> wrote:
Bump again. I'm assuming you've solved your issue, can you close this then please?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
So when you say 'custom' metadata, I am taking it as it is not one of the fields mentioned here: https://github.com/mhe/pynrrd/blob/master/nrrd.py#L117 You are correct that is a limitation of this library. It is on my (long) TODO list to get to. It would be nice to be able to load custom fields and then write them back. Probably worthwhile to keep this issue open until it is resolved. Thanks for clarifying! |
Fixed in #57 |
It would be very useful to be able to pass a complete header dictionary to the write method. For instnace if you read a NRRD file, then do operations on the header and then you want to save the same data with the updated header.
One of such operations is to add metadata like indicated here:
http://teem.sourceforge.net/nrrd/lib.html#keyvalue
Another operation is to save the data in a different coordinate system. In that case it would be ideal to be able to update the respective fields in the header and then write the data with the new header.
The text was updated successfully, but these errors were encountered: