-
Notifications
You must be signed in to change notification settings - Fork 4
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
Writer functions #6
Comments
|
To use |
I assume header isn't a napari notion... why not store the image object itself as the header? |
Yes your right. We should switch from storing the affine matrix and the image header in naparis metadata to storing the image object. With the image object we can then use |
I uploaded a basic writer implementation for the image layers to the writer_implementation branch. |
The logic is basically all in |
But |
I meant you could adapt the logic to something you need, such as: valid_klasses = [klass for klass in all_image_classes
if ext in klass.valid_exts]
img = valid_klasses[0](data, affine)
img.to_filename(...) But you can even just save time by creating a In [1]: import nibabel as nb
In [2]: import numpy as np
In [3]: img = nb.spatialimages.SpatialImage(np.zeros((5,5,5)), np.eye(4))
In [4]: nb.save(img, "test.nii")
In [5]: nb.load("test.nii")
Out[5]: <nibabel.nifti1.Nifti1Image at 0x7fcd1cd74c10> Though if you need to set additional header information, you will probably want to do something like the first option and modify |
Thanks for the input. I will use the second approach for the case of saving a layer with no additional information in its metadata. |
I would like to create a branch with the _writer.py script. At the moment my solution only supports the nifti format.
The functions works by creating a
nibabel.Nifti1Image
from the selected layer (image or labels) data and metadata. Do have an idea for a more elegant way to support the different formats in nibabel other than writing a specific writer for each?The text was updated successfully, but these errors were encountered: