@cornerstonejs/adapters 3.0.0-beta.5 → 3.0.0-beta.6
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/esm/adapters/Cornerstone/Angle.js +61 -74
- package/dist/esm/adapters/Cornerstone/ArrowAnnotate.js +76 -76
- package/dist/esm/adapters/Cornerstone/Bidirectional.js +130 -146
- package/dist/esm/adapters/Cornerstone/CircleRoi.js +96 -95
- package/dist/esm/adapters/Cornerstone/CobbAngle.js +66 -79
- package/dist/esm/adapters/Cornerstone/EllipticalRoi.js +152 -152
- package/dist/esm/adapters/Cornerstone/FreehandRoi.js +68 -69
- package/dist/esm/adapters/Cornerstone/Length.js +54 -63
- package/dist/esm/adapters/Cornerstone/MeasurementReport.js +221 -224
- package/dist/esm/adapters/Cornerstone/ParametricMap.js +88 -110
- package/dist/esm/adapters/Cornerstone/RectangleRoi.js +72 -78
- package/dist/esm/adapters/Cornerstone/Segmentation.js +7 -7
- package/dist/esm/adapters/Cornerstone/Segmentation_3X.js +113 -104
- package/dist/esm/adapters/Cornerstone/Segmentation_4X.js +434 -462
- package/dist/esm/adapters/Cornerstone/index.js +14 -14
- package/dist/esm/adapters/Cornerstone3D/Angle.d.ts +2 -5
- package/dist/esm/adapters/Cornerstone3D/Angle.js +89 -100
- package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.d.ts +5 -11
- package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.js +106 -118
- package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.d.ts +43 -0
- package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.js +92 -0
- package/dist/esm/adapters/Cornerstone3D/Bidirectional.d.ts +2 -5
- package/dist/esm/adapters/Cornerstone3D/Bidirectional.js +118 -133
- package/dist/esm/adapters/Cornerstone3D/CircleROI.d.ts +2 -7
- package/dist/esm/adapters/Cornerstone3D/CircleROI.js +85 -85
- package/dist/esm/adapters/Cornerstone3D/CobbAngle.d.ts +2 -5
- package/dist/esm/adapters/Cornerstone3D/CobbAngle.js +93 -104
- package/dist/esm/adapters/Cornerstone3D/CodingScheme.js +5 -5
- package/dist/esm/adapters/Cornerstone3D/EllipticalROI.d.ts +2 -7
- package/dist/esm/adapters/Cornerstone3D/EllipticalROI.js +148 -149
- package/dist/esm/adapters/Cornerstone3D/KeyImage.d.ts +24 -0
- package/dist/esm/adapters/Cornerstone3D/KeyImage.js +49 -0
- package/dist/esm/adapters/Cornerstone3D/Length.d.ts +2 -10
- package/dist/esm/adapters/Cornerstone3D/Length.js +83 -93
- package/dist/esm/adapters/Cornerstone3D/MeasurementReport.d.ts +23 -4
- package/dist/esm/adapters/Cornerstone3D/MeasurementReport.js +259 -240
- package/dist/esm/adapters/Cornerstone3D/ParametricMap/generateToolState.js +8 -4
- package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.d.ts +3 -5
- package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.js +99 -115
- package/dist/esm/adapters/Cornerstone3D/Probe.d.ts +4 -17
- package/dist/esm/adapters/Cornerstone3D/Probe.js +38 -79
- package/dist/esm/adapters/Cornerstone3D/RTStruct/RTSS.js +60 -52
- package/dist/esm/adapters/Cornerstone3D/RTStruct/index.js +3 -1
- package/dist/esm/adapters/Cornerstone3D/RTStruct/utilities/getPatientModule.js +5 -5
- package/dist/esm/adapters/Cornerstone3D/RTStruct/utilities/getReferencedFrameOfReferenceSequence.js +14 -10
- package/dist/esm/adapters/Cornerstone3D/RTStruct/utilities/getReferencedSeriesSequence.js +17 -11
- package/dist/esm/adapters/Cornerstone3D/RTStruct/utilities/getStructureSetModule.js +3 -1
- package/dist/esm/adapters/Cornerstone3D/RectangleROI.d.ts +2 -5
- package/dist/esm/adapters/Cornerstone3D/RectangleROI.js +73 -85
- package/dist/esm/adapters/Cornerstone3D/Segmentation/generateLabelMaps2DFrom3D.js +15 -13
- package/dist/esm/adapters/Cornerstone3D/Segmentation/generateSegmentation.js +15 -9
- package/dist/esm/adapters/Cornerstone3D/Segmentation/generateToolState.js +10 -10
- package/dist/esm/adapters/Cornerstone3D/Segmentation/labelmapImagesFromBuffer.js +134 -151
- package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.d.ts +2 -5
- package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.js +68 -84
- package/dist/esm/adapters/Cornerstone3D/index.d.ts +4 -0
- package/dist/esm/adapters/Cornerstone3D/index.js +21 -17
- package/dist/esm/adapters/VTKjs/Segmentation.js +66 -72
- package/dist/esm/adapters/VTKjs/index.js +2 -2
- package/dist/esm/adapters/helpers/checkIfPerpendicular.js +2 -2
- package/dist/esm/adapters/helpers/checkOrientation.js +8 -8
- package/dist/esm/adapters/helpers/codeMeaningEquals.js +2 -2
- package/dist/esm/adapters/helpers/compareArrays.js +4 -2
- package/dist/esm/adapters/helpers/downloadDICOMData.js +6 -4
- package/dist/esm/adapters/helpers/getDatasetsFromImages.js +20 -18
- package/dist/esm/adapters/helpers/graphicTypeEquals.js +2 -2
- package/dist/esm/adapters/helpers/toArray.js +1 -3
- package/dist/esm/adapters/index.d.ts +2 -0
- package/dist/esm/adapters/index.js +6 -5
- package/dist/esm/node_modules/@babel/runtime/helpers/esm/defineProperty.js +18 -0
- package/dist/esm/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
- package/dist/esm/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
- package/dist/esm/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
- package/package.json +4 -4
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +0 -493
- package/dist/esm/adapters/Cornerstone3D/isValidCornerstoneTrackingIdentifier.js +0 -18
|
@@ -1,277 +1,296 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from '../../node_modules/@babel/runtime/helpers/esm/defineProperty.js';
|
|
2
2
|
import { utilities, derivations, normalizers, data } from 'dcmjs';
|
|
3
3
|
import CORNERSTONE_3D_TAG from './cornerstone3DTag.js';
|
|
4
4
|
import { toArray } from '../helpers/toArray.js';
|
|
5
5
|
import { codeMeaningEquals } from '../helpers/codeMeaningEquals.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'buffer';
|
|
7
7
|
import CodingScheme from './CodingScheme.js';
|
|
8
8
|
|
|
9
9
|
var _MeasurementReport;
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
const {
|
|
13
|
+
TID1500,
|
|
14
|
+
addAccessors
|
|
15
|
+
} = utilities;
|
|
16
|
+
const {
|
|
17
|
+
StructuredReport
|
|
18
|
+
} = derivations;
|
|
19
|
+
const {
|
|
20
|
+
Normalizer
|
|
21
|
+
} = normalizers;
|
|
22
|
+
const {
|
|
23
|
+
TID1500MeasurementReport,
|
|
24
|
+
TID1501MeasurementGroup
|
|
25
|
+
} = TID1500;
|
|
26
|
+
const {
|
|
27
|
+
DicomMetaDictionary
|
|
28
|
+
} = data;
|
|
29
|
+
const FINDING = {
|
|
18
30
|
CodingSchemeDesignator: "DCM",
|
|
19
31
|
CodeValue: "121071"
|
|
20
32
|
};
|
|
21
|
-
|
|
33
|
+
const FINDING_SITE = {
|
|
22
34
|
CodingSchemeDesignator: "SCT",
|
|
23
35
|
CodeValue: "363698007"
|
|
24
36
|
};
|
|
25
|
-
|
|
37
|
+
const FINDING_SITE_OLD = {
|
|
26
38
|
CodingSchemeDesignator: "SRT",
|
|
27
39
|
CodeValue: "G-C0E3"
|
|
28
40
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
class MeasurementReport {
|
|
42
|
+
static getTID300ContentItem(tool, ReferencedSOPSequence, toolClass, worldToImageCoords) {
|
|
43
|
+
const args = toolClass.getTID300RepresentationArguments(tool, worldToImageCoords);
|
|
44
|
+
args.ReferencedSOPSequence = ReferencedSOPSequence;
|
|
45
|
+
const TID300Measurement = new toolClass.TID300Representation(args);
|
|
46
|
+
return TID300Measurement;
|
|
33
47
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, worldToImageCoords) {
|
|
45
|
-
var toolTypeData = toolData[toolType];
|
|
46
|
-
var toolClass = MeasurementReport.CORNERSTONE_TOOL_CLASSES_BY_TOOL_TYPE[toolType];
|
|
47
|
-
if (!toolTypeData || !toolTypeData.data || !toolTypeData.data.length || !toolClass) {
|
|
48
|
-
return;
|
|
48
|
+
static getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, worldToImageCoords) {
|
|
49
|
+
const toolTypeData = toolData[toolType];
|
|
50
|
+
const toolClass = this.measurementAdapterByToolType.get(toolType);
|
|
51
|
+
if (!toolTypeData || !toolTypeData.data || !toolTypeData.data.length || !toolClass) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const Measurements = toolTypeData.data.map(tool => {
|
|
55
|
+
return this.getTID300ContentItem(tool, ReferencedSOPSequence, toolClass, worldToImageCoords);
|
|
56
|
+
});
|
|
57
|
+
return new TID1501MeasurementGroup(Measurements);
|
|
49
58
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
static getCornerstoneLabelFromDefaultState(defaultState) {
|
|
60
|
+
const {
|
|
61
|
+
findingSites = [],
|
|
62
|
+
finding
|
|
63
|
+
} = defaultState;
|
|
64
|
+
const cornersoneFreeTextCodingValue = CodingScheme.codeValues.CORNERSTONEFREETEXT;
|
|
65
|
+
const freeTextLabel = findingSites.find(fs => fs.CodeValue === cornersoneFreeTextCodingValue);
|
|
66
|
+
if (freeTextLabel) {
|
|
67
|
+
return freeTextLabel.CodeMeaning;
|
|
68
|
+
}
|
|
69
|
+
if (finding && finding.CodeValue === cornersoneFreeTextCodingValue) {
|
|
70
|
+
return finding.CodeMeaning;
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
static generateDatasetMeta() {
|
|
74
|
+
const fileMetaInformationVersionArray = new Uint8Array(2);
|
|
75
|
+
fileMetaInformationVersionArray[1] = 1;
|
|
76
|
+
const _meta = {
|
|
77
|
+
FileMetaInformationVersion: {
|
|
78
|
+
Value: [fileMetaInformationVersionArray.buffer],
|
|
79
|
+
vr: "OB"
|
|
80
|
+
},
|
|
81
|
+
TransferSyntaxUID: {
|
|
82
|
+
Value: ["1.2.840.10008.1.2.1"],
|
|
83
|
+
vr: "UI"
|
|
84
|
+
},
|
|
85
|
+
ImplementationClassUID: {
|
|
86
|
+
Value: [DicomMetaDictionary.uid()],
|
|
87
|
+
vr: "UI"
|
|
88
|
+
},
|
|
89
|
+
ImplementationVersionName: {
|
|
90
|
+
Value: ["dcmjs"],
|
|
91
|
+
vr: "SH"
|
|
74
92
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
};
|
|
94
|
+
return _meta;
|
|
95
|
+
}
|
|
96
|
+
static getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, toolType) {
|
|
97
|
+
const {
|
|
98
|
+
ContentSequence
|
|
99
|
+
} = MeasurementGroup;
|
|
100
|
+
const contentSequenceArr = toArray(ContentSequence);
|
|
101
|
+
const findingGroup = contentSequenceArr.find(group => this.codeValueMatch(group, FINDING));
|
|
102
|
+
const findingSiteGroups = contentSequenceArr.filter(group => this.codeValueMatch(group, FINDING_SITE, FINDING_SITE_OLD)) || [];
|
|
103
|
+
const NUMGroup = contentSequenceArr.find(group => group.ValueType === "NUM");
|
|
104
|
+
const SCOORDGroup = toArray(NUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD");
|
|
105
|
+
const {
|
|
106
|
+
ReferencedSOPSequence
|
|
107
|
+
} = SCOORDGroup.ContentSequence;
|
|
108
|
+
const {
|
|
109
|
+
ReferencedSOPInstanceUID,
|
|
110
|
+
ReferencedFrameNumber
|
|
111
|
+
} = ReferencedSOPSequence;
|
|
112
|
+
const referencedImageId = sopInstanceUIDToImageIdMap[ReferencedSOPInstanceUID];
|
|
113
|
+
const imagePlaneModule = metadata.get("imagePlaneModule", referencedImageId);
|
|
114
|
+
const finding = findingGroup ? addAccessors(findingGroup.ConceptCodeSequence) : undefined;
|
|
115
|
+
const findingSites = findingSiteGroups.map(fsg => {
|
|
116
|
+
return addAccessors(fsg.ConceptCodeSequence);
|
|
117
|
+
});
|
|
118
|
+
const defaultState = {
|
|
119
|
+
description: undefined,
|
|
120
|
+
sopInstanceUid: ReferencedSOPInstanceUID,
|
|
121
|
+
annotation: {
|
|
122
|
+
annotationUID: DicomMetaDictionary.uid(),
|
|
123
|
+
metadata: {
|
|
124
|
+
toolName: toolType,
|
|
125
|
+
referencedImageId,
|
|
126
|
+
FrameOfReferenceUID: imagePlaneModule.frameOfReferenceUID,
|
|
127
|
+
label: ""
|
|
93
128
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
data: undefined
|
|
130
|
+
},
|
|
131
|
+
finding,
|
|
132
|
+
findingSites
|
|
133
|
+
};
|
|
134
|
+
if (defaultState.finding) {
|
|
135
|
+
defaultState.description = defaultState.finding.CodeMeaning;
|
|
100
136
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
annotation: {
|
|
131
|
-
annotationUID: DicomMetaDictionary.uid(),
|
|
132
|
-
metadata: {
|
|
133
|
-
toolName: toolType,
|
|
134
|
-
referencedImageId: referencedImageId,
|
|
135
|
-
FrameOfReferenceUID: imagePlaneModule.frameOfReferenceUID,
|
|
136
|
-
label: ""
|
|
137
|
-
},
|
|
138
|
-
data: undefined
|
|
139
|
-
},
|
|
140
|
-
finding: finding,
|
|
141
|
-
findingSites: findingSites
|
|
142
|
-
};
|
|
143
|
-
if (defaultState.finding) {
|
|
144
|
-
defaultState.description = defaultState.finding.CodeMeaning;
|
|
137
|
+
defaultState.annotation.metadata.label = MeasurementReport.getCornerstoneLabelFromDefaultState(defaultState);
|
|
138
|
+
return {
|
|
139
|
+
defaultState,
|
|
140
|
+
NUMGroup,
|
|
141
|
+
SCOORDGroup,
|
|
142
|
+
ReferencedSOPSequence,
|
|
143
|
+
ReferencedSOPInstanceUID,
|
|
144
|
+
ReferencedFrameNumber
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
static generateReport(toolState, metadataProvider, worldToImageCoords, options) {
|
|
148
|
+
let allMeasurementGroups = [];
|
|
149
|
+
const sopInstanceUIDsToSeriesInstanceUIDMap = {};
|
|
150
|
+
const derivationSourceDatasets = [];
|
|
151
|
+
const _meta = MeasurementReport.generateDatasetMeta();
|
|
152
|
+
Object.keys(toolState).forEach(imageId => {
|
|
153
|
+
const sopCommonModule = metadataProvider.get("sopCommonModule", imageId);
|
|
154
|
+
const instance = metadataProvider.get("instance", imageId);
|
|
155
|
+
const {
|
|
156
|
+
sopInstanceUID,
|
|
157
|
+
sopClassUID
|
|
158
|
+
} = sopCommonModule;
|
|
159
|
+
const {
|
|
160
|
+
SeriesInstanceUID: seriesInstanceUID
|
|
161
|
+
} = instance;
|
|
162
|
+
sopInstanceUIDsToSeriesInstanceUIDMap[sopInstanceUID] = seriesInstanceUID;
|
|
163
|
+
if (!derivationSourceDatasets.find(dsd => dsd.SeriesInstanceUID === seriesInstanceUID)) {
|
|
164
|
+
const derivationSourceDataset = MeasurementReport.generateDerivationSourceDataset(instance);
|
|
165
|
+
derivationSourceDatasets.push(derivationSourceDataset);
|
|
145
166
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
ReferencedFrameNumber: ReferencedFrameNumber
|
|
167
|
+
const frameNumber = metadataProvider.get("frameNumber", imageId);
|
|
168
|
+
const toolData = toolState[imageId];
|
|
169
|
+
const toolTypes = Object.keys(toolData);
|
|
170
|
+
const ReferencedSOPSequence = {
|
|
171
|
+
ReferencedSOPClassUID: sopClassUID,
|
|
172
|
+
ReferencedSOPInstanceUID: sopInstanceUID,
|
|
173
|
+
ReferencedFrameNumber: undefined
|
|
154
174
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
Object.keys(toolState).forEach(function (imageId) {
|
|
164
|
-
var sopCommonModule = metadataProvider.get("sopCommonModule", imageId);
|
|
165
|
-
var instance = metadataProvider.get("instance", imageId);
|
|
166
|
-
var sopInstanceUID = sopCommonModule.sopInstanceUID,
|
|
167
|
-
sopClassUID = sopCommonModule.sopClassUID;
|
|
168
|
-
var seriesInstanceUID = instance.SeriesInstanceUID;
|
|
169
|
-
sopInstanceUIDsToSeriesInstanceUIDMap[sopInstanceUID] = seriesInstanceUID;
|
|
170
|
-
if (!derivationSourceDatasets.find(function (dsd) {
|
|
171
|
-
return dsd.SeriesInstanceUID === seriesInstanceUID;
|
|
172
|
-
})) {
|
|
173
|
-
var derivationSourceDataset = MeasurementReport.generateDerivationSourceDataset(instance);
|
|
174
|
-
derivationSourceDatasets.push(derivationSourceDataset);
|
|
175
|
-
}
|
|
176
|
-
var frameNumber = metadataProvider.get("frameNumber", imageId);
|
|
177
|
-
var toolData = toolState[imageId];
|
|
178
|
-
var toolTypes = Object.keys(toolData);
|
|
179
|
-
var ReferencedSOPSequence = {
|
|
180
|
-
ReferencedSOPClassUID: sopClassUID,
|
|
181
|
-
ReferencedSOPInstanceUID: sopInstanceUID,
|
|
182
|
-
ReferencedFrameNumber: undefined
|
|
183
|
-
};
|
|
184
|
-
if (instance && instance.NumberOfFrames && instance.NumberOfFrames > 1 || Normalizer.isMultiframeSOPClassUID(sopClassUID)) {
|
|
185
|
-
ReferencedSOPSequence.ReferencedFrameNumber = frameNumber;
|
|
175
|
+
if (instance && instance.NumberOfFrames && instance.NumberOfFrames > 1 || Normalizer.isMultiframeSOPClassUID(sopClassUID)) {
|
|
176
|
+
ReferencedSOPSequence.ReferencedFrameNumber = frameNumber;
|
|
177
|
+
}
|
|
178
|
+
const measurementGroups = [];
|
|
179
|
+
toolTypes.forEach(toolType => {
|
|
180
|
+
const group = this.getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, worldToImageCoords);
|
|
181
|
+
if (group) {
|
|
182
|
+
measurementGroups.push(group);
|
|
186
183
|
}
|
|
187
|
-
var measurementGroups = [];
|
|
188
|
-
toolTypes.forEach(function (toolType) {
|
|
189
|
-
var group = getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, worldToImageCoords);
|
|
190
|
-
if (group) {
|
|
191
|
-
measurementGroups.push(group);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
allMeasurementGroups = allMeasurementGroups.concat(measurementGroups);
|
|
195
184
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
185
|
+
allMeasurementGroups = allMeasurementGroups.concat(measurementGroups);
|
|
186
|
+
});
|
|
187
|
+
const tid1500MeasurementReport = new TID1500MeasurementReport({
|
|
188
|
+
TID1501MeasurementGroups: allMeasurementGroups
|
|
189
|
+
}, options);
|
|
190
|
+
const report = new StructuredReport(derivationSourceDatasets, options);
|
|
191
|
+
const contentItem = tid1500MeasurementReport.contentItem(derivationSourceDatasets, _objectSpread(_objectSpread({}, options), {}, {
|
|
192
|
+
sopInstanceUIDsToSeriesInstanceUIDMap
|
|
193
|
+
}));
|
|
194
|
+
report.dataset = Object.assign(report.dataset, contentItem);
|
|
195
|
+
report.dataset._meta = _meta;
|
|
196
|
+
report.SpecificCharacterSet = "ISO_IR 192";
|
|
197
|
+
return report;
|
|
198
|
+
}
|
|
199
|
+
static generateToolState(dataset, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, hooks) {
|
|
200
|
+
if (dataset.ContentTemplateSequence.TemplateIdentifier !== "1500") {
|
|
201
|
+
throw new Error("This package can currently only interpret DICOM SR TID 1500");
|
|
207
202
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
var TrackingIdentifierValue = TrackingIdentifierGroup.TextValue;
|
|
235
|
-
var TrackingUniqueIdentifierGroup = measurementGroupContentSequence.find(function (contentItem) {
|
|
236
|
-
return contentItem.ConceptNameCodeSequence.CodeMeaning === TRACKING_UNIQUE_IDENTIFIER;
|
|
237
|
-
});
|
|
238
|
-
var TrackingUniqueIdentifierValue = TrackingUniqueIdentifierGroup === null || TrackingUniqueIdentifierGroup === void 0 ? void 0 : TrackingUniqueIdentifierGroup.UID;
|
|
239
|
-
var toolClass = (hooks === null || hooks === void 0 || (_hooks$getToolClass = hooks.getToolClass) === null || _hooks$getToolClass === void 0 ? void 0 : _hooks$getToolClass.call(hooks, measurementGroup, dataset, registeredToolClasses)) || registeredToolClasses.find(function (tc) {
|
|
240
|
-
return tc.isValidCornerstoneTrackingIdentifier(TrackingIdentifierValue);
|
|
241
|
-
});
|
|
242
|
-
if (toolClass) {
|
|
243
|
-
var measurement = toolClass.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata);
|
|
244
|
-
measurement.TrackingUniqueIdentifier = TrackingUniqueIdentifierValue;
|
|
245
|
-
console.log("=== ".concat(toolClass.toolType, " ==="));
|
|
246
|
-
console.log(measurement);
|
|
247
|
-
measurementData[toolClass.toolType].push(measurement);
|
|
248
|
-
}
|
|
249
|
-
} catch (e) {
|
|
250
|
-
console.warn("Unable to generate tool state for", measurementGroup, e);
|
|
203
|
+
const REPORT = "Imaging Measurements";
|
|
204
|
+
const GROUP = "Measurement Group";
|
|
205
|
+
const TRACKING_IDENTIFIER = "Tracking Identifier";
|
|
206
|
+
const TRACKING_UNIQUE_IDENTIFIER = "Tracking Unique Identifier";
|
|
207
|
+
const imagingMeasurementContent = toArray(dataset.ContentSequence).find(codeMeaningEquals(REPORT));
|
|
208
|
+
const measurementGroups = toArray(imagingMeasurementContent.ContentSequence).filter(codeMeaningEquals(GROUP));
|
|
209
|
+
const measurementData = {};
|
|
210
|
+
measurementGroups.forEach(measurementGroup => {
|
|
211
|
+
try {
|
|
212
|
+
var _hooks$getToolClass;
|
|
213
|
+
const measurementGroupContentSequence = toArray(measurementGroup.ContentSequence);
|
|
214
|
+
const trackingIdentifierGroup = measurementGroupContentSequence.find(contentItem => contentItem.ConceptNameCodeSequence.CodeMeaning === TRACKING_IDENTIFIER);
|
|
215
|
+
const {
|
|
216
|
+
TextValue: trackingIdentifierValue
|
|
217
|
+
} = trackingIdentifierGroup;
|
|
218
|
+
const trackingUniqueIdentifierGroup = measurementGroupContentSequence.find(contentItem => contentItem.ConceptNameCodeSequence.CodeMeaning === TRACKING_UNIQUE_IDENTIFIER);
|
|
219
|
+
const trackingUniqueIdentifierValue = trackingUniqueIdentifierGroup === null || trackingUniqueIdentifierGroup === void 0 ? void 0 : trackingUniqueIdentifierGroup.UID;
|
|
220
|
+
const toolAdapter = (hooks === null || hooks === void 0 || (_hooks$getToolClass = hooks.getToolClass) === null || _hooks$getToolClass === void 0 ? void 0 : _hooks$getToolClass.call(hooks, measurementGroup, dataset, this.measurementAdapterByToolType)) || this.getAdapterForTrackingIdentifier(trackingIdentifierValue);
|
|
221
|
+
if (toolAdapter) {
|
|
222
|
+
var _toolAdapter$toolType;
|
|
223
|
+
const measurement = toolAdapter.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, trackingIdentifierValue);
|
|
224
|
+
measurement.TrackingUniqueIdentifier = trackingUniqueIdentifierValue;
|
|
225
|
+
console.log("=== ".concat(toolAdapter.toolType, " ==="));
|
|
226
|
+
console.log(measurement);
|
|
227
|
+
measurementData[_toolAdapter$toolType = toolAdapter.toolType] || (measurementData[_toolAdapter$toolType] = []);
|
|
228
|
+
measurementData[toolAdapter.toolType].push(measurement);
|
|
251
229
|
}
|
|
252
|
-
})
|
|
253
|
-
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.warn("Unable to generate tool state for", measurementGroup, e);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return measurementData;
|
|
235
|
+
}
|
|
236
|
+
static registerTool(toolAdapter) {
|
|
237
|
+
let replace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
238
|
+
const registerName = toolAdapter.toolType;
|
|
239
|
+
if (this.measurementAdapterByToolType.has(registerName)) {
|
|
240
|
+
if (!replace) {
|
|
241
|
+
throw new Error("The registered tool name ".concat(registerName, " already exists in adapters, use a different toolType or use replace"));
|
|
242
|
+
}
|
|
243
|
+
if (typeof replace === "function") {
|
|
244
|
+
replace(this.measurementAdapterByToolType.get(registerName));
|
|
245
|
+
}
|
|
254
246
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
247
|
+
this.measurementAdapterByToolType.set(toolAdapter.toolType, toolAdapter);
|
|
248
|
+
this.measurementAdapterByTrackingIdentifier.set(toolAdapter.trackingIdentifierTextValue, toolAdapter);
|
|
249
|
+
}
|
|
250
|
+
static registerTrackingIdentifier(toolClass) {
|
|
251
|
+
for (var _len = arguments.length, trackingIdentifiers = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
252
|
+
trackingIdentifiers[_key - 1] = arguments[_key];
|
|
261
253
|
}
|
|
262
|
-
|
|
263
|
-
|
|
254
|
+
for (const identifier of trackingIdentifiers) {
|
|
255
|
+
this.measurementAdapterByTrackingIdentifier.set(identifier, toolClass);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
static getAdapterForTrackingIdentifier(trackingIdentifier) {
|
|
259
|
+
const adapter = this.measurementAdapterByTrackingIdentifier.get(trackingIdentifier);
|
|
260
|
+
if (adapter) {
|
|
261
|
+
return adapter;
|
|
262
|
+
}
|
|
263
|
+
for (const adapterTest of [...this.measurementAdapterByToolType.values()]) {
|
|
264
|
+
if (adapterTest.isValidCornerstoneTrackingIdentifier(trackingIdentifier)) {
|
|
265
|
+
this.measurementAdapterByTrackingIdentifier.set(trackingIdentifier, adapterTest);
|
|
266
|
+
return adapterTest;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
264
271
|
_MeasurementReport = MeasurementReport;
|
|
265
272
|
_MeasurementReport.CORNERSTONE_3D_TAG = CORNERSTONE_3D_TAG;
|
|
266
|
-
_MeasurementReport.
|
|
267
|
-
_MeasurementReport.
|
|
268
|
-
_MeasurementReport.
|
|
269
|
-
|
|
270
|
-
|
|
273
|
+
_MeasurementReport.measurementAdapterByToolType = new Map();
|
|
274
|
+
_MeasurementReport.measurementAdapterByTrackingIdentifier = new Map();
|
|
275
|
+
_MeasurementReport.codeValueMatch = (group, code, oldCode) => {
|
|
276
|
+
const {
|
|
277
|
+
ConceptNameCodeSequence
|
|
278
|
+
} = group;
|
|
279
|
+
if (!ConceptNameCodeSequence) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const {
|
|
283
|
+
CodingSchemeDesignator,
|
|
284
|
+
CodeValue
|
|
285
|
+
} = ConceptNameCodeSequence;
|
|
286
|
+
return CodingSchemeDesignator == code.CodingSchemeDesignator && CodeValue == code.CodeValue || oldCode && CodingSchemeDesignator == oldCode.CodingSchemeDesignator && CodeValue == oldCode.CodeValue;
|
|
287
|
+
};
|
|
288
|
+
_MeasurementReport.generateDerivationSourceDataset = instance => {
|
|
289
|
+
const _vrMap = {
|
|
271
290
|
PixelData: "OW"
|
|
272
291
|
};
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
const _meta = _MeasurementReport.generateDatasetMeta();
|
|
293
|
+
const derivationSourceDataset = _objectSpread(_objectSpread({}, instance), {}, {
|
|
275
294
|
_meta: _meta,
|
|
276
295
|
_vrMap: _vrMap
|
|
277
296
|
});
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { CornerstonePMAP } from '../../Cornerstone/index.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const {
|
|
4
|
+
ParametricMap
|
|
5
|
+
} = CornerstonePMAP;
|
|
6
|
+
const {
|
|
7
|
+
generateToolState: generateToolStateCornerstone
|
|
8
|
+
} = ParametricMap;
|
|
5
9
|
function generateToolState(imageIds, arrayBuffer, metadataProvider) {
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
let skipOverlapping = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
11
|
+
let tolerance = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1e-3;
|
|
8
12
|
return generateToolStateCornerstone(imageIds, arrayBuffer, metadataProvider, skipOverlapping, tolerance);
|
|
9
13
|
}
|
|
10
14
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
static
|
|
4
|
-
static TID300Representation: any;
|
|
5
|
-
static isValidCornerstoneTrackingIdentifier: (TrackingIdentifier: any) => boolean;
|
|
1
|
+
import BaseAdapter3D from "./BaseAdapter3D";
|
|
2
|
+
declare class PlanarFreehandROI extends BaseAdapter3D {
|
|
3
|
+
static closedContourThreshold: number;
|
|
6
4
|
static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): {
|
|
7
5
|
description: any;
|
|
8
6
|
sopInstanceUid: any;
|