@cornerstonejs/tools 0.57.0 → 0.58.0
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/dist/cjs/utilities/cine/playClip.js +0 -1
- package/dist/cjs/utilities/cine/playClip.js.map +1 -1
- package/dist/cjs/utilities/dynamicVolume/generateImageFromTimeData.d.ts +3 -0
- package/dist/cjs/utilities/dynamicVolume/generateImageFromTimeData.js +45 -0
- package/dist/cjs/utilities/dynamicVolume/generateImageFromTimeData.js.map +1 -0
- package/dist/cjs/utilities/dynamicVolume/getDataInTime.js +6 -6
- package/dist/cjs/utilities/dynamicVolume/getDataInTime.js.map +1 -1
- package/dist/cjs/utilities/dynamicVolume/index.d.ts +2 -0
- package/dist/cjs/utilities/dynamicVolume/index.js +3 -1
- package/dist/cjs/utilities/dynamicVolume/index.js.map +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsWithinSlice.js +10 -1
- package/dist/cjs/utilities/planar/filterAnnotationsWithinSlice.js.map +1 -1
- package/dist/esm/utilities/cine/playClip.js +0 -1
- package/dist/esm/utilities/cine/playClip.js.map +1 -1
- package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.d.ts +3 -0
- package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.js +43 -0
- package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.js.map +1 -0
- package/dist/esm/utilities/dynamicVolume/getDataInTime.js +6 -6
- package/dist/esm/utilities/dynamicVolume/getDataInTime.js.map +1 -1
- package/dist/esm/utilities/dynamicVolume/index.d.ts +2 -0
- package/dist/esm/utilities/dynamicVolume/index.js +2 -0
- package/dist/esm/utilities/dynamicVolume/index.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js +11 -2
- package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/utilities/cine/playClip.ts +2 -1
- package/src/utilities/dynamicVolume/generateImageFromTimeData.ts +68 -0
- package/src/utilities/dynamicVolume/getDataInTime.ts +6 -6
- package/src/utilities/dynamicVolume/index.ts +3 -0
- package/src/utilities/planar/filterAnnotationsWithinSlice.ts +29 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cornerstonejs/core": "^0.
|
|
29
|
+
"@cornerstonejs/core": "^0.38.0",
|
|
30
30
|
"lodash.clonedeep": "4.5.0",
|
|
31
31
|
"lodash.get": "^4.4.2"
|
|
32
32
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"type": "individual",
|
|
53
53
|
"url": "https://ohif.org/donate"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "9a2711ca032949079e7b96ba332b6e01b3316da8"
|
|
56
56
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
StackViewport,
|
|
6
6
|
VolumeViewport,
|
|
7
7
|
cache,
|
|
8
|
+
BaseVolumeViewport,
|
|
8
9
|
} from '@cornerstonejs/core';
|
|
9
10
|
|
|
10
11
|
import { Types } from '@cornerstonejs/core';
|
|
@@ -301,7 +302,7 @@ function _getVolumeFromViewport(viewport): Types.IImageVolume {
|
|
|
301
302
|
const actorEntry = viewport.getDefaultActor();
|
|
302
303
|
|
|
303
304
|
if (!actorEntry) {
|
|
304
|
-
|
|
305
|
+
// This can happen during setup/teardown of viewports.
|
|
305
306
|
return;
|
|
306
307
|
}
|
|
307
308
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets the scalar data for a series of time frames from a 4D volume, returns an
|
|
5
|
+
* array of scalar data after performing AVERAGE, SUM or SUBTRACT to be used to
|
|
6
|
+
* create a 3D volume
|
|
7
|
+
*
|
|
8
|
+
* @param dynamicVolume4D: volume to compute time frame data from
|
|
9
|
+
* @param operation: operation to perform on time frame data, operations include
|
|
10
|
+
* SUM, AVERAGE, and SUBTRACT (can only be used with 2 time frames provided)
|
|
11
|
+
* @param frameNumbers: an array of frame indexs to perform the operation on, if
|
|
12
|
+
* left empty, all frames will be used
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
function generateImageFromTimeData(
|
|
16
|
+
dynamicVolume: Types.IDynamicImageVolume,
|
|
17
|
+
operation: string,
|
|
18
|
+
frameNumbers?: number[]
|
|
19
|
+
) {
|
|
20
|
+
// If no time frames provided, use all time frames
|
|
21
|
+
const frames = frameNumbers || [...Array(dynamicVolume.numTimePoints).keys()];
|
|
22
|
+
const numFrames = frames.length;
|
|
23
|
+
|
|
24
|
+
if (frames.length <= 1) {
|
|
25
|
+
throw new Error('Please provide two or more time points');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Gets scalar data for all time frames
|
|
29
|
+
const typedArrays = dynamicVolume.getScalarDataArrays();
|
|
30
|
+
|
|
31
|
+
const arrayLength = typedArrays[0].length;
|
|
32
|
+
const finalArray = new Float32Array(arrayLength);
|
|
33
|
+
|
|
34
|
+
if (operation === Enums.DynamicOperatorType.SUM) {
|
|
35
|
+
for (let i = 0; i < numFrames; i++) {
|
|
36
|
+
const currentArray = typedArrays[frames[i]];
|
|
37
|
+
for (let j = 0; j < arrayLength; j++) {
|
|
38
|
+
finalArray[j] += currentArray[j];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return finalArray;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (operation === Enums.DynamicOperatorType.SUBTRACT) {
|
|
45
|
+
if (frames.length > 2) {
|
|
46
|
+
throw new Error('Please provide only 2 time points for subtraction.');
|
|
47
|
+
}
|
|
48
|
+
for (let j = 0; j < arrayLength; j++) {
|
|
49
|
+
finalArray[j] += typedArrays[frames[0]][j] - typedArrays[frames[1]][j];
|
|
50
|
+
}
|
|
51
|
+
return finalArray;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (operation === Enums.DynamicOperatorType.AVERAGE) {
|
|
55
|
+
for (let i = 0; i < numFrames; i++) {
|
|
56
|
+
const currentArray = typedArrays[frames[i]];
|
|
57
|
+
for (let j = 0; j < arrayLength; j++) {
|
|
58
|
+
finalArray[j] += currentArray[j];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (let k = 0; k < arrayLength; k++) {
|
|
62
|
+
finalArray[k] = finalArray[k] / numFrames;
|
|
63
|
+
}
|
|
64
|
+
return finalArray;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default generateImageFromTimeData;
|
|
@@ -83,11 +83,11 @@ function _getTimePointDataCoordinate(frames, coordinate, volume) {
|
|
|
83
83
|
const allScalarData = volume.getScalarDataArrays();
|
|
84
84
|
const value = [];
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
const activeScalarData = allScalarData[
|
|
86
|
+
frames.forEach((frame) => {
|
|
87
|
+
const activeScalarData = allScalarData[frame];
|
|
88
88
|
const scalarIndex = index[2] * zMultiple + index[1] * yMultiple + index[0];
|
|
89
89
|
value.push(activeScalarData[scalarIndex]);
|
|
90
|
-
}
|
|
90
|
+
});
|
|
91
91
|
|
|
92
92
|
return value;
|
|
93
93
|
}
|
|
@@ -98,10 +98,10 @@ function _getTimePointDataMask(frames, indexArray, volume) {
|
|
|
98
98
|
|
|
99
99
|
for (let i = 0; i < indexArray.length; i++) {
|
|
100
100
|
const indexValues = [];
|
|
101
|
-
|
|
102
|
-
const activeScalarData = allScalarData[
|
|
101
|
+
frames.forEach((frame) => {
|
|
102
|
+
const activeScalarData = allScalarData[frame];
|
|
103
103
|
indexValues.push(activeScalarData[indexArray[i]]);
|
|
104
|
-
}
|
|
104
|
+
});
|
|
105
105
|
value.push(indexValues);
|
|
106
106
|
}
|
|
107
107
|
return value;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
|
-
import { CONSTANTS } from '@cornerstonejs/core';
|
|
2
|
+
import { CONSTANTS, metaData } from '@cornerstonejs/core';
|
|
3
3
|
import type { Types } from '@cornerstonejs/core';
|
|
4
4
|
import { Annotations, Annotation } from '../../types';
|
|
5
|
+
import { debug } from 'console';
|
|
5
6
|
|
|
6
7
|
const { EPSILON } = CONSTANTS;
|
|
7
8
|
|
|
@@ -33,8 +34,33 @@ export default function filterAnnotationsWithinSlice(
|
|
|
33
34
|
// logic down below.
|
|
34
35
|
const annotationsWithParallelNormals = annotations.filter(
|
|
35
36
|
(td: Annotation) => {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
let annotationViewPlaneNormal = td.metadata.viewPlaneNormal;
|
|
38
|
+
|
|
39
|
+
if (!annotationViewPlaneNormal) {
|
|
40
|
+
// This code is run to set the annotation view plane normal
|
|
41
|
+
// for historical data which was saved without the normal.
|
|
42
|
+
const { referencedImageId } = td.metadata;
|
|
43
|
+
const { imageOrientationPatient } = metaData.get(
|
|
44
|
+
'imagePlaneModule',
|
|
45
|
+
referencedImageId
|
|
46
|
+
);
|
|
47
|
+
const rowCosineVec = vec3.fromValues(
|
|
48
|
+
imageOrientationPatient[0],
|
|
49
|
+
imageOrientationPatient[1],
|
|
50
|
+
imageOrientationPatient[2]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const colCosineVec = vec3.fromValues(
|
|
54
|
+
imageOrientationPatient[3],
|
|
55
|
+
imageOrientationPatient[4],
|
|
56
|
+
imageOrientationPatient[5]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
annotationViewPlaneNormal = vec3.create() as Types.Point3;
|
|
60
|
+
|
|
61
|
+
vec3.cross(annotationViewPlaneNormal, rowCosineVec, colCosineVec);
|
|
62
|
+
td.metadata.viewPlaneNormal = annotationViewPlaneNormal;
|
|
63
|
+
}
|
|
38
64
|
const isParallel =
|
|
39
65
|
Math.abs(vec3.dot(viewPlaneNormal, annotationViewPlaneNormal)) >
|
|
40
66
|
PARALLEL_THRESHOLD;
|