-
Notifications
You must be signed in to change notification settings - Fork 260
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
Unable to save extra information to the 'extra' field of a nifti1 image #1326
Comments
The extra dictionary is purely for passing around images in memory. You could write a NIfTI extension to pack anything you want in the header, though: Lines 286 to 417 in e6ccec4
The basic procedure is: ext = nb.nifti1.Nifti1Extension(0, bytestring) # 0 for unknown, and you need some bytestring
img.header.extensions.append(ext) Now you can save the image, and then retrieve it on a received image with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to put some extra information to the field 'extra' (which is just an empty dict by default) by using
img_nii.extra = {'Test': 'See what happens'}
# img_nii is my loaded nifti1 image.This assignment worked perfectly fine. Then I tried to save it by calling:
img_nii.to_filename('myTestFilename.nii.gz')
, which also worked with no errors reported.
But if I tried to load the nifti1 image again by calling
img_nii_new =
nib.load('myTestFilename.nii.gz')
,what I got in the field 'extra' of img_nii_new was simply an empty dict. What should I do in order to save extra information there? I plan to save some numpy arrays to this 'extra' field. How can I solve this problem? Any suggestions?
The text was updated successfully, but these errors were encountered: