Skip to content

Instantly share code, notes, and snippets.

View krekiehn's full-sized avatar

Nicolai Krekiehn krekiehn

View GitHub Profile
import SimpleITK as sitk
# read image
inputImage = sitk.ReadImage('/path/to/input.nii.gz')
# get result in the form of a numpy array
npa_res = my_algorithm(sitk.GetArrayFromImage(inputImage)) # my_algorithm does something fancy
# Converting back to SimpleITK (assumes we didn't move the image in space as we copy the information from the original)
result_image = sitk.GetImageFromArray(npa_res)