@@ -118,47 +118,49 @@ const getImageSamples = (x: number, y: number) => {
118118 firstToSample .image .indexToWorld (pickedIjk ) as vec3
119119 );
120120
121- const samples = sampleSet .value .map ((item : any ) => {
122- // Convert world position to this specific image's IJK
123- const itemIjk = worldPointToIndex (item .image , worldPosition );
124- const dims = item .image .getDimensions ();
125- const scalarData = item .image .getPointData ().getScalars ();
126-
127- // Round to nearest integer indices
128- const i = Math .round (itemIjk [0 ]);
129- const j = Math .round (itemIjk [1 ]);
130- const k = Math .round (itemIjk [2 ]);
131-
132- // Check bounds
133- if (
134- i < 0 ||
135- j < 0 ||
136- k < 0 ||
137- i >= dims [0 ] ||
138- j >= dims [1 ] ||
139- k >= dims [2 ]
140- ) {
141- return null ;
142- }
143-
144- const index = dims [0 ] * dims [1 ] * k + dims [0 ] * j + i ;
145- const scalars = scalarData .getTuple (index ) as number [];
146- const baseInfo = { id: item .id , name: item .name };
147-
148- if (item .type === ' segmentGroup' ) {
149- return {
150- ... baseInfo ,
151- displayValues: scalars .map (
152- (v ) => item .segments .byValue [v ]?.name || ' Background'
153- ),
154- };
155- }
156- return { ... baseInfo , displayValues: scalars };
157- });
121+ const samples = sampleSet .value
122+ .map ((item : any ) => {
123+ // Convert world position to this specific image's IJK
124+ const itemIjk = worldPointToIndex (item .image , worldPosition );
125+ const dims = item .image .getDimensions ();
126+ const scalarData = item .image .getPointData ().getScalars ();
127+
128+ // Round to nearest integer indices
129+ const i = Math .round (itemIjk [0 ]);
130+ const j = Math .round (itemIjk [1 ]);
131+ const k = Math .round (itemIjk [2 ]);
132+
133+ // Check bounds
134+ if (
135+ i < 0 ||
136+ j < 0 ||
137+ k < 0 ||
138+ i >= dims [0 ] ||
139+ j >= dims [1 ] ||
140+ k >= dims [2 ]
141+ ) {
142+ return null ;
143+ }
144+
145+ const index = dims [0 ] * dims [1 ] * k + dims [0 ] * j + i ;
146+ const scalars = scalarData .getTuple (index ) as number [];
147+ const baseInfo = { id: item .id , name: item .name };
148+
149+ if (item .type === ' segmentGroup' ) {
150+ return {
151+ ... baseInfo ,
152+ displayValues: scalars .map (
153+ (v ) => item .segments .byValue [v ]?.name || ' Background'
154+ ),
155+ };
156+ }
157+ return { ... baseInfo , displayValues: scalars };
158+ })
159+ .filter ((s ): s is NonNullable <typeof s > => s !== null );
158160
159161 return {
160162 pos: worldPosition ,
161- samples: samples . filter (( s ) : s is NonNullable < typeof s > => s !== null ) ,
163+ samples ,
162164 };
163165};
164166
0 commit comments