-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use dcm4che dcm2json instead of dcmtk
- for more maintainable, we want to drop c++ v8 dcmtk dependency - just use java and javascript to reduce maintenance difficulty
- Loading branch information
1 parent
bb4616a
commit 89e385b
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
const path = require("path"); | ||
const { importClassAsync } = require("java-bridge"); | ||
const { JsonGenerator } = require("@java-wrapper/javax/json/stream/JsonGenerator"); | ||
const { JSONWriter } = require("@dcm4che/json/JSONWriter"); | ||
const { DicomInputStream } = require("@dcm4che/io/DicomInputStream"); | ||
const { File } = require("@java-wrapper/java/io/File"); | ||
const { Json } = require("@java-wrapper/javax/json/Json"); | ||
const { Common } = require("@java-wrapper/org/github/chinlinlee/dcm777/common/Common"); | ||
const { DicomInputStream$IncludeBulkData } = require("@dcm4che/io/DicomInputStream$IncludeBulkData"); | ||
const { BasicBulkDataDescriptor } = require("@dcm4che/io/BasicBulkDataDescriptor"); | ||
|
||
|
||
class JDcm2Json { | ||
|
||
/** | ||
* | ||
* @param {string} filename | ||
*/ | ||
static async get(filename) { | ||
let jFile = new File(filename); | ||
let dicomInputStream = new DicomInputStream(jFile); | ||
await dicomInputStream.setIncludeBulkData(DicomInputStream$IncludeBulkData.NO); | ||
await dicomInputStream.setBulkDataDescriptor(new BasicBulkDataDescriptor()); | ||
|
||
let JByteArrayOutputStream = await importClassAsync("java.io.ByteArrayOutputStream"); | ||
let byteArrayOutputStream = new JByteArrayOutputStream(); | ||
|
||
let jsonGeneratorFactory = await Json.createGeneratorFactory( | ||
await Common.jsonGeneratorFactoryConfig(false) | ||
); | ||
let jsonGenerator = await jsonGeneratorFactory.createGenerator(byteArrayOutputStream); | ||
let jsonWriter = new JSONWriter(jsonGenerator); | ||
|
||
await dicomInputStream.setDicomInputHandler(jsonWriter); | ||
await dicomInputStream.readDataset(); | ||
await jsonGenerator.flush(); | ||
|
||
let jsonStr = await byteArrayOutputStream.toString("UTF-8"); | ||
await dicomInputStream.close(); | ||
return JSON.parse(jsonStr); | ||
} | ||
} | ||
|
||
module.exports.JDcm2Json = JDcm2Json; |
Binary file modified
BIN
+264 Bytes
(100%)
models/DICOM/dcm4che/javaNode/dcm4chee/lib/qrscp/dcm777-5.29.2.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters