File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,7 @@ class NRRDLoader extends Loader {
363363
364364 const volume = new Volume ( ) ;
365365 volume . header = headerObject ;
366+ volume . segmentation = this . segmentation ;
366367 //
367368 // parse the (unzipped) data to a datastream of the correct type
368369 //
@@ -445,7 +446,7 @@ class NRRDLoader extends Loader {
445446 }
446447
447448
448- if ( ! headerObject . vectors || this . segmentation ) {
449+ if ( ! headerObject . vectors ) {
449450
450451 volume . matrix . set (
451452 1 , 0 , 0 , 0 ,
@@ -472,7 +473,12 @@ class NRRDLoader extends Loader {
472473
473474 volume . inverseMatrix = new Matrix4 ( ) ;
474475 volume . inverseMatrix . copy ( volume . matrix ) . invert ( ) ;
475- volume . RASDimensions = new Vector3 ( volume . xLength , volume . yLength , volume . zLength ) . applyMatrix4 ( volume . matrix ) . round ( ) . toArray ( ) . map ( Math . abs ) ;
476+
477+ volume . RASDimensions = [
478+ Math . floor ( volume . xLength * spacingX ) ,
479+ Math . floor ( volume . yLength * spacingY ) ,
480+ Math . floor ( volume . zLength * spacingZ )
481+ ] ;
476482
477483 // .. and set the default threshold
478484 // only if the threshold was not already set
Original file line number Diff line number Diff line change @@ -194,10 +194,18 @@ class Volume {
194194 this . sliceList = [ ] ;
195195
196196
197+ /**
198+ * @member {boolean} segmentation in segmentation mode, it can load 16-bits nrrds correctly
199+ */
200+ this . segmentation = false ;
201+
202+
197203 /**
198204 * @member {Array} RASDimensions This array holds the dimensions of the volume in the RAS space
199205 */
200206
207+
208+
201209 }
202210
203211 /**
@@ -332,13 +340,20 @@ class Volume {
332340
333341 }
334342
335- firstDirection . applyMatrix4 ( volume . inverseMatrix ) . normalize ( ) ;
343+
344+ let iLength , jLength ;
345+
346+ if ( ! this . segmentation ) {
347+
348+ firstDirection . applyMatrix4 ( volume . inverseMatrix ) . normalize ( ) ;
349+ secondDirection . applyMatrix4 ( volume . inverseMatrix ) . normalize ( ) ;
350+ axisInIJK . applyMatrix4 ( volume . inverseMatrix ) . normalize ( ) ;
351+
352+ }
336353 firstDirection . arglet = 'i' ;
337- secondDirection . applyMatrix4 ( volume . inverseMatrix ) . normalize ( ) ;
338354 secondDirection . arglet = 'j' ;
339- axisInIJK . applyMatrix4 ( volume . inverseMatrix ) . normalize ( ) ;
340- const iLength = Math . floor ( Math . abs ( firstDirection . dot ( dimensions ) ) ) ;
341- const jLength = Math . floor ( Math . abs ( secondDirection . dot ( dimensions ) ) ) ;
355+ iLength = Math . floor ( Math . abs ( firstDirection . dot ( dimensions ) ) ) ;
356+ jLength = Math . floor ( Math . abs ( secondDirection . dot ( dimensions ) ) ) ;
342357 const planeWidth = Math . abs ( iLength * firstSpacing ) ;
343358 const planeHeight = Math . abs ( jLength * secondSpacing ) ;
344359
You can’t perform that action at this time.
0 commit comments