@cornerstonejs/core 0.43.0 → 0.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "description": "",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -51,5 +51,5 @@
51
51
  "type": "individual",
52
52
  "url": "https://ohif.org/donate"
53
53
  },
54
- "gitHead": "cc3ce18f1c601fc911d8866987ae369a8f4c28df"
54
+ "gitHead": "f64bb238239adaf0cf80ecdc2dca68341207bdd8"
55
55
  }
@@ -584,8 +584,10 @@ class StackViewport extends Viewport implements IStackViewport {
584
584
  return imagePlaneModule;
585
585
  }
586
586
 
587
- const [calibratedRowSpacing, calibratedColumnSpacing] =
588
- calibratedPixelSpacing;
587
+ const {
588
+ rowPixelSpacing: calibratedRowSpacing,
589
+ columnPixelSpacing: calibratedColumnSpacing,
590
+ } = calibratedPixelSpacing;
589
591
 
590
592
  // Todo: This is necessary in general, but breaks an edge case when an image
591
593
  // is calibrated to some other spacing, and it gets calibrated BACK to the
@@ -624,7 +626,9 @@ class StackViewport extends Viewport implements IStackViewport {
624
626
  calibratedColumnSpacing / imagePlaneModule.columnPixelSpacing,
625
627
  };
626
628
 
627
- // modify imagePlaneModule for actor to use calibrated spacing
629
+ // modify the calibration object to store the actual updated values applied
630
+ calibratedPixelSpacing.appliedSpacing = calibratedPixelSpacing;
631
+ // This updates the render copy
628
632
  imagePlaneModule.rowPixelSpacing = calibratedRowSpacing;
629
633
  imagePlaneModule.columnPixelSpacing = calibratedColumnSpacing;
630
634
  return imagePlaneModule;
@@ -634,6 +638,8 @@ class StackViewport extends Viewport implements IStackViewport {
634
638
  const { imageData } = imageDataMetadata;
635
639
  const [columnPixelSpacing, rowPixelSpacing] = imageData.getSpacing();
636
640
 
641
+ // modify the calibration object to store the actual updated values applied
642
+ calibratedPixelSpacing.appliedSpacing = calibratedPixelSpacing;
637
643
  imagePlaneModule.rowPixelSpacing = calibratedRowSpacing;
638
644
  imagePlaneModule.columnPixelSpacing = calibratedColumnSpacing;
639
645
 
@@ -2574,10 +2580,25 @@ class StackViewport extends Viewport implements IStackViewport {
2574
2580
  private _getImagePlaneModule(imageId: string): ImagePlaneModule {
2575
2581
  const imagePlaneModule = metaData.get('imagePlaneModule', imageId);
2576
2582
 
2583
+ const calibratedPixelSpacing = metaData.get(
2584
+ 'calibratedPixelSpacing',
2585
+ imageId
2586
+ );
2587
+
2577
2588
  const newImagePlaneModule: ImagePlaneModule = {
2578
2589
  ...imagePlaneModule,
2579
2590
  };
2580
2591
 
2592
+ if (calibratedPixelSpacing?.appliedSpacing) {
2593
+ // Over-ride the image plane module spacing, as the measurement data
2594
+ // has already been created with the calibrated spacing provided from
2595
+ // down below inside calibrateIfNecessary
2596
+ const { rowPixelSpacing, columnPixelSpacing } =
2597
+ calibratedPixelSpacing.appliedSpacing;
2598
+ newImagePlaneModule.rowPixelSpacing = rowPixelSpacing;
2599
+ newImagePlaneModule.columnPixelSpacing = columnPixelSpacing;
2600
+ }
2601
+
2581
2602
  if (!newImagePlaneModule.columnPixelSpacing) {
2582
2603
  newImagePlaneModule.columnPixelSpacing = 1;
2583
2604
  this.hasPixelSpacing = false;
@@ -1,6 +1,13 @@
1
1
  import imageIdToURI from './imageIdToURI';
2
2
 
3
- const state = {}; // Calibrated pixel spacing per imageId
3
+ export type CalibratedPixelValue = {
4
+ rowPixelSpacing: number;
5
+ columnPixelSpacing: number;
6
+ // These values get updated by the viewport after the change to record the applied value
7
+ appliedSpacing?: CalibratedPixelValue;
8
+ };
9
+
10
+ const state: Record<string, CalibratedPixelValue> = {}; // Calibrated pixel spacing per imageId
4
11
 
5
12
  /**
6
13
  * Simple metadataProvider object to store metadata for calibrated spacings.
@@ -13,11 +20,8 @@ const metadataProvider = {
13
20
  * @param imageId - the imageId for the metadata to store
14
21
  * @param payload - the payload composed of new calibrated pixel spacings
15
22
  */
16
- add: (imageId: string, payload: [number, number]): void => {
23
+ add: (imageId: string, payload: CalibratedPixelValue): void => {
17
24
  const imageURI = imageIdToURI(imageId);
18
- if (!state[imageURI]) {
19
- state[imageURI] = {};
20
- }
21
25
  state[imageURI] = payload;
22
26
  },
23
27
 
@@ -27,7 +31,7 @@ const metadataProvider = {
27
31
  * @param imageId - the imageId to enquire about
28
32
  * @returns the calibrated pixel spacings for the imageId if it exists, otherwise undefined
29
33
  */
30
- get: (type: string, imageId: string): [number, number] => {
34
+ get: (type: string, imageId: string): CalibratedPixelValue => {
31
35
  if (type === 'calibratedPixelSpacing') {
32
36
  const imageURI = imageIdToURI(imageId);
33
37
  return state[imageURI];