| 41 | { |
| 42 | template <typename TensorImageType, typename ImageType> |
| 43 | void |
| 44 | CorrectImageTensorDirection(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 | |
| 76 | template <typename DisplacementFieldType, typename ImageType> |
| 77 | void |
nothing calls this directly
no outgoing calls
no test coverage detected