2
2
*
3
3
* @param {Object } imageData - The vtkImageData
4
4
* @param {* } sliceIndex - The index of the slice you are inserting.
5
- * @param {* } acquistionDirection - The acquistion direction of the slice.
6
5
* @param {* } image The cornerstone image to pull pixel data data from.
7
6
* @param {* } modality The modality of the image.
8
7
* @param {* } modalitySpecificScalingParameters Specific scaling paramaters for this modality. E.g. Patient weight.
9
8
*/
10
9
export default function insertSlice (
11
10
imageData ,
12
11
sliceIndex ,
13
- acquistionDirection ,
14
12
image ,
15
13
modality ,
16
14
modalitySpecificScalingParameters
@@ -24,163 +22,6 @@ export default function insertSlice(
24
22
modalitySpecificScalingParameters
25
23
) ;
26
24
27
- const vtkImageDimensions = imageData . getDimensions ( ) ;
28
-
29
- let minAndMax ;
30
-
31
- switch ( acquistionDirection ) {
32
- case 'coronal' :
33
- minAndMax = insertCoronalSlice (
34
- image ,
35
- sliceIndex ,
36
- vtkImageDimensions ,
37
- scalarData ,
38
- scalingFunction
39
- ) ;
40
- break ;
41
- case 'sagittal' :
42
- minAndMax = insertSagittalSlice (
43
- image ,
44
- sliceIndex ,
45
- vtkImageDimensions ,
46
- scalarData ,
47
- scalingFunction
48
- ) ;
49
- break ;
50
- case 'axial' :
51
- minAndMax = insertAxialSlice (
52
- image ,
53
- sliceIndex ,
54
- scalarData ,
55
- scalingFunction
56
- ) ;
57
- break ;
58
- }
59
-
60
- return minAndMax ;
61
- }
62
-
63
- /**
64
- *
65
- * @param {object } image The cornerstone image to pull pixel data data from.
66
- * @param {number } xIndex The x index of axially oriented vtk volume to put the sagital slice.
67
- * @param {number[] } vtkImageDimensions The dimensions of the axially oriented vtk volume.
68
- * @param {number[] } scalarData The data array for the axially oriented vtk volume.
69
- * @param {function } scalingFunction The modality specific scaling function.
70
- *
71
- * @returns {object } The min and max pixel values in the inserted slice.
72
- */
73
- function insertSagittalSlice (
74
- image ,
75
- xIndex ,
76
- vtkImageDimensions ,
77
- scalarData ,
78
- scalingFunction
79
- ) {
80
- const pixels = image . getPixelData ( ) ;
81
- const { rows, columns } = image ;
82
-
83
- let pixelIndex = 0 ;
84
- let max = scalingFunction ( pixels [ pixelIndex ] ) ;
85
- let min = max ;
86
-
87
- const vtkImageDimensionsX = vtkImageDimensions [ 0 ] ;
88
- const vtkImageDimensionsY = vtkImageDimensions [ 1 ] ;
89
- const vtkImageDimensionsZ = vtkImageDimensions [ 2 ] ;
90
-
91
- const axialSliceLength = vtkImageDimensionsX * vtkImageDimensionsY ;
92
-
93
- for ( let row = 0 ; row < rows ; row ++ ) {
94
- for ( let col = 0 ; col < columns ; col ++ ) {
95
- const yPos = vtkImageDimensionsY - col ;
96
- const zPos = vtkImageDimensionsZ - row ;
97
-
98
- const destIdx =
99
- zPos * axialSliceLength + yPos * vtkImageDimensionsX + xIndex ;
100
-
101
- const pixel = pixels [ pixelIndex ] ;
102
- const pixelValue = scalingFunction ( pixel ) ;
103
-
104
- if ( pixelValue > max ) {
105
- max = pixelValue ;
106
- } else if ( pixelValue < min ) {
107
- min = pixelValue ;
108
- }
109
-
110
- scalarData [ destIdx ] = pixelValue ;
111
- pixelIndex ++ ;
112
- }
113
- }
114
-
115
- return { min, max } ;
116
- }
117
-
118
- /**
119
- *
120
- * @param {object } image The cornerstone image to pull pixel data data from.
121
- * @param {number } yIndex The y index of axially oriented vtk volume to put the coronal slice.
122
- * @param {number[] } vtkImageDimensions The dimensions of the axially oriented vtk volume.
123
- * @param {number[] } scalarData The data array for the axially oriented vtk volume.
124
- * @param {function } scalingFunction The modality specific scaling function.
125
- *
126
- * @returns {object } The min and max pixel values in the inserted slice.
127
- */
128
- function insertCoronalSlice (
129
- image ,
130
- yIndex ,
131
- vtkImageDimensions ,
132
- scalarData ,
133
- scalingFunction
134
- ) {
135
- const pixels = image . getPixelData ( ) ;
136
- const { rows, columns } = image ;
137
-
138
- let pixelIndex = 0 ;
139
- let max = scalingFunction ( pixels [ pixelIndex ] ) ;
140
- let min = max ;
141
-
142
- const vtkImageDimensionsX = vtkImageDimensions [ 0 ] ;
143
- const vtkImageDimensionsY = vtkImageDimensions [ 1 ] ;
144
- const vtkImageDimensionsZ = vtkImageDimensions [ 2 ] ;
145
-
146
- const axialSliceLength = vtkImageDimensionsX * vtkImageDimensionsY ;
147
-
148
- for ( let row = 0 ; row < rows ; row ++ ) {
149
- for ( let col = 0 ; col < columns ; col ++ ) {
150
- const xPos = col ;
151
- const yPos = yIndex ;
152
- const zPos = vtkImageDimensionsZ - row ;
153
-
154
- const destIdx =
155
- zPos * axialSliceLength + yPos * vtkImageDimensionsX + xPos ;
156
-
157
- const pixel = pixels [ pixelIndex ] ;
158
- const pixelValue = scalingFunction ( pixel ) ;
159
-
160
- if ( pixelValue > max ) {
161
- max = pixelValue ;
162
- } else if ( pixelValue < min ) {
163
- min = pixelValue ;
164
- }
165
-
166
- scalarData [ destIdx ] = pixelValue ;
167
- pixelIndex ++ ;
168
- }
169
- }
170
-
171
- return { min, max } ;
172
- }
173
-
174
- /**
175
- *
176
- * @param {object } image The cornerstone image to pull pixel data data from.
177
- * @param {number } zIndex The z index of axially oriented vtk volume to put the axial slice.
178
- * @param {number[] } scalarData The data array for the axially oriented vtk volume.
179
- * @param {function } scalingFunction The modality specific scaling function.
180
- *
181
- * @returns {object } The min and max pixel values in the inserted slice.
182
- */
183
- function insertAxialSlice ( image , zIndex , scalarData , scalingFunction ) {
184
25
const pixels = image . getPixelData ( ) ;
185
26
const sliceLength = pixels . length ;
186
27
@@ -189,7 +30,7 @@ function insertAxialSlice(image, zIndex, scalarData, scalingFunction) {
189
30
let min = max ;
190
31
191
32
for ( let pixelIndex = 0 ; pixelIndex < pixels . length ; pixelIndex ++ ) {
192
- const destIdx = pixelIndex + zIndex * sliceLength ;
33
+ const destIdx = pixelIndex + sliceIndex * sliceLength ;
193
34
const pixel = pixels [ pixelIndex ] ;
194
35
const pixelValue = scalingFunction ( pixel ) ;
195
36
0 commit comments