Skip to content

Commit 44d8b27

Browse files
authored
fix: 🐛 Update examples to use Float32Arrays for segmentations (#89)
Update examples to use Float32Arrays for segmentations, as well as use a new cornerstoneTools release for the cornerstone-sync example.
1 parent 016eabe commit 44d8b27

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

examples/VTKCornerstonePaintingSyncExample.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function setupSyncedBrush(imageDataObject) {
3131

3232
// If you want to load a segmentation labelmap, you would want to load
3333
// it into this array at this point.
34-
const threeDimensionalPixelData = new Uint16Array(numVolumePixels);
34+
const threeDimensionalPixelData = new Float32Array(numVolumePixels);
3535

3636
const buffer = threeDimensionalPixelData.buffer;
3737
const imageIds = imageDataObject.imageIds;
@@ -41,6 +41,9 @@ function setupSyncedBrush(imageDataObject) {
4141
throw new Error('Depth should match the number of imageIds');
4242
}
4343

44+
// Use Float32Arrays in cornerstoneTools for interoperability.
45+
segmentationModule.configuration.arrayType = 1;
46+
4447
segmentationModule.setters.labelmap3DByFirstImageId(
4548
imageIds[0],
4649
buffer,
@@ -324,6 +327,7 @@ class VTKCornerstonePaintingSyncExample extends Component {
324327
/>
325328
)}
326329
</div>
330+
327331
<div className="col-xs-12 col-sm-6" style={{ height: '512px' }}>
328332
{this.state.cornerstoneViewportData && (
329333
<CornerstoneViewport

examples/VTKMPRPaintingExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function createLabelMapImageData(backgroundImageData) {
6464
labelMapData.setDimensions(backgroundImageData.getDimensions());
6565
labelMapData.computeTransforms();
6666

67-
const values = new Uint16Array(backgroundImageData.getNumberOfPoints());
67+
const values = new Float32Array(backgroundImageData.getNumberOfPoints());
6868
const dataArray = vtkDataArray.newInstance({
6969
numberOfComponents: 1, // labelmap with single component
7070
values,
@@ -162,7 +162,7 @@ class VTKMPRPaintingExample extends Component {
162162
clearLabelMap = () => {
163163
const labelMapImageData = this.state.paintFilterLabelMapImageData;
164164
const numberOfPoints = labelMapImageData.getNumberOfPoints();
165-
const values = new Uint8Array(numberOfPoints);
165+
const values = new Float32Array(numberOfPoints);
166166
const dataArray = vtkDataArray.newInstance({
167167
numberOfComponents: 1, // labelmap with single component
168168
values,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"copy-webpack-plugin": "^5.0.4",
4848
"cornerstone-core": "^2.3.0",
4949
"cornerstone-math": "^0.1.8",
50-
"cornerstone-tools": "^4.5.2",
50+
"cornerstone-tools": "^4.11.0",
5151
"cornerstone-wado-image-loader": "^3.0.5",
5252
"cross-env": "^5.2.0",
5353
"css-loader": "^3.0.0",

src/VTKViewport/View2D.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ export default class View2D extends Component {
440440
this.subs.labelmap.unsubscribe();
441441

442442
const labelmapImageData = this.props.paintFilterLabelMapImageData;
443+
443444
const labelmap = createLabelPipeline(
444445
this.props.paintFilterBackgroundImageData,
445446
labelmapImageData,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,10 +3458,10 @@ cornerstone-math@^0.1.8:
34583458
resolved "https://registry.yarnpkg.com/cornerstone-math/-/cornerstone-math-0.1.8.tgz#68ab1f9e4fdcd7c5cb23a0d2eb4263f9f894f1c5"
34593459
integrity sha512-x7NEQHBtVG7j1yeyj/aRoKTpXv1Vh2/H9zNLMyqYJDtJkNng8C4Q8M3CgZ1qer0Yr7eVq2x+Ynmj6kfOm5jXKw==
34603460

3461-
cornerstone-tools@^4.5.2:
3462-
version "4.8.1"
3463-
resolved "https://registry.yarnpkg.com/cornerstone-tools/-/cornerstone-tools-4.8.1.tgz#a821c503886c384f3321e895ddd4c3350eb7d355"
3464-
integrity sha512-TPB2imrlHf/miVpnbP+QCjqlf3tKcwXdLpr7A6M6Q6vPEmJUW8p8h5rfZQrJcfmxi2zz0VGxNlVRHBt/lgo0JQ==
3461+
cornerstone-tools@^4.11.0:
3462+
version "4.11.0"
3463+
resolved "https://registry.yarnpkg.com/cornerstone-tools/-/cornerstone-tools-4.11.0.tgz#746839ec318510150c8d196a9b6d029138de1cbb"
3464+
integrity sha512-2HuPcZ9or93OItOrG1QbF8JMWaAWTPpAC/1ahHJdM4SP5kzzOO1GJMuuUFTOmeWfwezq9ZyoQm/KBMXg4yOIWQ==
34653465
dependencies:
34663466
"@babel/runtime" "7.1.2"
34673467
cornerstone-math "0.1.7"

0 commit comments

Comments
 (0)