From 55153e634ba8771875b6dbc74604e0e09c62da5c Mon Sep 17 00:00:00 2001 From: Douglas Yau Date: Wed, 9 Nov 2022 12:32:57 -0600 Subject: [PATCH] Fix the orthogonalization of the matrix --- src/lib/getImageData.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib/getImageData.js b/src/lib/getImageData.js index b72fade2..c3cbc284 100644 --- a/src/lib/getImageData.js +++ b/src/lib/getImageData.js @@ -35,15 +35,12 @@ export default function getImageData(imageIds, displaySetInstanceUid) { const colCosineVec = vec3.fromValues(...columnCosines); const scanAxisNormal = vec3.cross([], rowCosineVec, colCosineVec); - let direction = [rowCosineVec, colCosineVec, scanAxisNormal]; - vtkMath.orthogonalize3x3(direction, direction); - //setDirection expects orthogonal matrix - const orthogonalizedDirection = [ - ...direction[0], - ...direction[1], - ...direction[2], - ]; + let direction = []; + vtkMath.orthogonalize3x3( + [rowCosineVec, colCosineVec, scanAxisNormal], + direction + ); const { spacing, origin, sortedDatasets } = sortDatasetsByImagePosition( scanAxisNormal, @@ -92,7 +89,7 @@ export default function getImageData(imageIds, displaySetInstanceUid) { const imageData = vtkImageData.newInstance(); imageData.setDimensions(xVoxels, yVoxels, zVoxels); imageData.setSpacing(xSpacing, ySpacing, zSpacing); - imageData.setDirection(orthogonalizedDirection); + imageData.setDirection(direction); imageData.setOrigin(...origin); imageData.getPointData().setScalars(scalarArray);