@cornerstonejs/adapters 1.20.0 → 1.20.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.
@@ -5478,266 +5478,220 @@ function getStructureSetModule(contour, index) {
5478
5478
  }
5479
5479
 
5480
5480
  var DicomMetaDictionary = dcmjs.data.DicomMetaDictionary;
5481
- var RTSS = /*#__PURE__*/function () {
5482
- function RTSS() {
5483
- _classCallCheck(this, RTSS);
5484
- }
5485
- _createClass(RTSS, null, [{
5486
- key: "generateRTSSFromSegmentations",
5487
- value:
5488
- /**
5489
- * Convert handles to RTSS report containing the dcmjs dicom dataset.
5490
- *
5491
- * Note: current WIP and using segmentation to contour conversion,
5492
- * routine that is not fully tested
5493
- *
5494
- * @param segmentations - Cornerstone tool segmentations data
5495
- * @param metadataProvider - Metadata provider
5496
- * @param DicomMetadataStore - metadata store instance
5497
- * @param cs - cornerstone instance
5498
- * @param csTools - cornerstone tool instance
5499
- * @returns Report object containing the dataset
5500
- */
5501
- function generateRTSSFromSegmentations(segmentations, metadataProvider, DicomMetadataStore, cornerstoneCache, cornerstoneToolsEnums, vtkUtils) {
5502
- // Convert segmentations to ROIContours
5503
- var roiContours = [];
5504
- var contourSets = generateContourSetsFromLabelmap({
5481
+ /**
5482
+ * Convert handles to RTSS report containing the dcmjs dicom dataset.
5483
+ *
5484
+ * Note: current WIP and using segmentation to contour conversion,
5485
+ * routine that is not fully tested
5486
+ *
5487
+ * @param segmentations - Cornerstone tool segmentations data
5488
+ * @param metadataProvider - Metadata provider
5489
+ * @param DicomMetadataStore - metadata store instance
5490
+ * @param cs - cornerstone instance
5491
+ * @param csTools - cornerstone tool instance
5492
+ * @returns Report object containing the dataset
5493
+ */
5494
+ function generateRTSSFromSegmentations(segmentations, metadataProvider, DicomMetadataStore, cornerstoneCache, cornerstoneToolsEnums, vtkUtils) {
5495
+ // Convert segmentations to ROIContours
5496
+ var roiContours = [];
5497
+ var contourSets = generateContourSetsFromLabelmap({
5505
5498
  segmentations: segmentations,
5506
5499
  cornerstoneCache: cornerstoneCache,
5507
5500
  cornerstoneToolsEnums: cornerstoneToolsEnums,
5508
5501
  vtkUtils: vtkUtils
5509
- });
5510
- contourSets.forEach(function (contourSet, segIndex) {
5502
+ });
5503
+ contourSets.forEach(function (contourSet, segIndex) {
5511
5504
  // Check contour set isn't undefined
5512
5505
  if (contourSet) {
5513
- var contourSequence = [];
5514
- contourSet.sliceContours.forEach(function (sliceContour) {
5515
- /**
5516
- * addContour - Adds a new ROI with related contours to ROIContourSequence
5517
- *
5518
- * @param newContour - cornerstoneTools `ROIContour` object
5519
- *
5520
- * newContour = {
5521
- * name: string,
5522
- * description: string,
5523
- * contourSequence: array[contour]
5524
- * color: array[number],
5525
- * metadata: {
5526
- * referencedImageId: string,
5527
- * FrameOfReferenceUID: string
5528
- * }
5529
- * }
5530
- *
5531
- * contour = {
5532
- * ContourImageSequence: array[
5533
- * { ReferencedSOPClassUID: string, ReferencedSOPInstanceUID: string}
5534
- * ]
5535
- * ContourGeometricType: string,
5536
- * NumberOfContourPoints: number,
5537
- * ContourData: array[number]
5538
- * }
5539
- */
5540
- // Note: change needed if support non-planar contour representation is needed
5541
- var sopCommon = metadataProvider.get("sopCommonModule", sliceContour.referencedImageId);
5542
- var ReferencedSOPClassUID = sopCommon.sopClassUID;
5543
- var ReferencedSOPInstanceUID = sopCommon.sopInstanceUID;
5544
- var ContourImageSequence = [{
5545
- ReferencedSOPClassUID: ReferencedSOPClassUID,
5546
- ReferencedSOPInstanceUID: ReferencedSOPInstanceUID
5547
- } // NOTE: replace in dcmjs?
5548
- ];
5549
-
5550
- var sliceContourPolyData = sliceContour.polyData;
5551
- sliceContour.contours.forEach(function (contour, index) {
5552
- var ContourGeometricType = contour.type;
5553
- var NumberOfContourPoints = contour.contourPoints.length;
5554
- var ContourData = [];
5555
- contour.contourPoints.forEach(function (point) {
5556
- var pointData = sliceContourPolyData.points[point];
5557
- pointData[0] = +pointData[0].toFixed(2);
5558
- pointData[1] = +pointData[1].toFixed(2);
5559
- pointData[2] = +pointData[2].toFixed(2);
5560
- ContourData.push(pointData[0]);
5561
- ContourData.push(pointData[1]);
5562
- ContourData.push(pointData[2]);
5563
- });
5564
- contourSequence.push({
5565
- ContourImageSequence: ContourImageSequence,
5566
- ContourGeometricType: ContourGeometricType,
5567
- NumberOfContourPoints: NumberOfContourPoints,
5568
- ContourNumber: index + 1,
5569
- ContourData: ContourData
5570
- });
5506
+ var contourSequence_1 = [];
5507
+ contourSet.sliceContours.forEach(function (sliceContour) {
5508
+ /**
5509
+ * addContour - Adds a new ROI with related contours to ROIContourSequence
5510
+ *
5511
+ * @param newContour - cornerstoneTools `ROIContour` object
5512
+ *
5513
+ * newContour = {
5514
+ * name: string,
5515
+ * description: string,
5516
+ * contourSequence: array[contour]
5517
+ * color: array[number],
5518
+ * metadata: {
5519
+ * referencedImageId: string,
5520
+ * FrameOfReferenceUID: string
5521
+ * }
5522
+ * }
5523
+ *
5524
+ * contour = {
5525
+ * ContourImageSequence: array[
5526
+ * { ReferencedSOPClassUID: string, ReferencedSOPInstanceUID: string}
5527
+ * ]
5528
+ * ContourGeometricType: string,
5529
+ * NumberOfContourPoints: number,
5530
+ * ContourData: array[number]
5531
+ * }
5532
+ */
5533
+ // Note: change needed if support non-planar contour representation is needed
5534
+ var sopCommon = metadataProvider.get("sopCommonModule", sliceContour.referencedImageId);
5535
+ var ReferencedSOPClassUID = sopCommon.sopClassUID;
5536
+ var ReferencedSOPInstanceUID = sopCommon.sopInstanceUID;
5537
+ var ContourImageSequence = [
5538
+ { ReferencedSOPClassUID: ReferencedSOPClassUID, ReferencedSOPInstanceUID: ReferencedSOPInstanceUID } // NOTE: replace in dcmjs?
5539
+ ];
5540
+ var sliceContourPolyData = sliceContour.polyData;
5541
+ sliceContour.contours.forEach(function (contour, index) {
5542
+ var ContourGeometricType = contour.type;
5543
+ var NumberOfContourPoints = contour.contourPoints.length;
5544
+ var ContourData = [];
5545
+ contour.contourPoints.forEach(function (point) {
5546
+ var pointData = sliceContourPolyData.points[point];
5547
+ pointData[0] = +pointData[0].toFixed(2);
5548
+ pointData[1] = +pointData[1].toFixed(2);
5549
+ pointData[2] = +pointData[2].toFixed(2);
5550
+ ContourData.push(pointData[0]);
5551
+ ContourData.push(pointData[1]);
5552
+ ContourData.push(pointData[2]);
5553
+ });
5554
+ contourSequence_1.push({
5555
+ ContourImageSequence: ContourImageSequence,
5556
+ ContourGeometricType: ContourGeometricType,
5557
+ NumberOfContourPoints: NumberOfContourPoints,
5558
+ ContourNumber: index + 1,
5559
+ ContourData: ContourData
5560
+ });
5561
+ });
5571
5562
  });
5572
- });
5573
- var segLabel = contourSet.label || "Segment ".concat(segIndex + 1);
5574
- var ROIContour = {
5575
- name: segLabel,
5576
- description: segLabel,
5577
- contourSequence: contourSequence,
5578
- color: contourSet.color,
5579
- metadata: contourSet.metadata
5580
- };
5581
- roiContours.push(ROIContour);
5563
+ var segLabel = contourSet.label || "Segment ".concat(segIndex + 1);
5564
+ var ROIContour = {
5565
+ name: segLabel,
5566
+ description: segLabel,
5567
+ contourSequence: contourSequence_1,
5568
+ color: contourSet.color,
5569
+ metadata: contourSet.metadata
5570
+ };
5571
+ roiContours.push(ROIContour);
5582
5572
  }
5583
- });
5584
- var rtMetadata = {
5573
+ });
5574
+ var rtMetadata = {
5585
5575
  name: segmentations.label,
5586
5576
  label: segmentations.label
5587
- };
5588
- var dataset = initializeDataset(rtMetadata, roiContours[0].metadata, metadataProvider);
5589
- roiContours.forEach(function (contour, index) {
5577
+ };
5578
+ var dataset = _initializeDataset(rtMetadata, roiContours[0].metadata, metadataProvider);
5579
+ roiContours.forEach(function (contour, index) {
5590
5580
  var roiContour = {
5591
- ROIDisplayColor: contour.color || [255, 0, 0],
5592
- ContourSequence: contour.contourSequence,
5593
- ReferencedROINumber: index + 1
5581
+ ROIDisplayColor: contour.color || [255, 0, 0],
5582
+ ContourSequence: contour.contourSequence,
5583
+ ReferencedROINumber: index + 1
5594
5584
  };
5595
5585
  dataset.StructureSetROISequence.push(getStructureSetModule(contour, index));
5596
5586
  dataset.ROIContourSequence.push(roiContour);
5597
-
5598
5587
  // ReferencedSeriesSequence
5599
5588
  dataset.ReferencedSeriesSequence = getReferencedSeriesSequence(contour.metadata, index, metadataProvider, DicomMetadataStore);
5600
-
5601
5589
  // ReferencedFrameOfReferenceSequence
5602
- dataset.ReferencedFrameOfReferenceSequence = getReferencedFrameOfReferenceSequence(contour.metadata, metadataProvider, dataset);
5603
- });
5604
- var fileMetaInformationVersionArray = new Uint8Array(2);
5605
- fileMetaInformationVersionArray[1] = 1;
5606
- var _meta = {
5590
+ dataset.ReferencedFrameOfReferenceSequence =
5591
+ getReferencedFrameOfReferenceSequence(contour.metadata, metadataProvider, dataset);
5592
+ });
5593
+ var fileMetaInformationVersionArray = new Uint8Array(2);
5594
+ fileMetaInformationVersionArray[1] = 1;
5595
+ var _meta = {
5607
5596
  FileMetaInformationVersion: {
5608
- Value: [fileMetaInformationVersionArray.buffer],
5609
- vr: "OB"
5597
+ Value: [fileMetaInformationVersionArray.buffer],
5598
+ vr: "OB"
5610
5599
  },
5611
5600
  TransferSyntaxUID: {
5612
- Value: ["1.2.840.10008.1.2.1"],
5613
- vr: "UI"
5601
+ Value: ["1.2.840.10008.1.2.1"],
5602
+ vr: "UI"
5614
5603
  },
5615
5604
  ImplementationClassUID: {
5616
- Value: [DicomMetaDictionary.uid()],
5617
- // TODO: could be git hash or other valid id
5618
- vr: "UI"
5605
+ Value: [DicomMetaDictionary.uid()],
5606
+ vr: "UI"
5619
5607
  },
5620
5608
  ImplementationVersionName: {
5621
- Value: ["dcmjs"],
5622
- vr: "SH"
5609
+ Value: ["dcmjs"],
5610
+ vr: "SH"
5623
5611
  }
5624
- };
5625
- dataset._meta = _meta;
5626
- return dataset;
5627
- }
5628
-
5629
- /**
5630
- * Convert handles to RTSSReport report object containing the dcmjs dicom dataset.
5631
- *
5632
- * Note: The tool data needs to be formatted in a specific way, and currently
5633
- * it is limited to the RectangleROIStartEndTool in the Cornerstone.
5634
- *
5635
- * @param annotations Array of Cornerstone tool annotation data
5636
- * @param metadataProvider Metadata provider
5637
- * @param options report generation options
5638
- * @returns Report object containing the dataset
5639
- */
5640
- }, {
5641
- key: "generateRTSSFromAnnotations",
5642
- value: function generateRTSSFromAnnotations(annotations, metadataProvider, DicomMetadataStore, options) {
5643
- var rtMetadata = {
5612
+ };
5613
+ dataset._meta = _meta;
5614
+ return dataset;
5615
+ }
5616
+ /**
5617
+ * Convert handles to RTSSReport report object containing the dcmjs dicom dataset.
5618
+ *
5619
+ * Note: The tool data needs to be formatted in a specific way, and currently
5620
+ * it is limited to the RectangleROIStartEndTool in the Cornerstone.
5621
+ *
5622
+ * @param annotations Array of Cornerstone tool annotation data
5623
+ * @param metadataProvider Metadata provider
5624
+ * @param options report generation options
5625
+ * @returns Report object containing the dataset
5626
+ */
5627
+ function generateRTSSFromAnnotations(annotations, metadataProvider, DicomMetadataStore, options) {
5628
+ var rtMetadata = {
5644
5629
  name: "RTSS from Annotations",
5645
5630
  label: "RTSS from Annotations"
5646
- };
5647
- var dataset = initializeDataset(rtMetadata, annotations[0].metadata, metadataProvider);
5648
- annotations.forEach(function (annotation, index) {
5631
+ };
5632
+ var dataset = _initializeDataset(rtMetadata, annotations[0].metadata, metadataProvider);
5633
+ annotations.forEach(function (annotation, index) {
5649
5634
  var ContourSequence = AnnotationToPointData.convert(annotation, index, metadataProvider, options);
5650
5635
  dataset.StructureSetROISequence.push(getStructureSetModule(annotation, index));
5651
5636
  dataset.ROIContourSequence.push(ContourSequence);
5652
5637
  dataset.RTROIObservationsSequence.push(getRTROIObservationsSequence(annotation, index));
5653
-
5654
5638
  // ReferencedSeriesSequence
5655
5639
  // Todo: handle more than one series
5656
5640
  dataset.ReferencedSeriesSequence = getReferencedSeriesSequence(annotation.metadata, index, metadataProvider, DicomMetadataStore);
5657
-
5658
5641
  // ReferencedFrameOfReferenceSequence
5659
- dataset.ReferencedFrameOfReferenceSequence = getReferencedFrameOfReferenceSequence(annotation.metadata, metadataProvider, dataset);
5660
- });
5661
- var fileMetaInformationVersionArray = new Uint8Array(2);
5662
- fileMetaInformationVersionArray[1] = 1;
5663
- var _meta = {
5642
+ dataset.ReferencedFrameOfReferenceSequence =
5643
+ getReferencedFrameOfReferenceSequence(annotation.metadata, metadataProvider, dataset);
5644
+ });
5645
+ var fileMetaInformationVersionArray = new Uint8Array(2);
5646
+ fileMetaInformationVersionArray[1] = 1;
5647
+ var _meta = {
5664
5648
  FileMetaInformationVersion: {
5665
- Value: [fileMetaInformationVersionArray.buffer],
5666
- vr: "OB"
5649
+ Value: [fileMetaInformationVersionArray.buffer],
5650
+ vr: "OB"
5667
5651
  },
5668
5652
  TransferSyntaxUID: {
5669
- Value: ["1.2.840.10008.1.2.1"],
5670
- vr: "UI"
5653
+ Value: ["1.2.840.10008.1.2.1"],
5654
+ vr: "UI"
5671
5655
  },
5672
5656
  ImplementationClassUID: {
5673
- Value: [DicomMetaDictionary.uid()],
5674
- // TODO: could be git hash or other valid id
5675
- vr: "UI"
5657
+ Value: [DicomMetaDictionary.uid()],
5658
+ vr: "UI"
5676
5659
  },
5677
5660
  ImplementationVersionName: {
5678
- Value: ["dcmjs"],
5679
- vr: "SH"
5661
+ Value: ["dcmjs"],
5662
+ vr: "SH"
5680
5663
  }
5681
- };
5682
- dataset._meta = _meta;
5683
- return dataset;
5684
- }
5685
-
5686
- /**
5687
- * Generate Cornerstone tool state from dataset
5688
- * @param {object} dataset dataset
5689
- * @param {object} hooks
5690
- * @param {function} hooks.getToolClass Function to map dataset to a tool class
5691
- * @returns
5692
- */
5693
- //static generateToolState(_dataset, _hooks = {}) {
5694
- }, {
5695
- key: "generateToolState",
5696
- value: function generateToolState() {
5697
- // Todo
5698
- console.warn("RTSS.generateToolState not implemented");
5699
- }
5700
- }]);
5701
- return RTSS;
5702
- }();
5703
- function initializeDataset(rtMetadata, imgMetadata, metadataProvider) {
5704
- var rtSOPInstanceUID = DicomMetaDictionary.uid();
5705
-
5706
- // get the first annotation data
5707
- var imageId = imgMetadata.referencedImageId,
5708
- FrameOfReferenceUID = imgMetadata.FrameOfReferenceUID;
5709
- var _metadataProvider$get = metadataProvider.get("generalSeriesModule", imageId),
5710
- studyInstanceUID = _metadataProvider$get.studyInstanceUID;
5711
- var patientModule = getPatientModule(imageId, metadataProvider);
5712
- var rtSeriesModule = getRTSeriesModule(DicomMetaDictionary);
5713
- return _objectSpread2(_objectSpread2(_objectSpread2({
5714
- StructureSetROISequence: [],
5715
- ROIContourSequence: [],
5716
- RTROIObservationsSequence: [],
5717
- ReferencedSeriesSequence: [],
5718
- ReferencedFrameOfReferenceSequence: []
5719
- }, patientModule), rtSeriesModule), {}, {
5720
- StudyInstanceUID: studyInstanceUID,
5721
- SOPClassUID: "1.2.840.10008.5.1.4.1.1.481.3",
5722
- // RT Structure Set Storage
5723
- SOPInstanceUID: rtSOPInstanceUID,
5724
- Manufacturer: "dcmjs",
5725
- Modality: "RTSTRUCT",
5726
- FrameOfReferenceUID: FrameOfReferenceUID,
5727
- PositionReferenceIndicator: "",
5728
- StructureSetLabel: rtMetadata.label || "",
5729
- StructureSetName: rtMetadata.name || "",
5730
- ReferringPhysicianName: "",
5731
- OperatorsName: "",
5732
- StructureSetDate: DicomMetaDictionary.date(),
5733
- StructureSetTime: DicomMetaDictionary.time()
5734
- });
5664
+ };
5665
+ dataset._meta = _meta;
5666
+ return dataset;
5667
+ }
5668
+ // /**
5669
+ // * Generate Cornerstone tool state from dataset
5670
+ // * @param {object} dataset dataset
5671
+ // * @param {object} hooks
5672
+ // * @param {function} hooks.getToolClass Function to map dataset to a tool class
5673
+ // * @returns
5674
+ // */
5675
+ // //static generateToolState(_dataset, _hooks = {}) {
5676
+ // function generateToolState() {
5677
+ // // Todo
5678
+ // console.warn("RTSS.generateToolState not implemented");
5679
+ // }
5680
+ function _initializeDataset(rtMetadata, imgMetadata, metadataProvider) {
5681
+ var rtSOPInstanceUID = DicomMetaDictionary.uid();
5682
+ // get the first annotation data
5683
+ var imageId = imgMetadata.referencedImageId, FrameOfReferenceUID = imgMetadata.FrameOfReferenceUID;
5684
+ var studyInstanceUID = metadataProvider.get("generalSeriesModule", imageId).studyInstanceUID;
5685
+ var patientModule = getPatientModule(imageId, metadataProvider);
5686
+ var rtSeriesModule = getRTSeriesModule(DicomMetaDictionary);
5687
+ return __assign(__assign(__assign({ StructureSetROISequence: [], ROIContourSequence: [], RTROIObservationsSequence: [], ReferencedSeriesSequence: [], ReferencedFrameOfReferenceSequence: [] }, patientModule), rtSeriesModule), { StudyInstanceUID: studyInstanceUID, SOPClassUID: "1.2.840.10008.5.1.4.1.1.481.3", SOPInstanceUID: rtSOPInstanceUID, Manufacturer: "dcmjs", Modality: "RTSTRUCT", FrameOfReferenceUID: FrameOfReferenceUID, PositionReferenceIndicator: "", StructureSetLabel: rtMetadata.label || "", StructureSetName: rtMetadata.name || "", ReferringPhysicianName: "", OperatorsName: "", StructureSetDate: DicomMetaDictionary.date(), StructureSetTime: DicomMetaDictionary.time() });
5735
5688
  }
5736
5689
 
5737
- var RTStruct = /*#__PURE__*/Object.freeze({
5690
+ var RTSS = /*#__PURE__*/Object.freeze({
5738
5691
  __proto__: null,
5739
- RTSS: RTSS,
5740
- generateContourSetsFromLabelmap: generateContourSetsFromLabelmap
5692
+ generateContourSetsFromLabelmap: generateContourSetsFromLabelmap,
5693
+ generateRTSSFromAnnotations: generateRTSSFromAnnotations,
5694
+ generateRTSSFromSegmentations: generateRTSSFromSegmentations
5741
5695
  });
5742
5696
 
5743
5697
  var Cornerstone3DSR = {
@@ -5756,8 +5710,10 @@ var Cornerstone3DSR = {
5756
5710
  CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG
5757
5711
  };
5758
5712
  var Cornerstone3DSEG = {
5759
- Segmentation: Segmentation$1,
5760
- RTStruct: RTStruct
5713
+ Segmentation: Segmentation$1
5714
+ };
5715
+ var Cornerstone3DRT = {
5716
+ RTSS: RTSS
5761
5717
  };
5762
5718
 
5763
5719
  var Colors = data.Colors,
@@ -5956,6 +5912,9 @@ var adaptersSEG = {
5956
5912
  Cornerstone3D: Cornerstone3DSEG,
5957
5913
  VTKjs: VTKjsSEG
5958
5914
  };
5915
+ var adaptersRT = {
5916
+ Cornerstone3D: Cornerstone3DRT
5917
+ };
5959
5918
 
5960
- export { index as Enums, adaptersSEG, adaptersSR, index$1 as helpers };
5919
+ export { index as Enums, adaptersRT, adaptersSEG, adaptersSR, index$1 as helpers };
5961
5920
  //# sourceMappingURL=adapters.es.js.map