Вот, пожалуйста:
def rescale(data,affine):
#compute rescaling coef
original_resolution = [abs(affine[0,0]),abs(affine[1,1]),abs(affine[2,2])]
target_resolution = [0.45,0.45,0.45]
rescaling_coef = np.divide([float(i) for i in original_resolution],[float(i) for i in target_resolution])
# X and Y dimension
data = skimage.transform.rescale(data, (rescaling_coef[0],rescaling_coef[1]), order=1, preserve_range=True)
# Z dimension
#flip axes first
data = np.swapaxes(data,0,2)
data = skimage.transform.rescale(data, (rescaling_coef[2],1), order=1, preserve_range=True)
data = np.swapaxes(data,0,2)
return data, rescaling_coef