This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |