File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -117,15 +117,15 @@ export function allocateImageFromChunks(sortedChunks: Chunk[]) {
117
117
118
118
image . setSpacing ( [ 1 , 1 , 1 ] ) ;
119
119
if ( slices > 1 && imagePositionPatient && pixelSpacing ) {
120
- const secondMeta = new Map ( sortedChunks [ 1 ] . metadata ) ;
121
- const secondIPP = toVec ( secondMeta . get ( ImagePositionPatientTag ) ) ;
122
- if ( secondIPP ) {
123
- const spacing = [ ...pixelSpacing , 1 ] ;
120
+ const lastMeta = new Map ( sortedChunks [ sortedChunks . length - 1 ] . metadata ) ;
121
+ const lastIPP = toVec ( lastMeta . get ( ImagePositionPatientTag ) ) ;
122
+ if ( lastIPP ) {
124
123
// assumption: uniform Z spacing
125
124
const zVec = vec3 . create ( ) ;
126
125
const firstIPP = imagePositionPatient ;
127
- vec3 . sub ( zVec , secondIPP as vec3 , firstIPP as vec3 ) ;
128
- spacing [ 2 ] = vec3 . len ( zVec ) || 1 ;
126
+ vec3 . sub ( zVec , lastIPP as vec3 , firstIPP as vec3 ) ;
127
+ const zSpacing = vec3 . len ( zVec ) / ( sortedChunks . length - 1 ) || 1 ;
128
+ const spacing = [ ...pixelSpacing , zSpacing ] ;
129
129
image . setSpacing ( spacing ) ;
130
130
}
131
131
}
You can’t perform that action at this time.
0 commit comments