Hi,
I’m trying to resample a CT (nifti) of non-isotropic spacing to have isotropic spacing of (0.5, 0.5, 0.5), no rescaling. I’m using the code below. The output is an array of the desired size but consists of almost only zeros, except the first row of each slice.
def load_resampled_ct(input_file_name, spacing):
input_image = itk.imread(input_file_name)
inputspacing = itk.spacing(input_image)
outputspacing = [spacing, spacing, spacing]
output_origin = itk.origin(input_image)
inputsize = itk.size(input_image)
outsize = [ int(inputsize[0] * inputspacing[0] / outputspacing[0]),
int(inputsize[1] * inputspacing[1] / outputspacing[1]),
int(inputsize[2] * inputspacing[2] / outputspacing[2])]
interpolator = itk.LinearInterpolateImageFunction.New(input_image)
Dimension = input_image.GetImageDimension()
resample = itk.resample_image_filter(
input_image,
size=outsize,
output_spacing=spacing,
output_origin=output_origin
)
return itk.GetArrayFromImage(resample)
Can anyone see what is wrong here?
Best regards and thank you in advance!