Commit b357538c authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Image class makes sure its header dtype is correct, because this is not done

for us when a new nibabel image is created from an array+existing header
parent 2f9bf65f
......@@ -788,6 +788,15 @@ class Image(Nifti):
indexed = False
threaded = False
# Take a copy of the header if one has
# been provided
# NOTE: Nifti extensions are copied by
# reference, which may cause issues in
# the future.
if header is not None:
header = header.copy()
# The image parameter may be the name of an image file
if isinstance(image, six.string_types):
......@@ -826,6 +835,12 @@ class Image(Nifti):
if header is None:
ctr = nib.nifti1.Nifti1Image
# make sure that the data type is correct,
# in case this header was passed in from
# a different image
if header is not None:
# But if a nibabel header has been provided,
# we use the corresponding image type
if isinstance(header, nib.nifti2.Nifti2Header):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment