gpt4 book ai didi

python-3.x - map (用于重采样 DICOM 图像的 float 抛出多值错误

转载 作者:行者123 更新时间:2023-12-03 20:17:05 26 4
gpt4 key购买 nike

我得到“只能将列表(不是“MultiValue”)连接到列表”突出显示图( float 部分,在重采样下运行时,此代码在整个图像分割(如肺部等)中非常常用,我想这可能是 Python 的问题3 并且适用于早期版本,非常感谢任何帮助:

id = 0
imgs_to_process =
np.load(output_path+'fullimages_{}.npy'.format(id))
def resample(image, scan, new_spacing=[1,1,1]):
# Determine current pixel spacing
spacing = map(float, ([scan[0].SliceThickness] + scan[0].PixelSpacing))
spacing = np.array(list(spacing))

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 = scipy.ndimage.interpolation.zoom(image, real_resize_factor)

return image, new_spacing

print ("Shape before resampling\t", imgs_to_process.shape)
imgs_after_resamp, spacing = resample(imgs_to_process, patient, [1,1,1])
print ("Shape after resampling\t", imgs_after_resamp.shape)

最佳答案

改变

spacing = map(float, ([scan[0].SliceThickness] + scan[0].PixelSpacing))


spacing = map(float, ([scan[0].SliceThickness] + list(scan[0].PixelSpacing)))

基本上 scan[0].PixelSpacing 是一个 MultiValue 并且需要在连接到另一个列表之前转换为列表。

关于python-3.x - map (用于重采样 DICOM 图像的 float 抛出多值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49972817/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com