Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions bin/dcmjs.js
Original file line number Diff line number Diff line change
@@ -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('<part10>', 'part 10 file')
program
.command("dump")
.description("Dump a dicom file")
.argument("<part10>", "part 10 file")
// .option('-s, --separator <char>', 'separator character', ',')
.action(async (fileName, _options) => {
const dicomDict = readDicom(fileName);
dumpDicom(dicomDict);
});

program.command('instance')
.description('Write the instance data')
.argument('<part10>', 'part 10 file')
.option('-p, --pretty', 'Pretty print')
program
.command("natural")
.description("Show the natural representation of a file")
.argument("<part10>", "part 10 file")
// .option('-s, --separator <char>', 'separator character', ',')
.action(async (fileName, _options) => {
const dicomDict = readDicom(fileName);
naturalDicom(dicomDict);
});

program
.command("instance")
.description("Write the instance data")
.argument("<part10>", "part 10 file")
.option("-p, --pretty", "Pretty print")
.action(async (fileName, options) => {
const dicomDict = readDicom(fileName);
instanceDicom(dicomDict, options);
})

});

program.parse();
program.parse();
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}\""
Expand Down
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down