@cornerstonejs/metadata 5.13.2 → 5.15.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.
Files changed (100) hide show
  1. package/dist/esm/displayset/BaseDisplaySet.d.ts +3 -4
  2. package/dist/esm/displayset/BaseDisplaySet.js +1 -5
  3. package/dist/esm/displayset/IDisplaySet.d.ts +9 -3
  4. package/dist/esm/displayset/ImageStackDisplaySet.d.ts +1 -3
  5. package/dist/esm/displayset/ImageStackDisplaySet.js +0 -1
  6. package/dist/esm/displayset/__fixtures__/scenarioInstances.d.ts +12 -0
  7. package/dist/esm/displayset/__fixtures__/scenarioInstances.js +210 -0
  8. package/dist/esm/displayset/compileSplitRules.d.ts +3 -0
  9. package/dist/esm/displayset/compileSplitRules.js +197 -0
  10. package/dist/esm/displayset/compiledDisplaySetRules.d.ts +3 -0
  11. package/dist/esm/displayset/compiledDisplaySetRules.js +3 -0
  12. package/dist/esm/displayset/createDisplaySetFromGroup.js +54 -19
  13. package/dist/esm/displayset/displaySetContext.d.ts +150 -0
  14. package/dist/esm/displayset/displaySetContext.js +918 -0
  15. package/dist/esm/displayset/displaySetRules.d.ts +5 -0
  16. package/dist/esm/displayset/displaySetRules.js +142 -0
  17. package/dist/esm/displayset/displaySetRules.test.d.ts +1 -0
  18. package/dist/esm/displayset/displaySetRules.test.js +1306 -0
  19. package/dist/esm/displayset/displaySetRulesTypes.d.ts +34 -0
  20. package/dist/esm/displayset/displaySetRulesTypes.js +0 -0
  21. package/dist/esm/displayset/displayset.test.js +422 -130
  22. package/dist/esm/displayset/groupInstancesBySplitRules.d.ts +8 -2
  23. package/dist/esm/displayset/groupInstancesBySplitRules.js +174 -17
  24. package/dist/esm/displayset/index.d.ts +14 -4
  25. package/dist/esm/displayset/index.js +10 -3
  26. package/dist/esm/displayset/isEcgInstance.d.ts +2 -1
  27. package/dist/esm/displayset/isEcgInstance.js +4 -9
  28. package/dist/esm/displayset/isImageInstance.d.ts +2 -1
  29. package/dist/esm/displayset/isImageInstance.js +4 -44
  30. package/dist/esm/displayset/isReconstructableInstances.d.ts +2 -0
  31. package/dist/esm/displayset/isReconstructableInstances.js +91 -0
  32. package/dist/esm/displayset/isVideoInstance.d.ts +2 -1
  33. package/dist/esm/displayset/isVideoInstance.js +4 -30
  34. package/dist/esm/displayset/isWsiInstance.d.ts +2 -1
  35. package/dist/esm/displayset/isWsiInstance.js +4 -6
  36. package/dist/esm/displayset/metadataContext.d.ts +13 -0
  37. package/dist/esm/displayset/metadataContext.js +42 -0
  38. package/dist/esm/displayset/metadataContext.test.d.ts +1 -0
  39. package/dist/esm/displayset/metadataContext.test.js +62 -0
  40. package/dist/esm/displayset/scenarioFixtures.test.d.ts +1 -0
  41. package/dist/esm/displayset/scenarioFixtures.test.js +206 -0
  42. package/dist/esm/displayset/seriesContext.test.d.ts +1 -0
  43. package/dist/esm/displayset/seriesContext.test.js +238 -0
  44. package/dist/esm/displayset/seriesFunctions.d.ts +29 -0
  45. package/dist/esm/displayset/seriesFunctions.js +327 -0
  46. package/dist/esm/displayset/sopClassUidLists.d.ts +14 -0
  47. package/dist/esm/displayset/sopClassUidLists.js +100 -0
  48. package/dist/esm/displayset/sortInstances.d.ts +10 -0
  49. package/dist/esm/displayset/sortInstances.js +33 -0
  50. package/dist/esm/displayset/sortInstances.test.d.ts +1 -0
  51. package/dist/esm/displayset/sortInstances.test.js +56 -0
  52. package/dist/esm/displayset/splitImageIdsBySplitRules.d.ts +3 -3
  53. package/dist/esm/displayset/splitImageIdsBySplitRules.js +5 -5
  54. package/dist/esm/displayset/splitRuleSchema.d.ts +11 -0
  55. package/dist/esm/displayset/splitRuleSchema.js +168 -0
  56. package/dist/esm/displayset/splitRuleSet.d.ts +12 -0
  57. package/dist/esm/displayset/splitRuleSet.js +47 -0
  58. package/dist/esm/displayset/splitRuleSet.test.d.ts +1 -0
  59. package/dist/esm/displayset/splitRuleSet.test.js +119 -0
  60. package/dist/esm/displayset/types.d.ts +37 -4
  61. package/dist/esm/displayset/types.js +15 -0
  62. package/dist/esm/index.d.ts +4 -2
  63. package/dist/esm/index.js +2 -1
  64. package/dist/esm/safeFunctions/compile.d.ts +31 -0
  65. package/dist/esm/safeFunctions/compile.js +142 -0
  66. package/dist/esm/safeFunctions/compile.test.d.ts +1 -0
  67. package/dist/esm/safeFunctions/compile.test.js +82 -0
  68. package/dist/esm/safeFunctions/expression/compiler.d.ts +23 -0
  69. package/dist/esm/safeFunctions/expression/compiler.js +481 -0
  70. package/dist/esm/safeFunctions/expression/expression.test.d.ts +1 -0
  71. package/dist/esm/safeFunctions/expression/expression.test.js +325 -0
  72. package/dist/esm/safeFunctions/expression/index.d.ts +4 -0
  73. package/dist/esm/safeFunctions/expression/index.js +3 -0
  74. package/dist/esm/safeFunctions/expression/parser.d.ts +56 -0
  75. package/dist/esm/safeFunctions/expression/parser.js +248 -0
  76. package/dist/esm/safeFunctions/expression/tokenizer.d.ts +29 -0
  77. package/dist/esm/safeFunctions/expression/tokenizer.js +198 -0
  78. package/dist/esm/safeFunctions/index.d.ts +5 -0
  79. package/dist/esm/safeFunctions/index.js +4 -0
  80. package/dist/esm/safeFunctions/matchTests.d.ts +16 -0
  81. package/dist/esm/safeFunctions/matchTests.js +203 -0
  82. package/dist/esm/safeFunctions/schema.d.ts +72 -0
  83. package/dist/esm/safeFunctions/schema.js +361 -0
  84. package/dist/esm/safeFunctions/types.d.ts +47 -0
  85. package/dist/esm/safeFunctions/types.js +0 -0
  86. package/dist/esm/safeFunctions/values.d.ts +6 -0
  87. package/dist/esm/safeFunctions/values.js +71 -0
  88. package/dist/esm/utilities/Tags.d.ts +1 -0
  89. package/dist/esm/utilities/Tags.js +14 -2
  90. package/dist/esm/utilities/index.d.ts +1 -1
  91. package/dist/esm/utilities/index.js +1 -1
  92. package/dist/esm/utilities/toNumber.d.ts +1 -1
  93. package/dist/esm/utilities/toNumber.js +1 -1
  94. package/dist/esm/version.d.ts +1 -1
  95. package/dist/esm/version.js +1 -1
  96. package/package.json +2 -2
  97. package/dist/esm/displayset/defaultDisplaySetSplitRules.d.ts +0 -2
  98. package/dist/esm/displayset/defaultDisplaySetSplitRules.js +0 -93
  99. package/dist/esm/displayset/viewportTypes.d.ts +0 -4
  100. package/dist/esm/displayset/viewportTypes.js +0 -13
