0.1.3 • Published 2 years ago

dicomedit v0.1.3

Weekly downloads
108
License
MIT
Repository
github
Last release
2 years ago

DicomEdit.js

DicomEdit.js is a JavaScript library that provides the ability to read DICOM objects, transform their contents based on a scripted list of commands, and to output the transformed DICOM.

DicomEdit.js is a ported version the original Java-based library (https://wiki.xnat.org/xnat-tools/dicomedit) to work with a web-browser and Node.Js environments. This can add more safety to data privacy by allowing DICOM objects to be anonymized in users's local environment before being transferred to Server to make sure any PHI is not sent to unsecure/secure network.

DicomEdit.js uses a parser library (either Antlr4 or Peg.js (https://github.com/pegjs)) to create a parser for the DicomEdit script. Using the parser, the incoming script is converted to the abstract syntax tree, and finally the AST is transformed into the Rule groups object. and each defined rule is sequentially applied to the DICOM object.

Demo

This is a sample React.Js based webapp that demonstrates how the DicomEdit.js library works: https://testanonymizer.web.app.

Install

DicomEdit.js is available from npm or unpkg.

npm install dicomedit
yarn add dicomedit
<script src="https://unpkg.com/dicomedit/dist/web/dicomedit.js"></script>

API Documentation

To be added

Usage

Browser or Electron with HTML

<script src="https://unpkg.com/dicomedit@0.0.9/dist/web/dicomedit.min.js"></script>
<script>
const script = `version "6.3"
temp := "chany"
(0008,0008) := "test"
(0010,0010) := temp
`;

(async () => {
    // Assuming that a variable named 'buffer' is declared and ArrayBuffer type of the dcm image is assigned to the variable. (Please refer to https://github.com/WoonchanCho/dicomedit/blob/master/examples/web-example.html for the ArrayBuffer assignment. )
    const { Anonymizer } = DicomEdit;
    const anonymizer = new Anonymizer(script);
    anonymizer.loadDcm(buffer)
    await anonymizer.applyRules();

    console.log(anonymizer.outputDict)
    buffer = anonymizer.write()
    console.log(buffer)
})();

</script>

Node.js with the CommonJS module system

const fs = require('fs');
const { Anonymizer } = require('dicomedit/dist/node/dicomedit.min');

const script = `version "6.3"
temp := "chany"
(0008,0008) := "test"
(0010,0010) := temp
`;

(async () => {
  try {
    const anonymizer = new Anonymizer(script);

    const inputFile = process.argv[2] || './sample.dcm';
    anonymizer.loadDcmUsingFileName(inputFile);
    await anonymizer.applyRules();

    const buffer = anonymizer.write();
    const outputFile = process.argv[3] || './anon.dcm';
    fs.writeFileSync(outputFile, new Uint8Array(buffer));
  } catch (err) {
    console.log(err);
  }
})();

License

MIT

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.0.33

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.2

3 years ago