@cornerstonejs/core 4.13.6 → 4.14.2

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.
@@ -7,7 +7,7 @@ export default class VoxelManager<T> {
7
7
  sourceVoxelManager: IVoxelManager<T>;
8
8
  isInObject: (pointLPS: any, pointIJK: any) => boolean;
9
9
  readonly dimensions: Point3;
10
- readonly numberOfComponents: any;
10
+ readonly numberOfComponents: number;
11
11
  getCompleteScalarDataArray?: () => ArrayLike<number>;
12
12
  setCompleteScalarDataArray?: (scalarData: ArrayLike<number>) => void;
13
13
  getRange: () => [number, number];
@@ -178,7 +178,7 @@ export default class VoxelManager {
178
178
  this._set = options._set;
179
179
  this._id = options._id || '';
180
180
  this._getConstructor = options._getConstructor;
181
- this.numberOfComponents = this.numberOfComponents || 1;
181
+ this.numberOfComponents = options.numberOfComponents || 1;
182
182
  this.scalarData = options.scalarData;
183
183
  this._getScalarData = options._getScalarData;
184
184
  this._updateScalarData = options._updateScalarData;
@@ -1,8 +1,40 @@
1
1
  import { vec3 } from 'gl-matrix';
2
2
  import * as metaData from '../metaData';
3
3
  import { getConfiguration } from '../init';
4
+ const DEFAULT_THICKNESS_SINGLE_SLICE = 1;
5
+ function getPixelSpacingForCubicVoxel(metadata) {
6
+ if (metadata.columnPixelSpacing !== undefined) {
7
+ return metadata.columnPixelSpacing;
8
+ }
9
+ if (metadata.rowPixelSpacing !== undefined) {
10
+ return metadata.rowPixelSpacing;
11
+ }
12
+ if (metadata.pixelSpacing?.[1] !== undefined) {
13
+ return metadata.pixelSpacing[1];
14
+ }
15
+ if (metadata.pixelSpacing?.[0] !== undefined) {
16
+ return metadata.pixelSpacing[0];
17
+ }
18
+ return undefined;
19
+ }
4
20
  export default function calculateSpacingBetweenImageIds(imageIds) {
5
21
  const { imagePositionPatient: referenceImagePositionPatient, imageOrientationPatient, } = metaData.get('imagePlaneModule', imageIds[0]);
22
+ if (imageIds.length === 1) {
23
+ const { sliceThickness, spacingBetweenSlices, columnPixelSpacing, rowPixelSpacing, pixelSpacing, } = metaData.get('imagePlaneModule', imageIds[0]);
24
+ if (sliceThickness)
25
+ return sliceThickness;
26
+ if (spacingBetweenSlices)
27
+ return spacingBetweenSlices;
28
+ const pixelSpacingValue = getPixelSpacingForCubicVoxel({
29
+ columnPixelSpacing,
30
+ rowPixelSpacing,
31
+ pixelSpacing,
32
+ });
33
+ if (pixelSpacingValue !== undefined) {
34
+ return pixelSpacingValue;
35
+ }
36
+ return DEFAULT_THICKNESS_SINGLE_SLICE;
37
+ }
6
38
  const rowCosineVec = vec3.fromValues(imageOrientationPatient[0], imageOrientationPatient[1], imageOrientationPatient[2]);
7
39
  const colCosineVec = vec3.fromValues(imageOrientationPatient[3], imageOrientationPatient[4], imageOrientationPatient[5]);
8
40
  const scanAxisNormal = vec3.create();
@@ -37,8 +69,6 @@ export default function calculateSpacingBetweenImageIds(imageIds) {
37
69
  imageIds[0],
38
70
  imageIds[Math.floor(imageIds.length / 2)],
39
71
  ];
40
- const firstImageDistance = getDistance(prefetchedImageIds[0]);
41
- const middleImageDistance = getDistance(prefetchedImageIds[1]);
42
72
  const metadataForMiddleImage = metaData.get('imagePlaneModule', prefetchedImageIds[1]);
43
73
  if (!metadataForMiddleImage) {
44
74
  throw new Error('Incomplete metadata required for volume construction.');
@@ -51,7 +81,7 @@ export default function calculateSpacingBetweenImageIds(imageIds) {
51
81
  Math.abs(distanceBetweenFirstAndMiddleImages) /
52
82
  Math.floor(imageIds.length / 2);
53
83
  }
54
- const { sliceThickness, spacingBetweenSlices } = metaData.get('imagePlaneModule', imageIds[0]);
84
+ const { sliceThickness, spacingBetweenSlices, columnPixelSpacing, rowPixelSpacing, pixelSpacing, } = metaData.get('imagePlaneModule', imageIds[0]);
55
85
  const { strictZSpacingForVolumeViewport } = getConfiguration().rendering;
56
86
  if ((spacing === 0 || isNaN(spacing)) && !strictZSpacingForVolumeViewport) {
57
87
  if (spacingBetweenSlices) {
@@ -63,8 +93,18 @@ export default function calculateSpacingBetweenImageIds(imageIds) {
63
93
  spacing = sliceThickness;
64
94
  }
65
95
  else {
66
- console.debug('Could not calculate spacing. The VolumeViewport visualization is compromised. Setting spacing to 1 to render');
67
- spacing = 1;
96
+ const pixelSpacingValue = getPixelSpacingForCubicVoxel({
97
+ columnPixelSpacing,
98
+ rowPixelSpacing,
99
+ pixelSpacing,
100
+ });
101
+ if (pixelSpacingValue) {
102
+ spacing = pixelSpacingValue;
103
+ }
104
+ else {
105
+ console.debug(`Could not calculate spacing and no pixel spacing found. Using default thickness (${DEFAULT_THICKNESS_SINGLE_SLICE} mm)`);
106
+ spacing = DEFAULT_THICKNESS_SINGLE_SLICE;
107
+ }
68
108
  }
69
109
  }
70
110
  return spacing;
@@ -7,7 +7,7 @@ const log = coreLog.getLogger('utilities', 'getClosestImageId');
7
7
  export default function getClosestImageId(imageVolume, worldPos, viewPlaneNormal, options) {
8
8
  const { direction, spacing, imageIds } = imageVolume;
9
9
  const { ignoreSpacing = false } = options || {};
10
- if (!imageIds?.length) {
10
+ if (imageIds?.length) {
11
11
  return;
12
12
  }
13
13
  const kVector = direction.slice(6, 9);
@@ -1,7 +1,7 @@
1
1
  import * as metaData from '../metaData';
2
2
  import isEqual from './isEqual';
3
3
  function isValidVolume(imageIds) {
4
- if (imageIds.length <= 1) {
4
+ if (!imageIds.length) {
5
5
  return false;
6
6
  }
7
7
  const imageId0 = imageIds[0];
@@ -35,6 +35,8 @@ export default function scroll(viewport, options) {
35
35
  export function scrollVolume(viewport, volumeId, delta, scrollSlabs = false) {
36
36
  const useSlabThickness = scrollSlabs;
37
37
  const { numScrollSteps, currentStepIndex, sliceRangeInfo } = getVolumeViewportScrollInfo(viewport, volumeId, useSlabThickness);
38
+ if (numScrollSteps === 0)
39
+ return;
38
40
  if (!sliceRangeInfo) {
39
41
  return;
40
42
  }
@@ -1 +1 @@
1
- export declare const version = "4.13.6";
1
+ export declare const version = "4.14.2";
@@ -1 +1 @@
1
- export const version = '4.13.6';
1
+ export const version = '4.14.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "4.13.6",
3
+ "version": "4.14.2",
4
4
  "description": "Cornerstone3D Core",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -97,5 +97,5 @@
97
97
  "type": "individual",
98
98
  "url": "https://ohif.org/donate"
99
99
  },
100
- "gitHead": "43c0ed69005cdd74ceb4a2bb436a7d1b583b935d"
100
+ "gitHead": "3f4519a6cd7f13a7e0564263cae4c7f821b6f35b"
101
101
  }