MCPcopy Create free account
hub / github.com/ANTsX/ANTs / CorrectImageTensorDirection

Function CorrectImageTensorDirection

Examples/antsApplyTransforms.cxx:43–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41{
42template <typename TensorImageType, typename ImageType>
43void
44CorrectImageTensorDirection(TensorImageType * movingTensorImage, ImageType * referenceImage)
45{
46 using DirectionType = typename TensorImageType::DirectionType;
47 using MatrixType = typename DirectionType::InternalMatrixType;
48
49 // Assume tensors start in moving voxel space, we want to put them in fixed voxel space
50
51 MatrixType direction =
52 referenceImage->GetDirection().GetTranspose() * movingTensorImage->GetDirection().GetVnlMatrix();
53
54 if (!direction.is_identity(0.00001))
55 {
56 itk::ImageRegionIterator<TensorImageType> It(movingTensorImage, movingTensorImage->GetBufferedRegion());
57 for (It.GoToBegin(); !It.IsAtEnd(); ++It)
58 {
59 using TensorType = typename TensorImageType::PixelType;
60 using TensorMatrixType = typename TensorImageType::DirectionType::InternalMatrixType;
61
62 TensorType tensor = It.Get();
63 TensorMatrixType dt;
64
65 Vector2Matrix<TensorType, TensorMatrixType>(tensor, dt);
66
67 dt = direction * dt * direction.transpose();
68
69 tensor = Matrix2Vector<TensorType, TensorMatrixType>(dt);
70
71 It.Set(tensor);
72 }
73 }
74}
75
76template <typename DisplacementFieldType, typename ImageType>
77void

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected