@niivue/nv-ext-dcm2niix 1.0.0-rc.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.
- package/README.md +69 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @niivue/nv-ext-dcm2niix
|
|
2
|
+
|
|
3
|
+
Browser-side DICOM-to-NIfTI conversion for [NiiVue](https://github.com/niivue), wrapping the [`@niivue/dcm2niix`](https://www.npmjs.com/package/@niivue/dcm2niix) WebAssembly build of Chris Rorden's [`dcm2niix`](https://github.com/rordenlab/dcm2niix). No data leaves the browser.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @niivue/nv-ext-dcm2niix
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires `@niivue/niivue` as a peer dependency.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Folder picker
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import NiiVueGPU from '@niivue/niivue'
|
|
19
|
+
import { runDcm2niix } from '@niivue/nv-ext-dcm2niix'
|
|
20
|
+
|
|
21
|
+
const nv = new NiiVueGPU()
|
|
22
|
+
await nv.attachTo('gl1')
|
|
23
|
+
|
|
24
|
+
const input = document.querySelector<HTMLInputElement>('#dicomFolder')!
|
|
25
|
+
input.addEventListener('change', async () => {
|
|
26
|
+
const niftiFiles = await runDcm2niix(input.files)
|
|
27
|
+
await nv.loadVolumes([{ url: niftiFiles[0] }])
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The input should declare `webkitdirectory` so the browser exposes folder structure:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<input id="dicomFolder" type="file" webkitdirectory multiple />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Drag-and-drop folders
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { runDcm2niix, traverseDataTransferItems } from '@niivue/nv-ext-dcm2niix'
|
|
41
|
+
|
|
42
|
+
dropTarget.addEventListener('drop', async (e) => {
|
|
43
|
+
e.preventDefault()
|
|
44
|
+
const files = await traverseDataTransferItems(e.dataTransfer!.items)
|
|
45
|
+
const niftiFiles = await runDcm2niix(files)
|
|
46
|
+
await nv.loadVolumes([{ url: niftiFiles[0] }])
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Power users
|
|
51
|
+
|
|
52
|
+
The underlying `Dcm2niix` class is re-exported for callers that need full control over dcm2niix command-line flags (compression level, BIDS sidecars, etc.):
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { Dcm2niix } from '@niivue/nv-ext-dcm2niix'
|
|
56
|
+
|
|
57
|
+
const dcm2niix = new Dcm2niix()
|
|
58
|
+
await dcm2niix.init()
|
|
59
|
+
const result = await dcm2niix.input(files).compressionLevel(9).bids('n').run()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
bunx nx build nv-ext-dcm2niix
|
|
66
|
+
bunx nx typecheck nv-ext-dcm2niix
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Part of the [NiiVue](https://github.com/niivue) ecosystem
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@niivue/nv-ext-dcm2niix",
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "DICOM-to-NIfTI conversion in the browser via the dcm2niix WASM build, packaged for NiiVue",
|
|
6
|
+
"main": "./dist/nv-ext-dcm2niix.js",
|
|
7
|
+
"module": "./dist/nv-ext-dcm2niix.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/nv-ext-dcm2niix.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@niivue/niivue": "1.0.0-rc.4"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@niivue/dcm2niix": "^1.2.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@niivue/niivue": "1.0.0-rc.4",
|
|
26
|
+
"typescript": "~5.8.3",
|
|
27
|
+
"vite": "^6.3.2",
|
|
28
|
+
"vite-plugin-dts": "^4.5.4"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "npx vite build",
|
|
32
|
+
"typecheck": "bunx tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|