【问题标题】:VTK - How to read Tensors/Matrix per cell from a NIFTI Image?VTK - 如何从 NIFTI 图像中读取每个单元格的张量/矩阵?
【发布时间】:2015-08-21 10:08:07
【问题描述】:

我正在尝试实现一个基于VTK的MRT-DTI实时光纤跟踪可视化工具。 因此,我们需要读取存储在NIFTI图像 (.nii)中的张量/矩阵每个单元和我真的不知道该怎么做。

从 NIFTI 文件中检索单个标量值不是问题,但我不知道如何获取张量(3x3/4x4 矩阵)。 我们非常感谢任何帮助!

由于 NIFTIImageReader 应该将张量 NIFTI 图像作为多分量 vtkImage 读取,因此我们尝试了以下操作:

  vtkSmartPointer<vtkImageExtractComponents> extractTupel1 = vtkSmartPointer<vtkImageExtractComponents>::New();
  extractTupel1->SetInputConnection(reader->GetOutputPort());
  extractTupel1->SetComponents(0,1,2);
  extractTupel1->Update();

  vtkSmartPointer<vtkImageExtractComponents> extractTupel2 = vtkSmartPointer<vtkImageExtractComponents>::New();
  extractTupel2->SetInputConnection(reader->GetOutputPort());
  extractTupel2->SetComponents(3, 4, 5);
  extractTupel2->Update();

  vtkSmartPointer<vtkImageExtractComponents> extractTupel3 = vtkSmartPointer<vtkImageExtractComponents>::New();
  extractTupel3->SetInputConnection(reader->GetOutputPort());
  extractTupel3->SetComponents(6, 7, 8);
  extractTupel3->Update();


  extractTupel1->GetOutput()->GetPoint(pointId, tupel1);
  extractTupel2->GetOutput()->GetPoint(pointId, tupel2);
  extractTupel3->GetOutput()->GetPoint(pointId, tupel3);

但它不起作用。也许 GetPoint 方法是错误的选择? 请帮忙:)

【问题讨论】:

    标签: matrix cell vtk nifti


    【解决方案1】:

    David Gobbi 的回答,非常感谢他!:

    不,GetPoint() 方法不会返回张量值。它将返回体素的坐标。所以这里也不需要 vtkImageExtractComponents。

    vtkImageData 始终将体素值存储为其“标量”数组,即使体素值不是标量。

    获取标量值的一种简单(但效率低下)的方法是:

    GetScalarComponentAsDouble (int x, int y, int z, int component)
    

    对于每个体素,您将使用 component = [0..8] 调用此方法 9 次。

    一种更有效的获取张量的方法是从数据中获取标量数组,然后通过pointId查找张量:

    reader->Update(); vtkDataArray *tensors = reader->GetOutput()->GetPointData()->GetScalars(); double tensor[9]; tensors->GetTuple(pointId, tensor);

    这比 GetScalarComponentAsDouble() 效率高出几个数量级。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多