-
Notifications
You must be signed in to change notification settings - Fork 265
Closed
Description
Dear Nibabel Experts:
I am following nipype tutorial to save files. One approach is to use nib.save(). The other is to use image.to_filename(). But files saved from two methods seems quite different with fsleyes. The latter one is consistent with input file, while the formal is not. Please check the picture below. I was expecting both a and b should perfectly match. I intend to use the formal one, as image_data = image_get_fdata() can give me a numpy array which is easy to get processed for other purpose. Can someone point out what causes the difference in saving and how to fix it? Thanks. The zipped mask file is attached.
mask.nii.gz
The code snippet is below:
image = nib.load("mask.nii.gz")
# save method 1
image.to_filename("a.nii.gz")
# save method 2
outImg = nib.Nifti1Image(image.get_fdata(), affine=image.header.get_base_affine(),
header=image.header)
nib.save(outImg, "b.nii.gz")
Metadata
Metadata
Assignees
Labels
No labels