def resample(patient, new_spacing=[1,1,1]):
scan = get_scan(patient)
image = get_3D_data(patient)
# Determine current pixel spacing
spacing = np.array([scan[0].SliceThickness] + scan[0].PixelSpacing, dtype=np.float32)
resize_factor = spacing / new_spacing
new_real_shape = image.shape * resize_factor
new_shape = np.round(new_real_shape)
real_resize_factor = new_shape / image.shape
new_spacing = spacing / real_resize_factor
image = nd.interpolation.zoom(image, real_resize_factor, mode='nearest')
return image
# For the sake of testing the network, we'll be using the sample dataset
# For this, we'll use the maximum size of the image
# and PAD any image with -1000 values which is smaller than that
#PS: only the first dimension is different in sample dataset
#which is not the case in actual dataset
评论列表
文章目录