@ohos-ports/dcmjs 0.52.0-beta.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/License.txt ADDED
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2017 Steve Pieper
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ <div align="center">
2
+ <h1>dcmjs</h1>
3
+ <p>JavaScript implementation of DICOM manipulation. This code is an outgrowth of several efforts to implement web applications for medical imaging. the package should also work fine on node.</p>
4
+ </div>
5
+
6
+ <hr />
7
+
8
+ [![CI](https://github.com/dcmjs-org/dcmjs/actions/workflows/publish-package.yml/badge.svg)](https://github.com/dcmjs-org/dcmjs/actions?query=workflow:publish-package)
9
+
10
+ **Note: this code is a work-in-progress**
11
+
12
+ This is a community effort so please help improve support for a wide range of DICOM data and use cases.
13
+
14
+ See [live examples here](https://master--dcmjs2.netlify.app/)
15
+
16
+ # Goals
17
+
18
+ _Overall the code should:_
19
+
20
+ - Support reading and writing of correct DICOM objects in JavaScript for browser or node environments
21
+ - Provide a programmer-friendly JavaScript environment for using and manipulating DICOM objects
22
+ - Include a set of useful demos to encourage correct usage of dcmjs and modern DICOM objects
23
+ - Encourage correct referencing of instances and composite context when creating derived objects
24
+ - Current target is modern web browsers, but a set of node-based utilities also makes sense someday
25
+
26
+ _Architectural goals include:_
27
+
28
+ - Use modern JavaScript programming methods (currently ES6) but avoid heavy frameworks
29
+ - Leverage modern DICOM standards but avoid legacy parts
30
+ - Support straightforward integration with multiple JavaScript deployment targets (browser, node, etc) and frameworks.
31
+
32
+ _Parts of DICOM that dcmjs *will* focus on:_
33
+
34
+ - Enhanced Multiframe Images
35
+ - Segmentation Objects
36
+ - Parametric Maps
37
+ - Structured Reports
38
+
39
+ _Parts of DICOM that dcmjs *will not* focus on:_
40
+
41
+ - DIMSE (legacy networking like C-STORE, C-FIND, C-MOVE, etc). See the [dcmjs-dimse](https://github.com/PantelisGeorgiadis/dcmjs-dimse) project for that.
42
+ - Physical Media (optical disks). See [this FAQ](https://www.dclunie.com/medical-image-faq/html/index.html) if you need to work with those.
43
+ - Image rendering. See [dcmjs-imaging](https://github.com/PantelisGeorgiadis/dcmjs-imaging) for this.
44
+ - Encapsulated transfer syntax transcoding. See [dcmjs-codecs](https://github.com/PantelisGeorgiadis/dcmjs-codecs) for this.
45
+ - 3D rendering. See [vtk.js](https://kitware.github.io/vtk-js/index.html).
46
+ - Radiology review application - see [OHIF](https://ohif.org).
47
+ - Deidentification and data organization - see [dcm-organize](https://github.com/bebbi/dcm-organize) for this.
48
+
49
+ # Usage
50
+
51
+ ## In Browser
52
+
53
+ ```html
54
+ <script type="text/javascript" src="https://unpkg.com/dcmjs"></script>
55
+ ```
56
+
57
+ ## In Node
58
+
59
+ Add **dcmjs** to your application (pnpm):
60
+
61
+ ```bash
62
+ pnpm add dcmjs # latest stable release
63
+ pnpm add dcmjs@dev # latest code merged to master
64
+ ```
65
+
66
+ The same versions can be installed with `npm install` or Yarn in **your** project; those clients are fine for consuming the published package. **Building this repository** is pnpm-only (see below).
67
+
68
+ ## For Developers
69
+
70
+ Building and testing this repository requires **[pnpm](https://pnpm.io/)** and **Node.js 22.13 or newer** (pnpm 11 and this repo’s tooling expect that baseline; Rollup’s dependency chain expects a modern `crypto` global). CI runs tests on Node 22 and 24, and runs the production Rollup build on Node 24. The pnpm version is pinned under `packageManager` in `package.json`. Enable [Corepack](https://nodejs.org/api/corepack.html) (`corepack enable`) and use pnpm for every install and script:
71
+
72
+ ```bash
73
+ corepack enable
74
+ git clone https://github.com/dcmjs-org/dcmjs
75
+ cd dcmjs
76
+ pnpm install
77
+ pnpm run build
78
+ pnpm test
79
+ ```
80
+
81
+ Other common tasks:
82
+
83
+ ```bash
84
+ pnpm run build:examples # Rollup build + copy bundles into examples/js
85
+ pnpm run lint # ESLint (writes fixes)
86
+ pnpm run format # Prettier (writes)
87
+ pnpm run format:check # Prettier (check only)
88
+ ```
89
+
90
+ **Yarn is no longer supported** for working in this repo: there is no `yarn.lock`, and installs, builds, and CI are aligned with `pnpm-lock.yaml` only. Use pnpm so dependency resolution matches lockfile and automation.
91
+
92
+ After changing dependencies in `package.json`, refresh the lockfile with `pnpm run install:update-lockfile` (or `pnpm install --no-frozen-lockfile`) before opening a PR.
93
+
94
+ ## For Maintainers and Contributors
95
+
96
+ Publish new version automatically from commit:
97
+
98
+ Use the following "Commit Message Format" when drafting commit messages. If you're merging a 3rd party's PR, you have the ability to override the supplied commit messages by doing a "Squash & Merge":
99
+
100
+ - [Commit Message Format](https://semantic-release.gitbook.io/semantic-release/#commit-message-format)
101
+
102
+ Note: Be wary of `BREAKING_CHANGE` in commit message descriptions, as this can force a major version bump.
103
+
104
+ Be sure to use lower case for the first letter of your semantic commit message, so use `fix` not `Fix` or `feat` not `Feat`, have a space after the : and make the PR github review title follow the SAME rules. It is the PR review title that determins the final commit message and will be used for semantic detection.
105
+
106
+ Note: a new package version will be published only if the commit comes from a PR.
107
+
108
+ ### Optional Tooling
109
+
110
+ It is advised to use the git-cz, i.e.:
111
+
112
+ - install git-cz
113
+
114
+ ```bash
115
+ pnpm add -g git-cz
116
+ # or: npm install -g git-cz
117
+ ```
118
+
119
+ - how to commit
120
+
121
+ ```
122
+ git-cz --non-interactive --type=fix --subject="commit message"
123
+ ```
124
+
125
+ More info at [git-cz](https://www.npmjs.com/package/git-cz).
126
+
127
+ ## DICOM Dictionary
128
+
129
+ The dcmjs library includes DICOM data dictionaries that map DICOM tags to their metadata (VR, VM, etc.). To optimize load performance, the library uses a pre-compiled "fast dictionary" format.
130
+
131
+ ### Dictionary Files
132
+
133
+ - **`src/dictionary.fast.js`** - Pre-compiled fast dictionary (used at runtime)
134
+ - **`generate/dictionary.mjs`** - Source dictionary generator
135
+ - **`src/privateDictionary.js`** - Private tag definitions
136
+
137
+ ### Updating the Dictionary
138
+
139
+ When DICOM standards are updated or new tags need to be added:
140
+
141
+ 1. **Generate the dictionary from DICOM standards** (downloads latest PS3.6 and PS3.7 XML from dicom.nema.org):
142
+ ```bash
143
+ pnpm run generate-dictionary
144
+ ```
145
+ This creates/updates `generate/dictionary.js` with the latest tag definitions.
146
+
147
+ 2. **Pack the dictionary into optimized format**:
148
+ ```bash
149
+ pnpm run pack-dictionary
150
+ ```
151
+ This generates the optimized `src/dictionary.fast.js` used at runtime.
152
+
153
+ ### Why the Fast Dictionary?
154
+
155
+ The fast dictionary was introduced to significantly improve library load performance. The original dictionary format required complex runtime processing during module initialization, which added substantial overhead, especially in applications that frequently import dcmjs.
156
+
157
+ **Performance Benchmark Results (Bun):**
158
+
159
+ ```
160
+ Old dictionary (generate/dictionary.mjs): 181.16 ms
161
+ New dictionary (src/dictionary.fast.js): 19.04 ms
162
+ Performance improvement: 9.52x faster
163
+
164
+ ESM main (dcmjs.es.js): 112.01 ms
165
+ ESM private (loadPrivateTags): 0.01 ms
166
+ ESM total: 112.01 ms
167
+
168
+ UMD (dcmjs.js): 72.11 ms
169
+ ```
170
+
171
+ The fast dictionary reduces initial load time by over 9x, making it especially beneficial for:
172
+ - Server-side applications that spawn multiple workers
173
+ - Build tools and bundlers
174
+ - Applications with frequent module reloading during development
175
+ - Environments where startup time is critical
176
+
177
+ ## Community Participation
178
+
179
+ Use this repository's issues page to report any bugs. Please follow [SSCCE](http://sscce.org/) guidelines when submitting issues.
180
+
181
+ Use github pull requests to make contributions.
182
+
183
+ ## Unit Tests
184
+
185
+ Tests are written using the [Jest](https://jestjs.io) testing framework and live in the `test/` folder. Test file names must end with `.test.js`.
186
+
187
+ Pull requests should either update existing tests or add new tests in order to ensure good test coverage of the changes being made.
188
+
189
+ To run all tests use `pnpm test`. To only run specific tests use Jest's [`.only`](https://www.testim.io/blog/unit-testing-best-practices/) feature. If you're using VS Code, an extension such as [`firsttris.vscode-jest-runner`](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) can be used to step through specific tests in the debugger.
190
+
191
+ Read all about unit testing best practices [here](https://www.testim.io/blog/unit-testing-best-practices/).
192
+
193
+ # Status
194
+
195
+ Currently dcmjs is an early-stage development experiment, but already has valuable functionality.
196
+
197
+ ## Implemented
198
+
199
+ - Bidirectional conversion to and from part 10 binary DICOM and DICOM standard JSON encoding (as in [DICOMweb](http://dicomweb.org))
200
+ - Bidirectional convertion to and from DICOM standard JSON and a programmer-friendly high-level version (high-level form is called the "naturalized" form in the code).
201
+
202
+ ## In development
203
+
204
+ - Creation of (correct) enhanced multiframe DICOM objects from legacy image objects
205
+ - Creation of (correct) derived DICOM objects such as Segmentations and Structured Reports
206
+
207
+ ## TODO
208
+
209
+ - Create a test suite of input and output DICOM objects
210
+ - Test interoperability with other DICOM implementations
211
+ - Add documentation
212
+
213
+ # History
214
+
215
+ - 2014
216
+ - [DCMTK](dcmtk.org) cross compiled to javascript at [CTK Hackfest](http://www.commontk.org/index.php/CTK-Hackfest-May-2014). While this was useful and powerful, it was heavyweight for typical web usage.
217
+ - 2016
218
+ - A [Medical Imaging Web Appliction meeting at Stanford](http://qiicr.org/web/outreach/Medical-Imaging-Web-Apps/) and [follow-on hackfest in Boston](http://qiicr.org/web/outreach/MIWS-hackfest/) helped elaborate the needs for manipulating DICOM in pure Javascript.
219
+ - Based on [DICOM Part 10 read/write code](https://github.com/OHIF/dicom-dimse) initiated by Weiwei Wu of [OHIF](http://ohif.org), Steve Pieper [developed further features](https://github.com/pieper/sites/tree/gh-pages/dcmio) and [examples of creating multiframe and segmentation objects](https://github.com/pieper/sites/tree/gh-pages/DICOMzero) discussed with the community at RSNA
220
+ - 2017
221
+ - At [NA-MIC Project Week 25](https://na-mic.org/wiki/Project_Week_25) Erik Ziegler and Steve Pieper [worked](https://na-mic.org/wiki/Project_Week_25/DICOM_Segmentation_Support_for_Cornerstone_and_OHIF_Viewer)
222
+ with the community to define some example use cases to mix the pure JavaScript DICOM code with Cornerstone and [CornerstoneTools](https://github.com/chafey/cornerstoneTools).
223
+ - 2018-2022
224
+ - Work continues to develop SR and SEG support to [OHIFViewer](http://ohif.org) allow interoperability with [DICOM4QI](https://legacy.gitbook.com/book/qiicr/dicom4qi/details)
225
+ - 2022-present
226
+ - dcmjs is used by a number of projects and as of January 2025 has about 15,000 weekly [downloads from npm]([url](https://www.npmjs.com/package/dcmjs)).
227
+
228
+ # Support
229
+
230
+ The developers gratefully acknowledge their research support:
231
+
232
+ - Open Health Imaging Foundation ([OHIF](http://ohif.org))
233
+ - Quantitative Image Informatics for Cancer Research ([QIICR](http://qiicr.org))
234
+ - [Radiomics](http://radiomics.io)
235
+ - The [Neuroimage Analysis Center](http://nac.spl.harvard.edu)
236
+ - The [National Center for Image Guided Therapy](http://ncigt.org)
237
+ - The [NCI Imaging Data Commons](https://imagingdatacommons.github.io/) NCI Imaging Data Commons: contract number 19X037Q from Leidos Biomedical Research under Task Order HHSN26100071 from NCI
238
+ - dcmjs is being used and partially supported by [dicom-curate](https://github.com/bebbi/dicom-curate)
239
+
240
+ ## Logging
241
+
242
+ This library uses [loglevel](https://github.com/pimterry/loglevel) for logging. By default, the log level is set to "warn". You can change the log level by setting the `LOG_LEVEL` environment variable or by using the `setLevel` method in your code.