@@ -0,0 +1,5 @@
1
+ export function createDisplaySetSplitRules(rules?: DisplaySetRules, options?: CreateDisplaySetSplitRulesOptions): SplitRuleSet;
2
+ export const displaySetRules: DisplaySetRules;
3
+ export type DisplaySetRules = import("./displaySetRulesTypes.js").DisplaySetRules;
4
+ export type CreateDisplaySetSplitRulesOptions = import("./displaySetRulesTypes.js").CreateDisplaySetSplitRulesOptions;
5
+ export type SplitRuleSet = import("./types.js").SplitRuleSet;
@@ -0,0 +1,142 @@
1
+ import { compileDisplaySetSplitRules } from './compileSplitRules.js';
2
+ const VOLUME_MODALITIES = ['CT', 'MR', 'PT', 'NM'];
3
+ const CINE_MODALITIES = ['US', 'XA', 'RF', 'ES', 'XC'];
4
+ const VOLUME_MULTIFRAME_SOP_CLASSES = [
5
+ '1.2.840.10008.5.1.4.1.1.6.2',
6
+ '1.2.840.10008.5.1.4.1.1.13.1.1',
7
+ '1.2.840.10008.5.1.4.1.1.13.1.2',
8
+ ];
9
+ const quotedList = (values) => `[${values.map((v) => `'${v}'`).join(', ')}]`;
10
+ const SINGLE_IMAGE_MODALITIES = ['CR', 'DX', 'MG'];
11
+ const RENDERABLE_IMAGE = { isImage: true, Rows: { notNull: true } };
12
+ const REVISION_CHAIN = {
13
+ groupBy: ['SeriesInstanceUID', 'revisionChainUid'],
14
+ sortBy: ['isActiveRevision', 'InstanceNumber'],
15
+ attributes: { activeSopInstanceUid: 'revisionChainUid' },
16
+ };
17
+ const objectRule = (priority, kind, handler, description) => ({
18
+ priority,
19
+ description,
20
+ handler,
21
+ matches: { [kind]: true },
22
+ groupBy: ['SeriesInstanceUID'],
23
+ });
24
+ export const displaySetRules = {
25
+ video: {
26
+ priority: 1,
27
+ description: 'A video-only SOP class, or a video transfer syntax, or (with no known ' +
28
+ 'transfer syntax) a long multi-frame secondary capture. One display set ' +
29
+ 'per instance, shown on a video viewport.',
30
+ handler: 'video',
31
+ matches: { isVideo: true },
32
+ groupBy: ['SOPInstanceUID'],
33
+ },
34
+ ecg: {
35
+ priority: 2,
36
+ description: 'ECG / waveform SOP classes. One display set per instance, shown on a ' +
37
+ 'waveform viewport rather than an image viewport.',
38
+ handler: 'ecg',
39
+ matches: { isEcg: true },
40
+ groupBy: ['SOPInstanceUID'],
41
+ },
42
+ wholeslide: {
43
+ priority: 3,
44
+ description: 'VL Whole Slide Microscopy (or modality SM). All pyramid levels of the ' +
45
+ 'series form a single whole-slide display set.',
46
+ handler: 'wholeSlide',
47
+ matches: { isWsi: true },
48
+ groupBy: ['SeriesInstanceUID'],
49
+ },
50
+ singleImageModality: {
51
+ priority: 4,
52
+ description: 'CR / DX / MG, which acquire one image per instance. One display set ' +
53
+ 'per instance, so each view of a mammography series is its own display ' +
54
+ 'set.',
55
+ matches: { Modality: SINGLE_IMAGE_MODALITIES, isImage: true },
56
+ groupBy: ['SOPInstanceUID'],
57
+ },
58
+ multiFrame: {
59
+ priority: 5,
60
+ description: 'Multi-frame image instances, one display set per instance. A cine clip ' +
61
+ '(a slice location, or a US, XA, RF, ES or XC multi-frame that is not a ' +
62
+ 'volume) is flagged isClip. Another multi-frame instance, such as an ' +
63
+ 'enhanced CT, is not a clip.',
64
+ context: {
65
+ isCineClip: `SliceLocation != null || (Modality in ${quotedList(CINE_MODALITIES)}` +
66
+ ` && !(SOPClassUID in ${quotedList(VOLUME_MULTIFRAME_SOP_CLASSES)}))`,
67
+ },
68
+ matches: { isImage: true, isMultiFrame: true },
69
+ groupBy: ['SOPInstanceUID'],
70
+ attributes: {
71
+ isClip: 'isCineClip',
72
+ numImageFrames: { expression: 'Number(NumberOfFrames)' },
73
+ },
74
+ },
75
+ mixedDimensionalityBValue: {
76
+ priority: 6,
77
+ description: 'Diffusion MR that mixes 4D b-value frames with trailing frames that have ' +
78
+ 'none. The undefined-b-value frames are not part of the 4D set, so they ' +
79
+ 'split off - otherwise 4D rendering is applied to the 3D portion.',
80
+ context: {
81
+ isMixedBValue: 'series.instances.count(DiffusionBValue) > 0 && ' +
82
+ 'series.instances.count(DiffusionBValue) < series.instances.count()',
83
+ hasNoBValue: 'DiffusionBValue == null',
84
+ },
85
+ matches: { Modality: 'MR', isMixedBValue: true, ...RENDERABLE_IMAGE },
86
+ groupBy: ['SeriesInstanceUID', 'hasNoBValue'],
87
+ },
88
+ volume3d: {
89
+ priority: 7,
90
+ description: 'Multi-slice CT / MR / PT / NM, which reconstruct into a volume.',
91
+ matches: {
92
+ Modality: VOLUME_MODALITIES,
93
+ seriesInstanceCount: { greaterThan: 1 },
94
+ ...RENDERABLE_IMAGE,
95
+ },
96
+ groupBy: ['SeriesInstanceUID'],
97
+ },
98
+ defaultImageRule: {
99
+ priority: 8,
100
+ description: 'Fallback for any remaining image SOP class, also with no Rows in the ' +
101
+ 'metadata. Grouped one display set per series.',
102
+ matches: { isImage: true },
103
+ },
104
+ segmentation: objectRule(9, 'isSegmentation', 'segmentation', 'Segmentations (segmentationSopClassUids). One display set per series.'),
105
+ rtStructureSet: objectRule(10, 'isRtStructureSet', 'rtStructureSet', 'RT structure sets (rtStructureSetSopClassUids). One display set per series.'),
106
+ parametricMap: objectRule(11, 'isParametricMap', 'parametricMap', 'Parametric maps (parametricMapSopClassUids). One display set per series.'),
107
+ structuredReport: {
108
+ ...objectRule(12, 'isStructuredReport', 'structuredReport', 'Structured reports (structuredReportSopClassUids), also Comprehensive ' +
109
+ '3D SR. One display set per series. Manufacturer and ' +
110
+ 'ManufacturerModelName name the writer of the SR.'),
111
+ attributes: {
112
+ Manufacturer: 'Manufacturer',
113
+ ManufacturerModelName: 'ManufacturerModelName',
114
+ },
115
+ },
116
+ encapsulatedDocument: {
117
+ ...objectRule(13, 'isEncapsulatedDocument', 'encapsulatedDocument', 'Encapsulated documents (encapsulatedDocumentSopClassUids). One ' +
118
+ 'display set per revision chain (PredecessorDocumentsSequence) of ' +
119
+ 'the series; activeSopInstanceUid names the current revision.'),
120
+ ...REVISION_CHAIN,
121
+ },
122
+ bulkAnnotation: objectRule(14, 'isBulkAnnotation', 'bulkAnnotation', 'Microscopy bulk annotations (bulkAnnotationSopClassUids). One display ' +
123
+ 'set per series.'),
124
+ chart: {
125
+ ...objectRule(15, 'isChart', 'chart', 'Charts (chartSopClassUids, empty by default: a host adds its chart ' +
126
+ 'SOP class). One display set per revision chain of the series; ' +
127
+ 'activeSopInstanceUid names the current revision.'),
128
+ ...REVISION_CHAIN,
129
+ },
130
+ unsupported: {
131
+ priority: Number.MAX_SAFE_INTEGER,
132
+ description: 'Catch-all for objects that no other rule claims (presentation states, ' +
133
+ 'other non-image objects). Produces one display set for each series, ' +
134
+ 'marked isDisplayable: false, so the objects are surfaced rather than ' +
135
+ 'silently dropped. Runs last.',
136
+ handler: 'unsupported',
137
+ groupBy: ['SeriesInstanceUID'],
138
+ },
139
+ };
140
+ export function createDisplaySetSplitRules(rules = displaySetRules, options = {}) {
141
+ return compileDisplaySetSplitRules(rules, options);
142
+ }
@@ -0,0 +1 @@
1
+ export {};