保存变形字段时的简单ITK问题:变形字段为空



我正在寻找simpleITK的帮助,我正在使用NII文件来计算变形场。我使用Python和simpleITK(simpleITK 1.2.0rc2.dev1167+gd4cf2(。我可以很容易地注册我的图像或体积,但我无法获得变形字段!

当我在控制台中打印它时,simpleITK告诉我矢量是预测的图像;WriteImage";这是一个sitk成员函数,写入的图像充满了空值

用于执行此操作的代码:

def RegistrationGel(pathImage1,pathImage2):
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(sitk.ReadImage(pathImage1))
elastixImageFilter.SetMovingImage(sitk.ReadImage(pathImage2))
parameterMapVector = sitk.VectorOfParameterMap()
parameterMapVector.append(sitk.GetDefaultParameterMap("affine"))
#parameterMapVector.append(sitk.GetDefaultParameterMap("bspline"))
elastixImageFilter.SetParameterMap(parameterMapVector)
elastixImageFilter.Execute()
sitk.WriteImage(elastixImageFilter.GetResultImage(),"C:/Users/Armand/Desktop/RecalageGel/Output/resultImageGel.nii")
transformixImageFilter = sitk.TransformixImageFilter()
transformixImageFilter.SetMovingImage(sitk.ReadImage(pathImage2))
transformixImageFilter.ComputeDeformationFieldOn()
#transformixImageFilter.SetOutputDirectory("C:/Users/Armand/Desktop/RecalageGel/Output/DeformationFIELD.nii")
transformixImageFilter.SetTransformParameterMap(elastixImageFilter.GetTransformParameterMap())
transformixImageFilter.Execute()
sitk.WriteImage(transformixImageFilter.GetDeformationField(),"C:/Users/Armand/Desktop/RecalageGel/Output/OutputDef.nii")

我还尝试设置transformixImageFilter的输出目录,但也没有成功。我真的不明白这里发生了什么。。。有人有解决方案或同样的问题吗?我已经阅读了一些相关的主题,但没有任何成功

我也遇到了同样的问题,但奇怪的是,现在它似乎起了作用。。这是我的代码:

moving = sitk.ReadImage("path_to_my_moving_image")
fixed = sitk.ReadImage("path_to_my_fixed_image")
elastixImageFilter = sitk.ElastixImageFilter()
parameterMapVector = sitk.VectorOfParameterMap()

elastixImageFilter.SetFixedImage(fixed)
elastixImageFilter.SetMovingImage(moving)
parameterMapVector = sitk.VectorOfParameterMap()
parameterMapVector.append(sitk.GetDefaultParameterMap("rigid"))
parameterMapVector.append(sitk.GetDefaultParameterMap("affine"))
parameterMapVector.append(sitk.GetDefaultParameterMap("bspline"))
elastixImageFilter.SetParameterMap(parameterMapVector)
elastixImageFilter.Execute()

transformixImageFilter = sitk.TransformixImageFilter()
transformixImageFilter.SetMovingImage(moving)  
transformixImageFilter.SetTransformParameterMap(elastixImageFilter.GetTransformParameterMap())
transformixImageFilter.ComputeDeformationFieldOn()
transformixImageFilter.LogToConsoleOn()
transformixImageFilter.SetOutputDirectory("path_to_my_outputfolder/")
transformixImageFilter.Execute()
sitk.WriteImage(transformixImageFilter.GetDeformationField(), "path_to_my_outputfolder/transformix_rigid_affine_bspline.nii.gz")

transformix部分的终端输出如下:

ELASTIX version: 5.000
Command line options from ElastixBase:
-out      path_to_my_outputfolder/
-threads  unspecified, so all available threads are used
-def      all
-jac      unspecified, so no det(dT/dx) computed
-jacmat   unspecified, so no dT/dx computed
Reading input image ...
Reading input image took 0.000005 s
Calling all ReadFromFile()'s ...
WARNING: The parameter "UseBinaryFormatForTransformationParameters", requested at entry number 0, does not exist at all.
The default value "false" is used instead.
WARNING: The parameter "UseBinaryFormatForTransformationParameters", requested at entry number 0, does not exist at all.
The default value "false" is used instead.
WARNING: The parameter "UseBinaryFormatForTransformationParameters", requested at entry number 0, does not exist at all.
The default value "false" is used instead.
Calling all ReadFromFile()'s took 0.041007 s
Transforming points ...
The transform is evaluated on all points. The result is a deformation field.
Transforming points done, it took 8.95s
Compute determinant of spatial Jacobian ...
The command-line option "-jac" is not used, so no det(dT/dx) computed.
Computing determinant of spatial Jacobian done, it took 0.00s
Compute spatial Jacobian (full matrix) ...
The command-line option "-jacmat" is not used, so no dT/dx computed.
Computing spatial Jacobian done, it took 0.00s
Resampling image and writing to disk ...
Resampling took 25.14s

相关内容

  • 没有找到相关文章

最新更新