VTK-如何从NIFTI图像读取每个单元的张量/矩阵? [英] VTK - How to read Tensors/Matrix per cell from a NIFTI Image?

查看:903
本文介绍了VTK-如何从NIFTI图像读取每个单元的张量/矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to implement a MRT-DTI real-time fibertracking visualization tool based on VTK. Therefore we need to read the DTI tensors/matrices per cell stored in a NIFTI Image (.nii) and I really can't figure out how to do this.

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

It's not a problem to retrieve a single scalar value from the NIFTI file, but I don't know how to get the tensor (3x3/4x4 matrix). We would really appreciate any help !

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

Since the NIFTIImageReader is supposed to read a tensor NIFTI image as a multi-component vtkImage we tried this:

  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-Method是错误的选择? 请帮忙:)

But it doesn't work. Maybe the GetPoint-Method is the wrong choice? Please help :)

推荐答案

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

否,GetPoint()方法将不会返回张量值.它将返回体素的坐标.因此在这里也不需要vtkImageExtractComponents.

Answer by David Gobbi, really much thanks to him!:

No, the GetPoint() method will not return the tensor value. It will return the coordinates of the voxel. So vtkImageExtractComponents is not necessary here, either.

vtkImageData始终将体素值存储为其标量"数组,即使体素值不是标量也是如此.

A vtkImageData always stores the voxel values as its "Scalars" array, even if the voxel values are not scalar quantities.

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

A simple (but inefficient way) to get the scalar values is this method:

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

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

For each voxel, you would call this method 9 times with component = [0..8].

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

A much more efficient way of getting the tensors is to get the scalar array from the data, and then look up the tensors via the pointId:

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

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

这比GetScalarComponentAsDouble()的效率高几个数量级.

This is orders of magnitude more efficient than GetScalarComponentAsDouble().

这篇关于VTK-如何从NIFTI图像读取每个单元的张量/矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