|
@@ -359,80 +359,56 @@
|
|
volume.windowLow = min;
|
|
volume.windowLow = min;
|
|
volume.windowHigh = max; // get the image dimensions
|
|
volume.windowHigh = max; // get the image dimensions
|
|
|
|
|
|
-
|
|
|
|
- // get the image dimensions
|
|
|
|
volume.dimensions = [ headerObject.sizes[ 0 ], headerObject.sizes[ 1 ], headerObject.sizes[ 2 ] ];
|
|
volume.dimensions = [ headerObject.sizes[ 0 ], headerObject.sizes[ 1 ], headerObject.sizes[ 2 ] ];
|
|
volume.xLength = volume.dimensions[ 0 ];
|
|
volume.xLength = volume.dimensions[ 0 ];
|
|
volume.yLength = volume.dimensions[ 1 ];
|
|
volume.yLength = volume.dimensions[ 1 ];
|
|
- volume.zLength = volume.dimensions[ 2 ];
|
|
|
|
|
|
+ volume.zLength = volume.dimensions[ 2 ]; // Identify axis order in the space-directions matrix from the header if possible.
|
|
|
|
|
|
- // Identify axis order in the space-directions matrix from the header if possible.
|
|
|
|
- if (headerObject.vectors) {
|
|
|
|
- const xIndex = headerObject.vectors.findIndex(vector => vector[0] !== 0);
|
|
|
|
- const yIndex = headerObject.vectors.findIndex(vector => vector[1] !== 0);
|
|
|
|
- const zIndex = headerObject.vectors.findIndex(vector => vector[2] !== 0);
|
|
|
|
|
|
+ if ( headerObject.vectors ) {
|
|
|
|
|
|
|
|
+ const xIndex = headerObject.vectors.findIndex( vector => vector[ 0 ] !== 0 );
|
|
|
|
+ const yIndex = headerObject.vectors.findIndex( vector => vector[ 1 ] !== 0 );
|
|
|
|
+ const zIndex = headerObject.vectors.findIndex( vector => vector[ 2 ] !== 0 );
|
|
const axisOrder = [];
|
|
const axisOrder = [];
|
|
- axisOrder[xIndex] = 'x';
|
|
|
|
- axisOrder[yIndex] = 'y';
|
|
|
|
- axisOrder[zIndex] = 'z';
|
|
|
|
|
|
+ axisOrder[ xIndex ] = 'x';
|
|
|
|
+ axisOrder[ yIndex ] = 'y';
|
|
|
|
+ axisOrder[ zIndex ] = 'z';
|
|
volume.axisOrder = axisOrder;
|
|
volume.axisOrder = axisOrder;
|
|
- }
|
|
|
|
- else {
|
|
|
|
- volume.axisOrder = ['x', 'y', 'z'];
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // spacing
|
|
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ volume.axisOrder = [ 'x', 'y', 'z' ];
|
|
|
|
+
|
|
|
|
+ } // spacing
|
|
|
|
+
|
|
|
|
+
|
|
const spacingX = new THREE.Vector3().fromArray( headerObject.vectors[ 0 ] ).length();
|
|
const spacingX = new THREE.Vector3().fromArray( headerObject.vectors[ 0 ] ).length();
|
|
const spacingY = new THREE.Vector3().fromArray( headerObject.vectors[ 1 ] ).length();
|
|
const spacingY = new THREE.Vector3().fromArray( headerObject.vectors[ 1 ] ).length();
|
|
const spacingZ = new THREE.Vector3().fromArray( headerObject.vectors[ 2 ] ).length();
|
|
const spacingZ = new THREE.Vector3().fromArray( headerObject.vectors[ 2 ] ).length();
|
|
- volume.spacing = [ spacingX, spacingY, spacingZ ];
|
|
|
|
|
|
+ volume.spacing = [ spacingX, spacingY, spacingZ ]; // Create IJKtoRAS matrix
|
|
|
|
|
|
- // Create IJKtoRAS matrix
|
|
|
|
volume.matrix = new THREE.Matrix4();
|
|
volume.matrix = new THREE.Matrix4();
|
|
-
|
|
|
|
const transitionMatrix = new THREE.Matrix4();
|
|
const transitionMatrix = new THREE.Matrix4();
|
|
|
|
|
|
if ( headerObject.space === 'left-posterior-superior' ) {
|
|
if ( headerObject.space === 'left-posterior-superior' ) {
|
|
|
|
|
|
- transitionMatrix.set(
|
|
|
|
- - 1, 0, 0, 0,
|
|
|
|
- 0, -1, 0, 0,
|
|
|
|
- 0, 0, 1, 0,
|
|
|
|
- 0, 0, 0, 1 );
|
|
|
|
|
|
+ transitionMatrix.set( - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
} else if ( headerObject.space === 'left-anterior-superior' ) {
|
|
} else if ( headerObject.space === 'left-anterior-superior' ) {
|
|
|
|
|
|
- transitionMatrix.set(
|
|
|
|
- 1, 0, 0, 0,
|
|
|
|
- 0, 1, 0, 0,
|
|
|
|
- 0, 0, -1, 0,
|
|
|
|
- 0, 0, 0, 1 );
|
|
|
|
|
|
+ transitionMatrix.set( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if ( ! headerObject.vectors ) {
|
|
if ( ! headerObject.vectors ) {
|
|
|
|
|
|
- volume.matrix.set(
|
|
|
|
- 1, 0, 0, 0,
|
|
|
|
- 0, 1, 0, 0,
|
|
|
|
- 0, 0, 1, 0,
|
|
|
|
- 0, 0, 0, 1 );
|
|
|
|
|
|
+ volume.matrix.set( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
const v = headerObject.vectors;
|
|
const v = headerObject.vectors;
|
|
-
|
|
|
|
- const ijk_to_transition = ( new THREE.Matrix4() ).set(
|
|
|
|
- v[ 0 ][ 0 ], v[ 1 ][ 0 ], v[ 2 ][ 0 ], 0,
|
|
|
|
- v[ 0 ][ 1 ], v[ 1 ][ 1 ], v[ 2 ][ 1 ], 0,
|
|
|
|
- v[ 0 ][ 2 ], v[ 1 ][ 2 ], v[ 2 ][ 2 ], 0,
|
|
|
|
- 0, 0, 0, 1
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- const transition_to_ras = (new THREE.Matrix4()).multiplyMatrices( ijk_to_transition, transitionMatrix );
|
|
|
|
-
|
|
|
|
|
|
+ const ijk_to_transition = new THREE.Matrix4().set( v[ 0 ][ 0 ], v[ 1 ][ 0 ], v[ 2 ][ 0 ], 0, v[ 0 ][ 1 ], v[ 1 ][ 1 ], v[ 2 ][ 1 ], 0, v[ 0 ][ 2 ], v[ 1 ][ 2 ], v[ 2 ][ 2 ], 0, 0, 0, 0, 1 );
|
|
|
|
+ const transition_to_ras = new THREE.Matrix4().multiplyMatrices( ijk_to_transition, transitionMatrix );
|
|
volume.matrix = transition_to_ras;
|
|
volume.matrix = transition_to_ras;
|
|
|
|
|
|
}
|
|
}
|