-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dsr2html): generate TS wrapper (bindgen) for structured-report-t…
…o-html Generate typescript wrapper and add test cases for structured-report-to-html operation.
- Loading branch information
Showing
10 changed files
with
554 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,7 @@ | ||
interface StructuredReportToHtmlNodeResult { | ||
/** Output text file */ | ||
outputText: string | ||
|
||
} | ||
|
||
export default StructuredReportToHtmlNodeResult |
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,125 @@ | ||
interface StructuredReportToHtmlOptions { | ||
/** read file format only */ | ||
readFileOnly?: boolean | ||
|
||
/** read data set without file meta information */ | ||
readDataset?: boolean | ||
|
||
/** use TS recognition (default) */ | ||
readXferAuto?: boolean | ||
|
||
/** ignore TS specified in the file meta header */ | ||
readXferDetect?: boolean | ||
|
||
/** read with explicit VR little endian TS */ | ||
readXferLittle?: boolean | ||
|
||
/** read with explicit VR big endian TS */ | ||
readXferBig?: boolean | ||
|
||
/** read with implicit VR little endian TS */ | ||
readXferImplicit?: boolean | ||
|
||
/** show currently processed content item */ | ||
processingDetails?: boolean | ||
|
||
/** accept unknown/missing relationship type */ | ||
unknownRelationship?: boolean | ||
|
||
/** accept invalid content item value | ||
(e.g. violation of VR or VM definition) */ | ||
invalidItemValue?: boolean | ||
|
||
/** ignore relationship content constraints */ | ||
ignoreConstraints?: boolean | ||
|
||
/** do not abort on content item errors, just warn | ||
(e.g. missing value type specific attributes) */ | ||
ignoreItemErrors?: boolean | ||
|
||
/** skip invalid content items (incl. sub-tree) */ | ||
skipInvalidItems?: boolean | ||
|
||
/** disable check for VR-conformant string values */ | ||
disableVrChecker?: boolean | ||
|
||
/** require declaration of ext. charset (default) */ | ||
charsetRequire?: boolean | ||
|
||
/** [c]harset: string, assume charset c if no extended charset declared */ | ||
charsetAssume?: string | ||
|
||
/** check all data elements with string values | ||
(default: only PN, LO, LT, SH, ST, UC and UT) */ | ||
charsetCheckAll?: boolean | ||
|
||
/** convert all element values that are affected | ||
by Specific Character Set (0008,0005) to UTF-8 */ | ||
convertToUtf8?: boolean | ||
|
||
/** use only HTML version 3.2 compatible features */ | ||
html32?: boolean | ||
|
||
/** allow all HTML version 4.01 features (default) */ | ||
html40?: boolean | ||
|
||
/** comply with XHTML version 1.1 specification */ | ||
xhtml11?: boolean | ||
|
||
/** add reference to SGML document type definition */ | ||
addDocumentType?: boolean | ||
|
||
/** URL: string. Add reference to specified CSS to document */ | ||
cssReference?: string | ||
|
||
/** [f]ilename: string. Embed content of specified CSS into document */ | ||
cssFile?: string | ||
|
||
/** expand short content items inline (default) */ | ||
expandInline?: boolean | ||
|
||
/** never expand content items inline */ | ||
neverExpandInline?: boolean | ||
|
||
/** always expand content items inline */ | ||
alwaysExpandInline?: boolean | ||
|
||
/** render full data of content items */ | ||
renderFullData?: boolean | ||
|
||
/** render section titles inline, not separately */ | ||
sectionTitleInline?: boolean | ||
|
||
/** use document type as document title (default) */ | ||
documentTypeTitle?: boolean | ||
|
||
/** use patient information as document title */ | ||
patientInfoTitle?: boolean | ||
|
||
/** do not render general document information */ | ||
noDocumentHeader?: boolean | ||
|
||
/** render codes in continuous text blocks */ | ||
renderInlineCodes?: boolean | ||
|
||
/** render code of concept names */ | ||
conceptNameCodes?: boolean | ||
|
||
/** render code of numeric measurement units */ | ||
numericUnitCodes?: boolean | ||
|
||
/** use code value as measurement unit (default) */ | ||
codeValueUnit?: boolean | ||
|
||
/** use code meaning as measurement unit */ | ||
codeMeaningUnit?: boolean | ||
|
||
/** render all codes (implies +Ci, +Cn and +Cu) */ | ||
renderAllCodes?: boolean | ||
|
||
/** render code details as a tooltip (implies +Cc) */ | ||
codeDetailsTooltip?: boolean | ||
|
||
} | ||
|
||
export default StructuredReportToHtmlOptions |
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,10 @@ | ||
interface StructuredReportToHtmlResult { | ||
/** WebWorker used for computation */ | ||
webWorker: Worker | null | ||
|
||
/** Output text file */ | ||
outputText: string | ||
|
||
} | ||
|
||
export default StructuredReportToHtmlResult |
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
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,174 @@ | ||
import { | ||
TextStream, | ||
InterfaceTypes, | ||
runPipeline | ||
} from 'itk-wasm' | ||
|
||
import StructuredReportToHtmlOptions from './StructuredReportToHtmlOptions.js' | ||
import StructuredReportToHtmlResult from './StructuredReportToHtmlResult.js' | ||
|
||
/** | ||
* Render DICOM SR file and data set to HTML/XHTML | ||
* | ||
* @param {Uint8Array} dicomFile - Input DICOM file | ||
* | ||
* @returns {Promise<StructuredReportToHtmlResult>} - result object | ||
*/ | ||
async function structuredReportToHtml( | ||
webWorker: null | Worker, | ||
dicomFile: Uint8Array, | ||
options: StructuredReportToHtmlOptions = {}) | ||
: Promise<StructuredReportToHtmlResult> { | ||
|
||
const desiredOutputs = [ | ||
{ type: InterfaceTypes.TextStream }, | ||
] | ||
const inputs = [ | ||
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, | ||
] | ||
|
||
const args = [] | ||
// Inputs | ||
args.push('file0') | ||
// Outputs | ||
args.push('0') | ||
// Options | ||
args.push('--memory-io') | ||
if (options.readFileOnly) { | ||
args.push('--read-file-only') | ||
} | ||
if (options.readDataset) { | ||
args.push('--read-dataset') | ||
} | ||
if (options.readXferAuto) { | ||
args.push('--read-xfer-auto') | ||
} | ||
if (options.readXferDetect) { | ||
args.push('--read-xfer-detect') | ||
} | ||
if (options.readXferLittle) { | ||
args.push('--read-xfer-little') | ||
} | ||
if (options.readXferBig) { | ||
args.push('--read-xfer-big') | ||
} | ||
if (options.readXferImplicit) { | ||
args.push('--read-xfer-implicit') | ||
} | ||
if (options.processingDetails) { | ||
args.push('--processing-details') | ||
} | ||
if (options.unknownRelationship) { | ||
args.push('--unknown-relationship') | ||
} | ||
if (options.invalidItemValue) { | ||
args.push('--invalid-item-value') | ||
} | ||
if (options.ignoreConstraints) { | ||
args.push('--ignore-constraints') | ||
} | ||
if (options.ignoreItemErrors) { | ||
args.push('--ignore-item-errors') | ||
} | ||
if (options.skipInvalidItems) { | ||
args.push('--skip-invalid-items') | ||
} | ||
if (options.disableVrChecker) { | ||
args.push('--disable-vr-checker') | ||
} | ||
if (options.charsetRequire) { | ||
args.push('--charset-require') | ||
} | ||
if (options.charsetAssume) { | ||
args.push('--charset-assume', '1') | ||
} | ||
if (options.charsetCheckAll) { | ||
args.push('--charset-check-all') | ||
} | ||
if (options.convertToUtf8) { | ||
args.push('--convert-to-utf8') | ||
} | ||
if (options.html32) { | ||
args.push('--html-3.2') | ||
} | ||
if (options.html40) { | ||
args.push('--html-4.0') | ||
} | ||
if (options.xhtml11) { | ||
args.push('--xhtml-1.1') | ||
} | ||
if (options.addDocumentType) { | ||
args.push('--add-document-type') | ||
} | ||
if (options.cssReference) { | ||
args.push('--css-reference', '2') | ||
} | ||
if (options.cssFile) { | ||
args.push('--css-file', '3') | ||
} | ||
if (options.expandInline) { | ||
args.push('--expand-inline') | ||
} | ||
if (options.neverExpandInline) { | ||
args.push('--never-expand-inline') | ||
} | ||
if (options.alwaysExpandInline) { | ||
args.push('--always-expand-inline') | ||
} | ||
if (options.renderFullData) { | ||
args.push('--render-full-data') | ||
} | ||
if (options.sectionTitleInline) { | ||
args.push('--section-title-inline') | ||
} | ||
if (options.documentTypeTitle) { | ||
args.push('--document-type-title') | ||
} | ||
if (options.patientInfoTitle) { | ||
args.push('--patient-info-title') | ||
} | ||
if (options.noDocumentHeader) { | ||
args.push('--no-document-header') | ||
} | ||
if (options.renderInlineCodes) { | ||
args.push('--render-inline-codes') | ||
} | ||
if (options.conceptNameCodes) { | ||
args.push('--concept-name-codes') | ||
} | ||
if (options.numericUnitCodes) { | ||
args.push('--numeric-unit-codes') | ||
} | ||
if (options.codeValueUnit) { | ||
args.push('--code-value-unit') | ||
} | ||
if (options.codeMeaningUnit) { | ||
args.push('--code-meaning-unit') | ||
} | ||
if (options.renderAllCodes) { | ||
args.push('--render-all-codes') | ||
} | ||
if (options.codeDetailsTooltip) { | ||
args.push('--code-details-tooltip') | ||
} | ||
|
||
const pipelinePath = 'structured-report-to-html' | ||
|
||
const { | ||
webWorker: usedWebWorker, | ||
returnValue, | ||
stderr, | ||
outputs | ||
} = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs) | ||
if (returnValue !== 0) { | ||
throw new Error(stderr) | ||
} | ||
|
||
const result = { | ||
webWorker: usedWebWorker as Worker, | ||
outputText: (outputs[0].data as TextStream).data, | ||
} | ||
return result | ||
} | ||
|
||
export default structuredReportToHtml |
Oops, something went wrong.