如何解决固定掩码必须是像素类型 satkUInt8 ' simpleitk"
我对 SimpleITK 的图像注册相当陌生,并且我已经在 python3 上从源代码安装了 SimpleITK 包。
这是我的代码:
import SimpleITK as sitk
FIXED_IMAGE_NAME = '/data/fixedImage.nii'
MOVING_IMAGE_NAME = '/data/movingImage.nii'
THIRD_IMAGE_NAME = '/data/thirdImage.nii'
FIXED_IMAGE_MASK_NAME = '/data/fixedImage_roi.nii'
OUTPUT_IMG_NAME = '/data/moving_registered.nii'
OUTPUT_THRID_IMG_NAME = '/data/third_registered.nii'
OUTPUT_LOG_NAME = '/data/MR_CT_thirdPET_LOG.txt'
## Load fixed and moving image data
fixedImage = sitk.ReadImage(FIXED_IMAGE_NAME,sitk.sitkInt16)
movingImage = sitk.ReadImage(MOVING_IMAGE_NAME,sitk.sitkInt16)
# Execute elastix registration
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(fixedImage)
elastixImageFilter.SetMovingImage(movingImage)
try:
if FIXED_IMAGE_MASK_NAME != None and FIXED_IMAGE_MASK_NAME != "":
elastixImageFilter.SetFixedMask(sitk.ReadImage(FIXED_IMAGE_MASK_NAME,sitk.sitkInt16))
except:
print("NO FIXED_IMAGE_MASK: there is no fixedImage_roi.nii in the /data folder.")
elastixImageFilter.SetParameterMap(parameterMap_rigid)
elastixImageFilter.AddParameterMap(parameterMap_bslpine)
print("Performing registration using SimpleElastix...")
elastixImageFilter.LogToFileOn()
#elastixImageFilter.SetLogFileName(OUTPUT_LOG_NAME)
elastixImageFilter.LogToConsoleOn()
elastixImageFilter.Execute()
resultimage = elastixImageFilter.GetResultimage()
sitk.WriteImage(resultimage,OUTPUT_IMG_NAME)
# Get transform parameter map
transformParameterMap = elastixImageFilter.GetTransformParameterMap()
try:
thirdImage = sitk.ReadImage(THIRD_IMAGE_NAME,sitk.sitkInt16)
transformix = sitk.TransformixImageFilter()
transformix.SetTransformParameterMap(transformParameterMap)
transformix.SetMovingImage(thirdImage)
transformix.Execute()
resultThird = transformix.GetResultimage()
sitk.WriteImage(resultThird,OUTPUT_THRID_IMG_NAME)
except:
print("NO THIRD_IMAGE: there is no thirdImage.nii in the /data folder.")
sitk::ERROR:固定掩码必须是像素类型 satkUInt8,但固定掩码 0 是“16 位有符号整数”类型。使用 SimpleITK.Cast(mask,sitk.sitkUInt8)
投射。
你能告诉我我的问题在哪里吗?
解决方法
看起来 elastixImageFilter.SetFixedMask 的蒙版图像必须是 satkUInt8 类型,但您对 satk.ReadImage 的调用告诉它使用类型 satkInt16。将其更改为以下行,它应该可以工作:
elastixImageFilter.SetFixedMask(sitk.ReadImage(FIXED_IMAGE_MASK_NAME,sitk.sitkUInt8))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。