将数据库中的所有图像重新采样为相同的体素大小

Resample all images in the database to the same voxel size

我有 3 个大小为 512x512x133, 512x512x155 and 512x512x277 的 dicom 堆栈。我想对所有堆栈重新采样以制作大小 512x512x277, 512x512x277 and 512x512x277。怎么做?

我知道我可以使用切片厚度和像素间距进行重采样。但这并不能确保每种情况下的切片数量相同。

您可以使用 scipy.ndimage.interpolate.zoom,像这样为每个轴指定缩放因子数组:

# example for first image
zoomArray = desiredshape.astype(float) / original.shape
zoomed = scipy.ndimage.interpolate.zoom(original, zoomArray)

更新:

如果速度太慢,您可以尝试以某种方式从 "image cube" 的垂直切片创建单独的图像,用一些高速图像库处理它们(有些人喜欢 ImageMagick,还有 PIL, opencv等),再将它们堆叠在一起。这样,您将拍摄 512 张尺寸为 512x133 的图像并将它们的大小调整为 512x277,然后再次堆叠为 512x512x277,这是您最终需要的尺寸。此外,这种分离将允许并行化。一种想法是:只有在横轴(您将沿其对 2D 图像进行切片的轴)不调整大小的情况下,这才有效!

您可以使用 Resample transform in TorchIO.

import torchio as tio
small, medium, large = dicom_dirs  # the folders of your three DICOMs
reference = tio.ScalarImage(large)
resample = tio.Resample(reference)
small_resampled = resample(small)
medium_resampled = resample(medium)

这三张图片现在具有相同的形状,512 x 512 x 277。

免责声明:我是 TorchIO 的主要开发者。