Skip to content

Instantly share code, notes, and snippets.

@sarthakpati
Created September 7, 2021 18:17
Show Gist options
  • Save sarthakpati/bad14ddd604f612469fabb156164ce27 to your computer and use it in GitHub Desktop.
Save sarthakpati/bad14ddd604f612469fabb156164ce27 to your computer and use it in GitHub Desktop.
Copy image information
import SimpleITK as sitk
# read image to copy information from
image_reference = sitk.ReadImage('/path/to/reference.nii.gz')
image_to_copy_from = sitk.ReadImage('/path/to/image_to_change.nii.gz')
image_to_copy_from.CopyInformation(image_reference)
# write the image
sitk.WriteImage(image_to_copy_from, '/path/to/result.nii.gz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment