@cornerstonejs/adapters 0.1.2 → 0.1.4

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 (39) hide show
  1. package/package.json +14 -5
  2. package/src/adapters/Cornerstone/Angle.js +92 -0
  3. package/src/adapters/Cornerstone/ArrowAnnotate.js +106 -0
  4. package/src/adapters/Cornerstone/Bidirectional.js +187 -0
  5. package/src/adapters/Cornerstone/CircleRoi.js +109 -0
  6. package/src/adapters/Cornerstone/CobbAngle.js +96 -0
  7. package/src/adapters/Cornerstone/EllipticalRoi.js +149 -0
  8. package/src/adapters/Cornerstone/FreehandRoi.js +82 -0
  9. package/src/adapters/Cornerstone/Length.js +80 -0
  10. package/src/adapters/Cornerstone/MeasurementReport.js +352 -0
  11. package/src/adapters/Cornerstone/RectangleRoi.js +92 -0
  12. package/src/adapters/Cornerstone/Segmentation.js +118 -0
  13. package/src/adapters/Cornerstone/Segmentation_3X.js +632 -0
  14. package/src/adapters/Cornerstone/Segmentation_4X.js +1543 -0
  15. package/src/adapters/Cornerstone/cornerstone4Tag.js +1 -0
  16. package/src/adapters/Cornerstone/index.js +27 -0
  17. package/src/adapters/Cornerstone3D/ArrowAnnotate.js +155 -0
  18. package/src/adapters/Cornerstone3D/Bidirectional.js +196 -0
  19. package/src/adapters/Cornerstone3D/CodingScheme.js +16 -0
  20. package/src/adapters/Cornerstone3D/EllipticalROI.js +204 -0
  21. package/src/adapters/Cornerstone3D/Length.js +113 -0
  22. package/src/adapters/Cornerstone3D/MeasurementReport.js +445 -0
  23. package/src/adapters/Cornerstone3D/PlanarFreehandROI.js +137 -0
  24. package/src/adapters/Cornerstone3D/Probe.js +106 -0
  25. package/src/adapters/Cornerstone3D/cornerstone3DTag.js +1 -0
  26. package/src/adapters/Cornerstone3D/index.js +24 -0
  27. package/src/adapters/VTKjs/Segmentation.js +223 -0
  28. package/src/adapters/VTKjs/index.js +7 -0
  29. package/src/adapters/helpers.js +19 -0
  30. package/src/adapters/index.js +11 -0
  31. package/src/index.js +4 -0
  32. package/.babelrc +0 -9
  33. package/.eslintrc.json +0 -18
  34. package/.prettierrc +0 -5
  35. package/CHANGELOG.md +0 -106
  36. package/generate-dictionary.js +0 -145
  37. package/netlify.toml +0 -20
  38. package/rollup.config.js +0 -37
  39. package/test/adapters.test.js +0 -1
@@ -1,145 +0,0 @@
1
- /**
2
- * Create the dictionary.js DICOM dictionary file from the Standard.
3
- * Reformat The DICOM dictionary PS3.6 and PS3.7 docbook XML files (from e.g. standard docs) to JavaScript syntax.
4
- * Based on https://github.com/pydicom/pydicom/blob/8112bb69bfc0423c3a08cb89e7960defbe7237bf/source/generate_dict/generate_dicom_dict.py
5
- */
6
- const fs = require('fs/promises');
7
- const http = require('http');
8
- const xml2js = require('xml2js');
9
-
10
- require('@babel/register');
11
- const DICTIONARY_PATH = './src/dictionary.js';
12
- const dictionary = require(DICTIONARY_PATH).default;
13
- const { Tag } = require('./src/Tag');
14
-
15
- async function main() {
16
- const tags = [];
17
-
18
- /**
19
- * Collect DICOM tags from XML documents
20
- */
21
- const part06 = await getDocbook('part06/part06.xml');
22
- const part06Rows = part06.book.chapter.find(chapter => chapter.$['xml:id'] === 'chapter_6').table[0].tbody[0].tr;
23
- tags.push(...part06Rows.map(row => {
24
- const retired = getCellData(row.td[5])?.startsWith('RET');
25
- const name = getCellData(row.td[2]);
26
- return {
27
- tag: getCellData(row.td[0]),
28
- vr: getCellData(row.td[3]),
29
- name: retired ? `RETIRED_${name}` : name,
30
- vm: getCellData(row.td[4]),
31
- version: retired ? 'DICOM/retired' : 'DICOM',
32
- }
33
- }));
34
-
35
- const part07 = await getDocbook('part07/part07.xml');
36
- const chapterE = part07.book.chapter.find(chapter => chapter.$['xml:id'] === 'chapter_E');
37
- const commandFields = chapterE.section[0].table[0].tbody[0].tr;
38
- tags.push(...commandFields.map(row => {
39
- return {
40
- tag: getCellData(row.td[0]),
41
- vr: getCellData(row.td[3]),
42
- name: getCellData(row.td[2]),
43
- vm: getCellData(row.td[4]),
44
- version: 'DICOM',
45
- }
46
- }));
47
- const retiredCommandFields = chapterE.section[1].table[0].tbody[0].tr;
48
- tags.push(...retiredCommandFields.map(row => {
49
- return {
50
- tag: getCellData(row.td[0]),
51
- vr: getCellData(row.td[3]),
52
- name: `RETIRED_${getCellData(row.td[2])}`,
53
- vm: getCellData(row.td[4]),
54
- version: 'DICOM/retired',
55
- }
56
- }));
57
-
58
- const newTags = tags.filter(tag => tag.vr && tag.name && tag.vm)
59
- .filter(tag => !(tag.tag in dictionary)) // filter already defined
60
- .filter(tag => !/[(,\dA-F]x+[A-F\d,)]/.test(tag.tag)); // filter repeater tags
61
-
62
- /**
63
- * Insert new tags into dictionary, ordered among tags with the same version
64
- */
65
- const dictionaryArray = Object.values(dictionary);
66
- for (const newTag of newTags) {
67
- const parsedTag = Tag.fromPString(newTag.tag);
68
- const insertIndex = dictionaryArray.findIndex(tag => {
69
- if (tag.version !== newTag.version) {
70
- return false;
71
- }
72
- const thisTag = Tag.fromPString(tag.tag);
73
- return thisTag.toCleanString() > parsedTag.toCleanString();
74
- });
75
- dictionaryArray.splice(insertIndex, 0, newTag);
76
- }
77
-
78
- await writeDictionary(dictionaryArray);
79
- }
80
-
81
- async function writeDictionary(tags) {
82
- let data = 'const dictionary = {';
83
- for (const tag of tags) {
84
- if (!tag.tag) {
85
- data += `
86
- "": {
87
- tag: ""
88
- },`
89
- continue;
90
- }
91
- const tagKey = tag.tag.includes('"') ? `'${tag.tag}'` : `"${tag.tag}"`;
92
- data += `
93
- ${tagKey}: {
94
- tag: ${tagKey},
95
- vr: "${tag.vr}",
96
- name: "${tag.name}",
97
- vm: "${tag.vm}",
98
- version: "${tag.version ?? 'PrivateTag'}"
99
- },`;
100
- }
101
- data += `
102
- };
103
-
104
- export default dictionary;
105
- `;
106
-
107
- await fs.writeFile(DICTIONARY_PATH, data);
108
- }
109
-
110
- async function getDocbook(part) {
111
- const source = await getUrl(`http://dicom.nema.org/medical/dicom/current/source/docbook/${part}`);
112
- return xml2js.parseStringPromise(source);
113
- }
114
-
115
- function getCellData(td) {
116
- const para = td.para?.[0];
117
- if (!para) {
118
- return undefined;
119
- }
120
- const text = para.emphasis ? para.emphasis[0]._ : para._;
121
- return text?.trim().replace(/[\u200b\uffff]/g, '');
122
- }
123
-
124
- function getUrl(url) {
125
- return new Promise((resolve, reject) => {
126
- http.get(url, request => {
127
- let data = '';
128
- request.on('error', () => {
129
- reject(error);
130
- });
131
- request.on('end', () => {
132
- resolve(data);
133
- });
134
- request.on('data', chunk => {
135
- data += chunk;
136
- });
137
- });
138
- });
139
- }
140
-
141
- if (require.main === module) {
142
- main().catch(error => {
143
- console.log(error);
144
- });
145
- }
package/netlify.toml DELETED
@@ -1,20 +0,0 @@
1
- # Netlify Config
2
- #
3
- # TOML Reference:
4
- # https://www.netlify.com/docs/netlify-toml-reference/
5
-
6
- # Settings in the [build] context are global and are applied to all contexts
7
- # unless otherwise overridden by more specific contexts.
8
- [build]
9
- # Directory to change to before starting a build.
10
- # This is where we will look for package.json/.nvmrc/etc.
11
- base = ""
12
- publish = "examples/"
13
- command = "npm run build:examples"
14
-
15
- # Deploy Preview context: all deploys generated from a pull/merge request will
16
- # inherit these settings.
17
- [context.deploy-preview]
18
- base = ""
19
- publish = "examples/"
20
- command = "npm run build:examples"
package/rollup.config.js DELETED
@@ -1,37 +0,0 @@
1
- import babel from "rollup-plugin-babel";
2
- import resolve from "rollup-plugin-node-resolve";
3
- import globals from "rollup-plugin-node-globals";
4
- import builtins from "rollup-plugin-node-builtins";
5
- import commonjs from "rollup-plugin-commonjs";
6
- import json from "rollup-plugin-json";
7
- import pkg from "./package.json";
8
-
9
- export default {
10
- input: pkg.src,
11
- output: [
12
- {
13
- file: pkg.main,
14
- format: "umd",
15
- name: pkg.name,
16
- sourcemap: true
17
- },
18
- {
19
- file: pkg.module,
20
- format: "es",
21
- sourcemap: true
22
- }
23
- ],
24
- plugins: [
25
- resolve({
26
- browser: true
27
- }),
28
- commonjs(),
29
- globals(),
30
- builtins(),
31
- babel({
32
- runtimeHelpers: true,
33
- exclude: "node_modules/**"
34
- }),
35
- json()
36
- ]
37
- };
@@ -1 +0,0 @@
1
- it("No tests yet", () => {});