diff --git a/bin/dcmjs.js b/bin/dcmjs.js index a55088f..98c62ef 100644 --- a/bin/dcmjs.js +++ b/bin/dcmjs.js @@ -1,31 +1,47 @@ #!/usr/bin/env node -import { Command } from 'commander'; -import { readDicom, instanceDicom, dumpDicom } from '../src/index.js'; +import { Command } from "commander"; +import { + readDicom, + instanceDicom, + dumpDicom, + naturalDicom, +} from "../src/index.js"; const program = new Command(); program - .name('dcmjs') - .description('dcmjs based tools for manipulation DICOM files') - .version('0.0.1') + .name("dcmjs") + .description("dcmjs based tools for manipulation DICOM files") + .version("0.0.1"); -program.command('dump') - .description('Dump a dicom file') - .argument('', 'part 10 file') +program + .command("dump") + .description("Dump a dicom file") + .argument("", "part 10 file") // .option('-s, --separator ', 'separator character', ',') .action(async (fileName, _options) => { const dicomDict = readDicom(fileName); dumpDicom(dicomDict); }); -program.command('instance') - .description('Write the instance data') - .argument('', 'part 10 file') - .option('-p, --pretty', 'Pretty print') +program + .command("natural") + .description("Show the natural representation of a file") + .argument("", "part 10 file") + // .option('-s, --separator ', 'separator character', ',') + .action(async (fileName, _options) => { + const dicomDict = readDicom(fileName); + naturalDicom(dicomDict); + }); + +program + .command("instance") + .description("Write the instance data") + .argument("", "part 10 file") + .option("-p, --pretty", "Pretty print") .action(async (fileName, options) => { const dicomDict = readDicom(fileName); instanceDicom(dicomDict, options); - }) - + }); -program.parse(); \ No newline at end of file +program.parse(); diff --git a/bun.lock b/bun.lock index a7fdba0..5e681ef 100644 --- a/bun.lock +++ b/bun.lock @@ -6,7 +6,7 @@ "dependencies": { "commander": "^12.1.0", "crypto": "^1.0.1", - "dcmjs": "^0.41.0", + "dcmjs": "^0.47.1", "dcmjs-dimse": "0.1.27", "dicomweb-client": "^0.11.2", "jsdom": "^26.1.0", @@ -323,7 +323,7 @@ "data-urls": ["data-urls@5.0.0", "", { "dependencies": { "whatwg-mimetype": "^4.0.0", "whatwg-url": "^14.0.0" } }, "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg=="], - "dcmjs": ["dcmjs@0.41.0", "", { "dependencies": { "@babel/runtime-corejs3": "^7.22.5", "adm-zip": "^0.5.10", "gl-matrix": "^3.1.0", "lodash.clonedeep": "^4.5.0", "loglevel": "^1.8.1", "ndarray": "^1.0.19", "pako": "^2.0.4" } }, "sha512-kr46REomItFeWz+0ck4Wif4uS5VVDWVlwdh5GGaCtTYHWfNQmrcCSiQOkrShc7Dc5zP8vNKrHEdORlZXenlg3w=="], + "dcmjs": ["dcmjs@0.47.1", "", { "dependencies": { "@babel/runtime-corejs3": "^7.22.5", "adm-zip": "^0.5.10", "gl-matrix": "^3.1.0", "lodash.clonedeep": "^4.5.0", "loglevel": "^1.8.1", "ndarray": "^1.0.19", "pako": "^2.0.4" } }, "sha512-ZpsF4c2+Gcdg2bNkDJY470EkaoHiOEfl6uH1uw2M88JUSrSf73gaNNMv1RuS+zKTw/695iDkueRyNU5OUsUanQ=="], "dcmjs-dimse": ["dcmjs-dimse@0.1.27", "", { "dependencies": { "async-eventemitter": "^0.2.4", "dcmjs": "^0.30.3", "smart-buffer": "^4.2.0", "ts-mixer": "^6.0.4", "winston": "^3.12.0" } }, "sha512-d5XXXXm/uwZAVVDNWgJDMSDa5MXZ5GLapv0zd4qBWTMMzD5ALES2l8t8P5qg6GV+5pfojmmnE/2idB7pZHo54g=="], diff --git a/package.json b/package.json index 6094f5c..3f9e984 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "dependencies": { "commander": "^12.1.0", "crypto": "^1.0.1", - "dcmjs": "^0.41.0", + "dcmjs": "^0.47.1", "dcmjs-dimse": "0.1.27", "dicomweb-client": "^0.11.2", "jsdom": "^26.1.0", @@ -84,6 +84,7 @@ "build": "bun build src/index.js --format esm --target node --outdir dist --", "clean": "rimraf dist", "dicomwebjs": "bun run build && bun run bin/dicomwebjs.js --", + "dcmjs": "bun run build && bun run bin/dcmjs.js --", "link:exec": "npm install -g && npm link", "lint": "npx eslint --color \"**/*.{js,mjs,cjs}\"", "lint:fix": "npx eslint --fix --color \"**/*.{js,mjs,cjs}\"" diff --git a/src/index.js b/src/index.js index a4275b2..d3ba3b9 100644 --- a/src/index.js +++ b/src/index.js @@ -22,6 +22,18 @@ export function dumpDicom(dicomDict, options = {}) { dumpData(dicomDict.dict, options); } +export function naturalDicom(dicomDict, options = {}) { + if (dicomDict.meta) { + console.log("Metadata"); + dumpData(dicomDict.meta, options); + } + console.log("Data"); + const natural = dcmjs.data.DicomMetaDictionary.naturalizeDataset( + dicomDict.dict + ); + console.log(JSON.stringify(natural, null, 2)); +} + export function dumpData(data, options, indent = "") { if (typeof data !== "object") { return;