dcmjs 0.18.11 → 0.19.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/build/dcmjs.es.js CHANGED
@@ -7134,6 +7134,27 @@ var graphicTypeEquals = function graphicTypeEquals(graphicType) {
7134
7134
  };
7135
7135
  };
7136
7136
 
7137
+ var FINDING = {
7138
+ CodingSchemeDesignator: "DCM",
7139
+ CodeValue: "121071"
7140
+ };
7141
+ var FINDING_SITE = {
7142
+ CodingSchemeDesignator: "SCT",
7143
+ CodeValue: "363698007"
7144
+ };
7145
+ var FINDING_SITE_OLD = {
7146
+ CodingSchemeDesignator: "SRT",
7147
+ CodeValue: "G-C0E3"
7148
+ };
7149
+
7150
+ var codeValueMatch = function codeValueMatch(group, code, oldCode) {
7151
+ var ConceptNameCodeSequence = group.ConceptNameCodeSequence;
7152
+ if (!ConceptNameCodeSequence) return;
7153
+ var CodingSchemeDesignator = ConceptNameCodeSequence.CodingSchemeDesignator,
7154
+ CodeValue = ConceptNameCodeSequence.CodeValue;
7155
+ return CodingSchemeDesignator == code.CodingSchemeDesignator && CodeValue == code.CodeValue || oldCode && CodingSchemeDesignator == oldCode.CodingSchemeDesignator && CodeValue == oldCode.CodeValue;
7156
+ };
7157
+
7137
7158
  function getTID300ContentItem(tool, toolType, ReferencedSOPSequence, toolClass) {
7138
7159
  var args = toolClass.getTID300RepresentationArguments(tool);
7139
7160
  args.ReferencedSOPSequence = ReferencedSOPSequence;
@@ -7165,6 +7186,57 @@ function () {
7165
7186
  }
7166
7187
 
7167
7188
  _createClass(MeasurementReport, null, [{
7189
+ key: "getSetupMeasurementData",
7190
+ value: function getSetupMeasurementData(MeasurementGroup) {
7191
+ var ContentSequence = MeasurementGroup.ContentSequence;
7192
+ var contentSequenceArr = toArray(ContentSequence);
7193
+ var findingGroup = contentSequenceArr.find(function (group) {
7194
+ return codeValueMatch(group, FINDING);
7195
+ });
7196
+ var findingSiteGroups = contentSequenceArr.filter(function (group) {
7197
+ return codeValueMatch(group, FINDING_SITE, FINDING_SITE_OLD);
7198
+ }) || [];
7199
+ var NUMGroup = contentSequenceArr.find(function (group) {
7200
+ return group.ValueType === "NUM";
7201
+ });
7202
+ var SCOORDGroup = toArray(NUMGroup.ContentSequence).find(function (group) {
7203
+ return group.ValueType === "SCOORD";
7204
+ });
7205
+ var ReferencedSOPSequence = SCOORDGroup.ContentSequence.ReferencedSOPSequence;
7206
+ var ReferencedSOPInstanceUID = ReferencedSOPSequence.ReferencedSOPInstanceUID,
7207
+ ReferencedFrameNumber = ReferencedSOPSequence.ReferencedFrameNumber;
7208
+ var defaultState = {
7209
+ sopInstanceUid: ReferencedSOPInstanceUID,
7210
+ frameIndex: ReferencedFrameNumber || 1,
7211
+ complete: true,
7212
+ finding: findingGroup ? findingGroup.ConceptCodeSequence : undefined,
7213
+ findingSites: findingSiteGroups.map(function (fsg) {
7214
+ return _objectSpread2({}, fsg.ConceptCodeSequence);
7215
+ })
7216
+ };
7217
+
7218
+ if (defaultState.finding) {
7219
+ defaultState.description = defaultState.finding.CodeMeaning;
7220
+ }
7221
+
7222
+ var findingSite = defaultState.findingSites && defaultState.findingSites[0];
7223
+
7224
+ if (findingSite) {
7225
+ defaultState.location = findingSite[0] && findingSite[0].CodeMeaning || findingSite.CodeMeaning;
7226
+ }
7227
+
7228
+ return {
7229
+ defaultState: defaultState,
7230
+ findingGroup: findingGroup,
7231
+ findingSiteGroups: findingSiteGroups,
7232
+ NUMGroup: NUMGroup,
7233
+ SCOORDGroup: SCOORDGroup,
7234
+ ReferencedSOPSequence: ReferencedSOPSequence,
7235
+ ReferencedSOPInstanceUID: ReferencedSOPInstanceUID,
7236
+ ReferencedFrameNumber: ReferencedFrameNumber
7237
+ };
7238
+ }
7239
+ }, {
7168
7240
  key: "generateReport",
7169
7241
  value: function generateReport(toolState, metadataProvider, options) {
7170
7242
  // ToolState for array of imageIDs to a Report
@@ -7409,8 +7481,8 @@ function () {
7409
7481
  RelationshipType: "CONTAINS",
7410
7482
  ValueType: "CODE",
7411
7483
  ConceptNameCodeSequence: {
7412
- CodeValue: "G-C0E3",
7413
- CodingSchemeDesignator: "SRT",
7484
+ CodeValue: "363698007",
7485
+ CodingSchemeDesignator: "SCT",
7414
7486
  CodeMeaning: "Finding Site"
7415
7487
  },
7416
7488
  ConceptCodeSequence: {
@@ -7486,8 +7558,6 @@ function (_TID300Measurement) {
7486
7558
  var CORNERSTONE_4_TAG = "cornerstoneTools@^4.0.0";
7487
7559
 
7488
7560
  var LENGTH = "Length";
7489
- var FINDING = "121071";
7490
- var FINDING_SITE = "G-C0E3";
7491
7561
 
7492
7562
  var Length$1 =
7493
7563
  /*#__PURE__*/
@@ -7500,25 +7570,12 @@ function () {
7500
7570
  _createClass(Length, null, [{
7501
7571
  key: "getMeasurementData",
7502
7572
  value: function getMeasurementData(MeasurementGroup) {
7503
- var ContentSequence = MeasurementGroup.ContentSequence;
7504
- var findingGroup = toArray(ContentSequence).find(function (group) {
7505
- return group.ConceptNameCodeSequence.CodeValue === FINDING;
7506
- });
7507
- var findingSiteGroups = toArray(ContentSequence).filter(function (group) {
7508
- return group.ConceptNameCodeSequence.CodeValue === FINDING_SITE;
7509
- });
7510
- var NUMGroup = toArray(ContentSequence).find(function (group) {
7511
- return group.ValueType === "NUM";
7512
- });
7513
- var SCOORDGroup = toArray(NUMGroup.ContentSequence).find(function (group) {
7514
- return group.ValueType === "SCOORD";
7515
- });
7516
- var ReferencedSOPSequence = SCOORDGroup.ContentSequence.ReferencedSOPSequence;
7517
- var ReferencedSOPInstanceUID = ReferencedSOPSequence.ReferencedSOPInstanceUID,
7518
- ReferencedFrameNumber = ReferencedSOPSequence.ReferencedFrameNumber;
7519
- var lengthState = {
7520
- sopInstanceUid: ReferencedSOPInstanceUID,
7521
- frameIndex: ReferencedFrameNumber || 1,
7573
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
7574
+ defaultState = _MeasurementReport$ge.defaultState,
7575
+ NUMGroup = _MeasurementReport$ge.NUMGroup,
7576
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup;
7577
+
7578
+ var state = _objectSpread2({}, defaultState, {
7522
7579
  length: NUMGroup.MeasuredValueSequence.NumericValue,
7523
7580
  toolType: Length.toolType,
7524
7581
  handles: {
@@ -7531,20 +7588,16 @@ function () {
7531
7588
  allowedOutsideImage: true,
7532
7589
  hasBoundingBox: true
7533
7590
  }
7534
- },
7535
- finding: findingGroup ? findingGroup.ConceptCodeSequence : undefined,
7536
- findingSites: findingSiteGroups.map(function (fsg) {
7537
- return _objectSpread2({}, fsg.ConceptCodeSequence);
7538
- })
7539
- };
7591
+ }
7592
+ });
7540
7593
 
7541
7594
  var _SCOORDGroup$GraphicD = _slicedToArray(SCOORDGroup.GraphicData, 4);
7542
7595
 
7543
- lengthState.handles.start.x = _SCOORDGroup$GraphicD[0];
7544
- lengthState.handles.start.y = _SCOORDGroup$GraphicD[1];
7545
- lengthState.handles.end.x = _SCOORDGroup$GraphicD[2];
7546
- lengthState.handles.end.y = _SCOORDGroup$GraphicD[3];
7547
- return lengthState;
7596
+ state.handles.start.x = _SCOORDGroup$GraphicD[0];
7597
+ state.handles.start.y = _SCOORDGroup$GraphicD[1];
7598
+ state.handles.end.x = _SCOORDGroup$GraphicD[2];
7599
+ state.handles.end.y = _SCOORDGroup$GraphicD[3];
7600
+ return state;
7548
7601
  }
7549
7602
  }, {
7550
7603
  key: "getTID300RepresentationArguments",
@@ -7604,11 +7657,11 @@ MeasurementReport.registerTool(Length$1);
7604
7657
  function expandPoints(points) {
7605
7658
  var allPoints = [];
7606
7659
  points.forEach(function (point) {
7607
- allPoints.push(point[0]);
7608
- allPoints.push(point[1]);
7660
+ allPoints.push(point[0] || point.x);
7661
+ allPoints.push(point[1] || point.y);
7609
7662
 
7610
- if (point[2] !== undefined) {
7611
- allPoints.push(point[2]);
7663
+ if (point[2] !== undefined || point.z !== undefined) {
7664
+ allPoints.push(point[2] || point.z);
7612
7665
  }
7613
7666
  });
7614
7667
  return allPoints;
@@ -7630,24 +7683,20 @@ function (_TID300Measurement) {
7630
7683
  value: function contentItem() {
7631
7684
  var _this$props = this.props,
7632
7685
  points = _this$props.points,
7686
+ area = _this$props.area,
7633
7687
  ReferencedSOPSequence = _this$props.ReferencedSOPSequence,
7634
7688
  _this$props$use3DSpat = _this$props.use3DSpatialCoordinates,
7635
- use3DSpatialCoordinates = _this$props$use3DSpat === void 0 ? false : _this$props$use3DSpat; // Combine all lengths to save the perimeter
7636
- // @ToDO The permiter has to be implemented
7637
- // const reducer = (accumulator, currentValue) => accumulator + currentValue;
7638
- // const perimeter = lengths.reduce(reducer);
7639
-
7640
- var perimeter = {};
7689
+ use3DSpatialCoordinates = _this$props$use3DSpat === void 0 ? false : _this$props$use3DSpat,
7690
+ perimeter = _this$props.perimeter;
7641
7691
  var GraphicData = expandPoints(points); // TODO: Add Mean and STDev value of (modality?) pixels
7642
7692
 
7643
7693
  return this.getMeasurement([{
7644
7694
  RelationshipType: "CONTAINS",
7645
7695
  ValueType: "NUM",
7646
7696
  ConceptNameCodeSequence: {
7647
- CodeValue: "G-A197",
7648
- CodingSchemeDesignator: "SRT",
7649
- CodeMeaning: "Perimeter" // TODO: Look this up from a Code Meaning dictionary
7650
-
7697
+ CodeValue: "131191004",
7698
+ CodingSchemeDesignator: "SCT",
7699
+ CodeMeaning: "Perimeter"
7651
7700
  },
7652
7701
  MeasuredValueSequence: {
7653
7702
  MeasurementUnitsCodeSequence: {
@@ -7686,7 +7735,7 @@ function (_TID300Measurement) {
7686
7735
  CodingSchemeVersion: "1.4",
7687
7736
  CodeMeaning: "SquareMilliMeter"
7688
7737
  },
7689
- NumericValue: perimeter
7738
+ NumericValue: area
7690
7739
  },
7691
7740
  ContentSequence: {
7692
7741
  RelationshipType: "INFERRED FROM",
@@ -7706,59 +7755,100 @@ function (_TID300Measurement) {
7706
7755
  return Polyline;
7707
7756
  }(TID300Measurement);
7708
7757
 
7709
- var Freehand =
7758
+ var FreehandRoi =
7710
7759
  /*#__PURE__*/
7711
7760
  function () {
7712
- function Freehand() {
7713
- _classCallCheck(this, Freehand);
7761
+ function FreehandRoi() {
7762
+ _classCallCheck(this, FreehandRoi);
7714
7763
  }
7715
7764
 
7716
- _createClass(Freehand, null, [{
7717
- key: "measurementContentToLengthState",
7718
- value: function measurementContentToLengthState(groupItemContent) {
7719
- var content = groupItemContent.ContentSequence;
7720
- var ReferencedSOPSequence = content.ContentSequence.ReferencedSOPSequence;
7721
- var ReferencedSOPInstanceUID = ReferencedSOPSequence.ReferencedSOPInstanceUID,
7722
- ReferencedFrameNumber = ReferencedSOPSequence.ReferencedFrameNumber;
7723
- var state = {
7724
- sopInstanceUid: ReferencedSOPInstanceUID,
7725
- frameIndex: ReferencedFrameNumber || 0,
7726
- toolType: Freehand.toolType
7727
- }; // TODO: To be implemented!
7728
- // Needs to add points, lengths
7765
+ _createClass(FreehandRoi, null, [{
7766
+ key: "getMeasurementData",
7767
+ value: function getMeasurementData(MeasurementGroup) {
7768
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
7769
+ defaultState = _MeasurementReport$ge.defaultState,
7770
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup;
7729
7771
 
7730
- return state;
7731
- } // TODO: this function is required for all Cornerstone Tool Adapters, since it is called by MeasurementReport.
7772
+ var state = _objectSpread2({}, defaultState, {
7773
+ toolType: FreehandRoi.toolType,
7774
+ handles: {
7775
+ points: [],
7776
+ textBox: {
7777
+ active: false,
7778
+ hasMoved: false,
7779
+ movesIndependently: false,
7780
+ drawnIndependently: true,
7781
+ allowedOutsideImage: true,
7782
+ hasBoundingBox: true
7783
+ }
7784
+ },
7785
+ color: undefined,
7786
+ invalidated: true
7787
+ });
7732
7788
 
7733
- }, {
7734
- key: "getMeasurementData",
7735
- value: function getMeasurementData(measurementContent) {
7736
- return measurementContent.map(Freehand.measurementContentToLengthState);
7789
+ var GraphicData = SCOORDGroup.GraphicData;
7790
+
7791
+ for (var i = 0; i < GraphicData.length; i += 2) {
7792
+ state.handles.points.push({
7793
+ x: GraphicData[i],
7794
+ y: GraphicData[i + 1]
7795
+ });
7796
+ }
7797
+
7798
+ return state;
7737
7799
  }
7738
7800
  }, {
7739
7801
  key: "getTID300RepresentationArguments",
7740
7802
  value: function getTID300RepresentationArguments()
7741
7803
  /*tool*/
7742
7804
  {
7743
- // TO BE IMPLEMENTED
7805
+ var _tool = tool,
7806
+ handles = _tool.handles,
7807
+ finding = _tool.finding,
7808
+ findingSites = _tool.findingSites,
7809
+ cachedStats = _tool.cachedStats;
7810
+ var points = handles.points;
7811
+ var _cachedStats$area = cachedStats.area,
7812
+ area = _cachedStats$area === void 0 ? 0 : _cachedStats$area,
7813
+ _cachedStats$perimete = cachedStats.perimeter,
7814
+ perimeter = _cachedStats$perimete === void 0 ? 0 : _cachedStats$perimete;
7815
+ var trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:FreehandRoi";
7744
7816
  return {
7745
- /*points, lengths*/
7817
+ points: points,
7818
+ area: area,
7819
+ perimeter: perimeter,
7820
+ trackingIdentifierTextValue: trackingIdentifierTextValue,
7821
+ finding: finding,
7822
+ findingSites: findingSites || []
7746
7823
  };
7747
7824
  }
7748
7825
  }]);
7749
7826
 
7750
- return Freehand;
7827
+ return FreehandRoi;
7751
7828
  }();
7752
7829
 
7753
- Freehand.toolType = "Freehand";
7754
- Freehand.utilityToolType = "Freehand";
7755
- Freehand.TID300Representation = Polyline;
7830
+ FreehandRoi.toolType = "FreehandRoi";
7831
+ FreehandRoi.utilityToolType = "FreehandRoi";
7832
+ FreehandRoi.TID300Representation = Polyline;
7756
7833
 
7757
- Freehand.isValidCornerstoneTrackingIdentifier = function (TrackingIdentifier) {
7758
- return false; // TODO
7834
+ FreehandRoi.isValidCornerstoneTrackingIdentifier = function (TrackingIdentifier) {
7835
+ if (!TrackingIdentifier.includes(":")) {
7836
+ return false;
7837
+ }
7838
+
7839
+ var _TrackingIdentifier$s = TrackingIdentifier.split(":"),
7840
+ _TrackingIdentifier$s2 = _slicedToArray(_TrackingIdentifier$s, 2),
7841
+ cornerstone4Tag = _TrackingIdentifier$s2[0],
7842
+ toolType = _TrackingIdentifier$s2[1];
7843
+
7844
+ if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
7845
+ return false;
7846
+ }
7847
+
7848
+ return toolType === FreehandRoi.toolType;
7759
7849
  };
7760
7850
 
7761
- MeasurementReport.registerTool(Freehand);
7851
+ MeasurementReport.registerTool(FreehandRoi);
7762
7852
 
7763
7853
  var Bidirectional =
7764
7854
  /*#__PURE__*/
@@ -8083,8 +8173,6 @@ function (_TID300Measurement) {
8083
8173
  }(TID300Measurement);
8084
8174
 
8085
8175
  var ELLIPTICALROI = "EllipticalRoi";
8086
- var FINDING$2 = "121071";
8087
- var FINDING_SITE$2 = "G-C0E3";
8088
8176
 
8089
8177
  var EllipticalRoi =
8090
8178
  /*#__PURE__*/
@@ -8097,19 +8185,11 @@ function () {
8097
8185
  _createClass(EllipticalRoi, null, [{
8098
8186
  key: "getMeasurementData",
8099
8187
  value: function getMeasurementData(MeasurementGroup) {
8100
- var ContentSequence = MeasurementGroup.ContentSequence;
8101
- var findingGroup = toArray(ContentSequence).find(function (group) {
8102
- return group.ConceptNameCodeSequence.CodeValue === FINDING$2;
8103
- });
8104
- var findingSiteGroups = toArray(ContentSequence).filter(function (group) {
8105
- return group.ConceptNameCodeSequence.CodeValue === FINDING_SITE$2;
8106
- });
8107
- var NUMGroup = toArray(ContentSequence).find(function (group) {
8108
- return group.ValueType === "NUM";
8109
- });
8110
- var SCOORDGroup = toArray(NUMGroup.ContentSequence).find(function (group) {
8111
- return group.ValueType === "SCOORD";
8112
- });
8188
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
8189
+ defaultState = _MeasurementReport$ge.defaultState,
8190
+ NUMGroup = _MeasurementReport$ge.NUMGroup,
8191
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup;
8192
+
8113
8193
  var GraphicData = SCOORDGroup.GraphicData;
8114
8194
  var majorAxis = [{
8115
8195
  x: GraphicData[0],
@@ -8142,12 +8222,8 @@ function () {
8142
8222
  x: majorAxis[1].x - minorAxisDirection.x * halfMinorAxisLength,
8143
8223
  y: majorAxis[1].y - minorAxisDirection.y * halfMinorAxisLength
8144
8224
  };
8145
- var ReferencedSOPSequence = SCOORDGroup.ContentSequence.ReferencedSOPSequence;
8146
- var ReferencedSOPInstanceUID = ReferencedSOPSequence.ReferencedSOPInstanceUID,
8147
- ReferencedFrameNumber = ReferencedSOPSequence.ReferencedFrameNumber;
8148
- var state = {
8149
- sopInstanceUid: ReferencedSOPInstanceUID,
8150
- frameIndex: ReferencedFrameNumber || 0,
8225
+
8226
+ var state = _objectSpread2({}, defaultState, {
8151
8227
  toolType: EllipticalRoi.toolType,
8152
8228
  active: false,
8153
8229
  cachedStats: {
@@ -8176,12 +8252,9 @@ function () {
8176
8252
  }
8177
8253
  },
8178
8254
  invalidated: true,
8179
- visible: true,
8180
- finding: findingGroup ? findingGroup.ConceptCodeSequence : undefined,
8181
- findingSites: findingSiteGroups.map(function (fsg) {
8182
- return _objectSpread2({}, fsg.ConceptCodeSequence);
8183
- })
8184
- };
8255
+ visible: true
8256
+ });
8257
+
8185
8258
  return state;
8186
8259
  }
8187
8260
  }, {
@@ -8300,7 +8373,14 @@ function (_TID300Measurement) {
8300
8373
  ReferencedSOPSequence = _this$props.ReferencedSOPSequence,
8301
8374
  _this$props$use3DSpat = _this$props.use3DSpatialCoordinates,
8302
8375
  use3DSpatialCoordinates = _this$props$use3DSpat === void 0 ? false : _this$props$use3DSpat;
8303
- var GraphicData = use3DSpatialCoordinates ? [points[0].x, points[0].y, points[0].z] : [points[0].x, points[0].y];
8376
+ var GraphicData = use3DSpatialCoordinates ? [points[0].x, points[0].y, points[0].z] : [points[0].x, points[0].y]; // Allow storing another point as part of an indicator showing a single point
8377
+
8378
+ if (points.length == 2) {
8379
+ GraphicData.push(points[1].x);
8380
+ GraphicData.push(points[1].y);
8381
+ if (use3DSpatialCoordinates) GraphicData.push(points[1].z);
8382
+ }
8383
+
8304
8384
  return this.getMeasurement([{
8305
8385
  RelationshipType: "CONTAINS",
8306
8386
  ValueType: "NUM",
@@ -8329,8 +8409,6 @@ function (_TID300Measurement) {
8329
8409
  }(TID300Measurement);
8330
8410
 
8331
8411
  var ARROW_ANNOTATE = "ArrowAnnotate";
8332
- var FINDING$3 = "121071";
8333
- var FINDING_SITE$3 = "G-C0E3";
8334
8412
  var CORNERSTONEFREETEXT = "CORNERSTONEFREETEXT";
8335
8413
 
8336
8414
  var ArrowAnnotate =
@@ -8338,33 +8416,20 @@ var ArrowAnnotate =
8338
8416
  function () {
8339
8417
  function ArrowAnnotate() {
8340
8418
  _classCallCheck(this, ArrowAnnotate);
8341
- } // TODO: this function is required for all Cornerstone Tool Adapters, since it is called by MeasurementReport.
8342
-
8419
+ }
8343
8420
 
8344
8421
  _createClass(ArrowAnnotate, null, [{
8345
8422
  key: "getMeasurementData",
8346
8423
  value: function getMeasurementData(MeasurementGroup) {
8347
- var ContentSequence = MeasurementGroup.ContentSequence;
8348
- var NUMGroup = toArray(ContentSequence).find(function (group) {
8349
- return group.ValueType === "NUM";
8350
- });
8351
- var SCOORDGroup = toArray(NUMGroup.ContentSequence).find(function (group) {
8352
- return group.ValueType === "SCOORD";
8353
- });
8354
- var findingGroup = toArray(ContentSequence).find(function (group) {
8355
- return group.ConceptNameCodeSequence.CodeValue === FINDING$3;
8356
- });
8357
- var findingSiteGroups = toArray(ContentSequence).filter(function (group) {
8358
- return group.ConceptNameCodeSequence.CodeValue === FINDING_SITE$3;
8359
- });
8424
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
8425
+ defaultState = _MeasurementReport$ge.defaultState,
8426
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup,
8427
+ findingGroup = _MeasurementReport$ge.findingGroup;
8428
+
8360
8429
  var text = findingGroup.ConceptCodeSequence.CodeMeaning;
8361
8430
  var GraphicData = SCOORDGroup.GraphicData;
8362
- var ReferencedSOPSequence = SCOORDGroup.ContentSequence.ReferencedSOPSequence;
8363
- var ReferencedSOPInstanceUID = ReferencedSOPSequence.ReferencedSOPInstanceUID,
8364
- ReferencedFrameNumber = ReferencedSOPSequence.ReferencedFrameNumber;
8365
- var state = {
8366
- sopInstanceUid: ReferencedSOPInstanceUID,
8367
- frameIndex: ReferencedFrameNumber || 0,
8431
+
8432
+ var state = _objectSpread2({}, defaultState, {
8368
8433
  toolType: ArrowAnnotate.toolType,
8369
8434
  active: false,
8370
8435
  handles: {
@@ -8374,11 +8439,11 @@ function () {
8374
8439
  highlight: true,
8375
8440
  active: false
8376
8441
  },
8377
- // TODO: How do we choose where the end goes?
8378
- // Just put it pointing from the bottom right for now?
8442
+ // Use a generic offset if the stored data doesn't have the endpoint, otherwise
8443
+ // use the actual endpoint.
8379
8444
  end: {
8380
- x: GraphicData[0] + 20,
8381
- y: GraphicData[1] + 20,
8445
+ x: GraphicData.length == 4 ? GraphicData[2] : GraphicData[0] + 20,
8446
+ y: GraphicData.length == 4 ? GraphicData[3] : GraphicData[1] + 20,
8382
8447
  highlight: true,
8383
8448
  active: false
8384
8449
  },
@@ -8392,18 +8457,15 @@ function () {
8392
8457
  },
8393
8458
  invalidated: true,
8394
8459
  text: text,
8395
- visible: true,
8396
- finding: findingGroup ? findingGroup.ConceptCodeSequence : undefined,
8397
- findingSites: findingSiteGroups.map(function (fsg) {
8398
- return _objectSpread2({}, fsg.ConceptCodeSequence);
8399
- })
8400
- };
8460
+ visible: true
8461
+ });
8462
+
8401
8463
  return state;
8402
8464
  }
8403
8465
  }, {
8404
8466
  key: "getTID300RepresentationArguments",
8405
8467
  value: function getTID300RepresentationArguments(tool) {
8406
- var points = [tool.handles.start];
8468
+ var points = [tool.handles.start, tool.handles.end];
8407
8469
  var finding = tool.finding,
8408
8470
  findingSites = tool.findingSites;
8409
8471
  var TID300RepresentationArguments = {
@@ -13032,14 +13094,384 @@ function fillSegmentation$1(segmentation, inputLabelmaps3D) {
13032
13094
  console.warn("No generateSegmentation adapater for cornerstone version ".concat(cornerstoneToolsVersion, ", exiting."));
13033
13095
  }
13034
13096
 
13097
+ var CobbAngle =
13098
+ /*#__PURE__*/
13099
+ function (_TID300Measurement) {
13100
+ _inherits(CobbAngle, _TID300Measurement);
13101
+
13102
+ function CobbAngle() {
13103
+ _classCallCheck(this, CobbAngle);
13104
+
13105
+ return _possibleConstructorReturn(this, _getPrototypeOf(CobbAngle).apply(this, arguments));
13106
+ }
13107
+
13108
+ _createClass(CobbAngle, [{
13109
+ key: "contentItem",
13110
+ value: function contentItem() {
13111
+ var _this$props = this.props,
13112
+ point1 = _this$props.point1,
13113
+ point2 = _this$props.point2,
13114
+ point3 = _this$props.point3,
13115
+ point4 = _this$props.point4,
13116
+ rAngle = _this$props.rAngle,
13117
+ ReferencedSOPSequence = _this$props.ReferencedSOPSequence;
13118
+ return this.getMeasurement([{
13119
+ RelationshipType: "CONTAINS",
13120
+ ValueType: "NUM",
13121
+ ConceptNameCodeSequence: {
13122
+ CodeValue: "285285000",
13123
+ CodingSchemeDesignator: "SCT",
13124
+ CodeMeaning: "Cobb angle"
13125
+ },
13126
+ MeasuredValueSequence: {
13127
+ MeasurementUnitsCodeSequence: {
13128
+ CodeValue: "deg",
13129
+ CodingSchemeDesignator: "UCUM",
13130
+ CodingSchemeVersion: "1.4",
13131
+ CodeMeaning: "\xB0"
13132
+ },
13133
+ NumericValue: rAngle
13134
+ },
13135
+ ContentSequence: {
13136
+ RelationshipType: "INFERRED FROM",
13137
+ ValueType: "SCOORD",
13138
+ GraphicType: "POLYLINE",
13139
+ GraphicData: [point1.x, point1.y, point2.x, point2.y, point3.x, point3.y, point4.x, point4.y],
13140
+ ContentSequence: {
13141
+ RelationshipType: "SELECTED FROM",
13142
+ ValueType: "IMAGE",
13143
+ ReferencedSOPSequence: ReferencedSOPSequence
13144
+ }
13145
+ }
13146
+ }]);
13147
+ }
13148
+ }]);
13149
+
13150
+ return CobbAngle;
13151
+ }(TID300Measurement);
13152
+
13153
+ var COBB_ANGLE = "CobbAngle";
13154
+
13155
+ var CobbAngle$1 =
13156
+ /*#__PURE__*/
13157
+ function () {
13158
+ function CobbAngle() {
13159
+ _classCallCheck(this, CobbAngle);
13160
+ } // TODO: this function is required for all Cornerstone Tool Adapters, since it is called by MeasurementReport.
13161
+
13162
+
13163
+ _createClass(CobbAngle, null, [{
13164
+ key: "getMeasurementData",
13165
+ value: function getMeasurementData(MeasurementGroup) {
13166
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
13167
+ defaultState = _MeasurementReport$ge.defaultState,
13168
+ NUMGroup = _MeasurementReport$ge.NUMGroup,
13169
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup;
13170
+
13171
+ var state = _objectSpread2({}, defaultState, {
13172
+ rAngle: NUMGroup.MeasuredValueSequence.NumericValue,
13173
+ toolType: CobbAngle.toolType,
13174
+ handles: {
13175
+ start: {},
13176
+ end: {},
13177
+ start2: {
13178
+ highlight: true,
13179
+ drawnIndependently: true
13180
+ },
13181
+ end2: {
13182
+ highlight: true,
13183
+ drawnIndependently: true
13184
+ },
13185
+ textBox: {
13186
+ hasMoved: false,
13187
+ movesIndependently: false,
13188
+ drawnIndependently: true,
13189
+ allowedOutsideImage: true,
13190
+ hasBoundingBox: true
13191
+ }
13192
+ }
13193
+ });
13194
+
13195
+ var _SCOORDGroup$GraphicD = _slicedToArray(SCOORDGroup.GraphicData, 8);
13196
+
13197
+ state.handles.start.x = _SCOORDGroup$GraphicD[0];
13198
+ state.handles.start.y = _SCOORDGroup$GraphicD[1];
13199
+ state.handles.end.x = _SCOORDGroup$GraphicD[2];
13200
+ state.handles.end.y = _SCOORDGroup$GraphicD[3];
13201
+ state.handles.start2.x = _SCOORDGroup$GraphicD[4];
13202
+ state.handles.start2.y = _SCOORDGroup$GraphicD[5];
13203
+ state.handles.end2.x = _SCOORDGroup$GraphicD[6];
13204
+ state.handles.end2.y = _SCOORDGroup$GraphicD[7];
13205
+ return state;
13206
+ }
13207
+ }, {
13208
+ key: "getTID300RepresentationArguments",
13209
+ value: function getTID300RepresentationArguments(tool) {
13210
+ var handles = tool.handles,
13211
+ finding = tool.finding,
13212
+ findingSites = tool.findingSites;
13213
+ var point1 = handles.start;
13214
+ var point2 = handles.end;
13215
+ var point3 = handles.start2;
13216
+ var point4 = handles.end2;
13217
+ var rAngle = tool.rAngle;
13218
+ var trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:CobbAngle";
13219
+ return {
13220
+ point1: point1,
13221
+ point2: point2,
13222
+ point3: point3,
13223
+ point4: point4,
13224
+ rAngle: rAngle,
13225
+ trackingIdentifierTextValue: trackingIdentifierTextValue,
13226
+ finding: finding,
13227
+ findingSites: findingSites || []
13228
+ };
13229
+ }
13230
+ }]);
13231
+
13232
+ return CobbAngle;
13233
+ }();
13234
+
13235
+ CobbAngle$1.toolType = COBB_ANGLE;
13236
+ CobbAngle$1.utilityToolType = COBB_ANGLE;
13237
+ CobbAngle$1.TID300Representation = CobbAngle;
13238
+
13239
+ CobbAngle$1.isValidCornerstoneTrackingIdentifier = function (TrackingIdentifier) {
13240
+ if (!TrackingIdentifier.includes(":")) {
13241
+ return false;
13242
+ }
13243
+
13244
+ var _TrackingIdentifier$s = TrackingIdentifier.split(":"),
13245
+ _TrackingIdentifier$s2 = _slicedToArray(_TrackingIdentifier$s, 2),
13246
+ cornerstone4Tag = _TrackingIdentifier$s2[0],
13247
+ toolType = _TrackingIdentifier$s2[1];
13248
+
13249
+ if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
13250
+ return false;
13251
+ }
13252
+
13253
+ return toolType === COBB_ANGLE;
13254
+ };
13255
+
13256
+ MeasurementReport.registerTool(CobbAngle$1);
13257
+
13258
+ var ANGLE = "Angle";
13259
+
13260
+ var Angle =
13261
+ /*#__PURE__*/
13262
+ function () {
13263
+ function Angle() {
13264
+ _classCallCheck(this, Angle);
13265
+ }
13266
+ /**
13267
+ * Generate TID300 measurement data for a plane angle measurement - use a CobbAngle, but label it as Angle
13268
+ * @param MeasurementGroup
13269
+ * @returns
13270
+ */
13271
+
13272
+
13273
+ _createClass(Angle, null, [{
13274
+ key: "getMeasurementData",
13275
+ value: function getMeasurementData(MeasurementGroup) {
13276
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
13277
+ defaultState = _MeasurementReport$ge.defaultState,
13278
+ NUMGroup = _MeasurementReport$ge.NUMGroup,
13279
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup;
13280
+
13281
+ var state = _objectSpread2({}, defaultState, {
13282
+ rAngle: NUMGroup.MeasuredValueSequence.NumericValue,
13283
+ toolType: Angle.toolType,
13284
+ handles: {
13285
+ start: {},
13286
+ middle: {},
13287
+ end: {},
13288
+ textBox: {
13289
+ hasMoved: false,
13290
+ movesIndependently: false,
13291
+ drawnIndependently: true,
13292
+ allowedOutsideImage: true,
13293
+ hasBoundingBox: true
13294
+ }
13295
+ }
13296
+ });
13297
+
13298
+ var _SCOORDGroup$GraphicD = _slicedToArray(SCOORDGroup.GraphicData, 8);
13299
+
13300
+ state.handles.start.x = _SCOORDGroup$GraphicD[0];
13301
+ state.handles.start.y = _SCOORDGroup$GraphicD[1];
13302
+ state.handles.middle.x = _SCOORDGroup$GraphicD[2];
13303
+ state.handles.middle.y = _SCOORDGroup$GraphicD[3];
13304
+ state.handles.middle.x = _SCOORDGroup$GraphicD[4];
13305
+ state.handles.middle.y = _SCOORDGroup$GraphicD[5];
13306
+ state.handles.end.x = _SCOORDGroup$GraphicD[6];
13307
+ state.handles.end.y = _SCOORDGroup$GraphicD[7];
13308
+ return state;
13309
+ }
13310
+ }, {
13311
+ key: "getTID300RepresentationArguments",
13312
+ value: function getTID300RepresentationArguments(tool) {
13313
+ var handles = tool.handles,
13314
+ finding = tool.finding,
13315
+ findingSites = tool.findingSites;
13316
+ var point1 = handles.start;
13317
+ var point2 = handles.middle;
13318
+ var point3 = handles.middle;
13319
+ var point4 = handles.end;
13320
+ var rAngle = tool.rAngle;
13321
+ var trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:Angle";
13322
+ return {
13323
+ point1: point1,
13324
+ point2: point2,
13325
+ point3: point3,
13326
+ point4: point4,
13327
+ rAngle: rAngle,
13328
+ trackingIdentifierTextValue: trackingIdentifierTextValue,
13329
+ finding: finding,
13330
+ findingSites: findingSites || []
13331
+ };
13332
+ }
13333
+ }]);
13334
+
13335
+ return Angle;
13336
+ }();
13337
+
13338
+ Angle.toolType = ANGLE;
13339
+ Angle.utilityToolType = ANGLE;
13340
+ Angle.TID300Representation = CobbAngle;
13341
+
13342
+ Angle.isValidCornerstoneTrackingIdentifier = function (TrackingIdentifier) {
13343
+ if (!TrackingIdentifier.includes(":")) {
13344
+ return false;
13345
+ }
13346
+
13347
+ var _TrackingIdentifier$s = TrackingIdentifier.split(":"),
13348
+ _TrackingIdentifier$s2 = _slicedToArray(_TrackingIdentifier$s, 2),
13349
+ cornerstone4Tag = _TrackingIdentifier$s2[0],
13350
+ toolType = _TrackingIdentifier$s2[1];
13351
+
13352
+ if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
13353
+ return false;
13354
+ }
13355
+
13356
+ return toolType === ANGLE;
13357
+ };
13358
+
13359
+ MeasurementReport.registerTool(Angle);
13360
+
13361
+ var RectangleRoi =
13362
+ /*#__PURE__*/
13363
+ function () {
13364
+ function RectangleRoi() {
13365
+ _classCallCheck(this, RectangleRoi);
13366
+ }
13367
+
13368
+ _createClass(RectangleRoi, null, [{
13369
+ key: "getMeasurementData",
13370
+ value: function getMeasurementData(MeasurementGroup) {
13371
+ var _MeasurementReport$ge = MeasurementReport.getSetupMeasurementData(MeasurementGroup),
13372
+ defaultState = _MeasurementReport$ge.defaultState,
13373
+ SCOORDGroup = _MeasurementReport$ge.SCOORDGroup;
13374
+
13375
+ var state = _objectSpread2({}, defaultState, {
13376
+ toolType: RectangleRoi.toolType,
13377
+ handles: {
13378
+ start: {},
13379
+ end: {},
13380
+ textBox: {
13381
+ active: false,
13382
+ hasMoved: false,
13383
+ movesIndependently: false,
13384
+ drawnIndependently: true,
13385
+ allowedOutsideImage: true,
13386
+ hasBoundingBox: true
13387
+ },
13388
+ initialRotation: 0
13389
+ },
13390
+ color: undefined,
13391
+ invalidated: true
13392
+ });
13393
+
13394
+ var intermediate = {};
13395
+
13396
+ var _SCOORDGroup$GraphicD = _slicedToArray(SCOORDGroup.GraphicData, 6);
13397
+
13398
+ state.handles.start.x = _SCOORDGroup$GraphicD[0];
13399
+ state.handles.start.y = _SCOORDGroup$GraphicD[1];
13400
+ intermediate.x = _SCOORDGroup$GraphicD[2];
13401
+ intermediate.y = _SCOORDGroup$GraphicD[3];
13402
+ state.handles.end.x = _SCOORDGroup$GraphicD[4];
13403
+ state.handles.end.y = _SCOORDGroup$GraphicD[5];
13404
+ return state;
13405
+ }
13406
+ }, {
13407
+ key: "getTID300RepresentationArguments",
13408
+ value: function getTID300RepresentationArguments(tool) {
13409
+ var finding = tool.finding,
13410
+ findingSites = tool.findingSites,
13411
+ cachedStats = tool.cachedStats,
13412
+ handles = tool.handles;
13413
+ console.log("getTID300 Rectangle", tool, cachedStats, handles);
13414
+ var start = handles.start,
13415
+ end = handles.end;
13416
+ var points = [start, {
13417
+ x: start.x,
13418
+ y: end.y
13419
+ }, end, {
13420
+ x: end.x,
13421
+ y: start.y
13422
+ }];
13423
+ var area = cachedStats.area,
13424
+ perimeter = cachedStats.perimeter;
13425
+ console.log("Point=", points, "cachedStats=", cachedStats);
13426
+ var trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:RectangleRoi";
13427
+ return {
13428
+ points: points,
13429
+ area: area,
13430
+ perimeter: perimeter,
13431
+ trackingIdentifierTextValue: trackingIdentifierTextValue,
13432
+ finding: finding,
13433
+ findingSites: findingSites || []
13434
+ };
13435
+ }
13436
+ }]);
13437
+
13438
+ return RectangleRoi;
13439
+ }();
13440
+
13441
+ RectangleRoi.toolType = "RectangleRoi";
13442
+ RectangleRoi.utilityToolType = "RectangleRoi";
13443
+ RectangleRoi.TID300Representation = Polyline;
13444
+
13445
+ RectangleRoi.isValidCornerstoneTrackingIdentifier = function (TrackingIdentifier) {
13446
+ if (!TrackingIdentifier.includes(":")) {
13447
+ return false;
13448
+ }
13449
+
13450
+ var _TrackingIdentifier$s = TrackingIdentifier.split(":"),
13451
+ _TrackingIdentifier$s2 = _slicedToArray(_TrackingIdentifier$s, 2),
13452
+ cornerstone4Tag = _TrackingIdentifier$s2[0],
13453
+ toolType = _TrackingIdentifier$s2[1];
13454
+
13455
+ if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
13456
+ return false;
13457
+ }
13458
+
13459
+ return toolType === RectangleRoi.toolType;
13460
+ };
13461
+
13462
+ MeasurementReport.registerTool(RectangleRoi);
13463
+
13035
13464
  var Cornerstone = {
13036
13465
  Length: Length$1,
13037
- Freehand: Freehand,
13466
+ FreehandRoi: FreehandRoi,
13038
13467
  Bidirectional: Bidirectional$1,
13039
13468
  EllipticalRoi: EllipticalRoi,
13040
13469
  ArrowAnnotate: ArrowAnnotate,
13041
13470
  MeasurementReport: MeasurementReport,
13042
- Segmentation: Segmentation$3
13471
+ Segmentation: Segmentation$3,
13472
+ CobbAngle: CobbAngle$1,
13473
+ Angle: Angle,
13474
+ RectangleRoi: RectangleRoi
13043
13475
  };
13044
13476
 
13045
13477
  // Should we move it to Colors.js
@@ -13964,6 +14396,7 @@ var TID1500 = {
13964
14396
  var TID300 = {
13965
14397
  TID300Measurement: TID300Measurement,
13966
14398
  Length: Length,
14399
+ CobbAngle: CobbAngle,
13967
14400
  Bidirectional: Bidirectional,
13968
14401
  Polyline: Polyline,
13969
14402
  Ellipse: Ellipse