diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 78f71194e..6775c9a87 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -14,6 +14,7 @@ guide](doc/content/docs/itk_js_to_itk_wasm_migration_guide.md). - apply-presentation-state-to-image presentation-state-file is an argument, as opposed to an optional parameter, since it is required. +- dicom functions access { data: , path: } arguments instead of just . ## From 1.0.0-b.72 to 1.0.0-b.73 diff --git a/packages/dicom/typescript/src/apply-presentation-state-to-image-node.ts b/packages/dicom/typescript/src/apply-presentation-state-to-image-node.ts index c8323bcef..e03d31387 100644 --- a/packages/dicom/typescript/src/apply-presentation-state-to-image-node.ts +++ b/packages/dicom/typescript/src/apply-presentation-state-to-image-node.ts @@ -1,6 +1,7 @@ // Generated file. Do not edit. import { + BinaryFile, JsonObject, Image, InterfaceTypes, @@ -18,14 +19,14 @@ import path from 'path' /** * Apply a presentation state to a given DICOM image and render output as pgm bitmap or dicom file. * - * @param {string} imageIn - Input DICOM file - * @param {string} presentationStateFile - Process using presentation state file + * @param {BinaryFile} imageIn - Input DICOM file + * @param {BinaryFile} presentationStateFile - Process using presentation state file * * @returns {Promise} - result object */ async function applyPresentationStateToImageNode( - imageIn: string, - presentationStateFile: string, + imageIn: BinaryFile, + presentationStateFile: BinaryFile, options: ApplyPresentationStateToImageOptions = {} ) : Promise { @@ -34,14 +35,14 @@ async function applyPresentationStateToImageNode( { type: InterfaceTypes.Image }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: imageIn, path: "file0" } }, - { type: InterfaceTypes.BinaryFile, data: { data: presentationStateFile, path: "file1" } }, + { type: InterfaceTypes.BinaryFile, data: imageIn }, + { type: InterfaceTypes.BinaryFile, data: presentationStateFile }, ] const args = [] // Inputs - args.push('file0') - args.push('file1') + args.push(imageIn.path) + args.push(presentationStateFile.path) // Outputs args.push('0') args.push('1') diff --git a/packages/dicom/typescript/src/apply-presentation-state-to-image.ts b/packages/dicom/typescript/src/apply-presentation-state-to-image.ts index 417102d3c..3eeb8e990 100644 --- a/packages/dicom/typescript/src/apply-presentation-state-to-image.ts +++ b/packages/dicom/typescript/src/apply-presentation-state-to-image.ts @@ -1,6 +1,7 @@ // Generated file. Do not edit. import { + BinaryFile, JsonObject, Image, InterfaceTypes, @@ -21,15 +22,15 @@ import { getPipelineWorkerUrl } from './pipeline-worker-url.js' /** * Apply a presentation state to a given DICOM image and render output as pgm bitmap or dicom file. * - * @param {string} imageIn - Input DICOM file - * @param {string} presentationStateFile - Process using presentation state file + * @param {BinaryFile} imageIn - Input DICOM file + * @param {BinaryFile} presentationStateFile - Process using presentation state file * * @returns {Promise} - result object */ async function applyPresentationStateToImage( webWorker: null | Worker, - imageIn: string, - presentationStateFile: string, + imageIn: BinaryFile, + presentationStateFile: BinaryFile, options: ApplyPresentationStateToImageOptions = {} ) : Promise { @@ -38,14 +39,14 @@ async function applyPresentationStateToImage( { type: InterfaceTypes.Image }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: imageIn, path: "file0" } }, - { type: InterfaceTypes.BinaryFile, data: { data: presentationStateFile, path: "file1" } }, + { type: InterfaceTypes.BinaryFile, data: imageIn }, + { type: InterfaceTypes.BinaryFile, data: presentationStateFile }, ] const args = [] // Inputs - args.push('file0') - args.push('file1') + args.push(imageIn.path) + args.push(presentationStateFile.path) // Outputs args.push('0') args.push('1') diff --git a/packages/dicom/typescript/src/read-dicom-encapsulated-pdf-node.ts b/packages/dicom/typescript/src/read-dicom-encapsulated-pdf-node.ts index b8b42a852..9276a4279 100644 --- a/packages/dicom/typescript/src/read-dicom-encapsulated-pdf-node.ts +++ b/packages/dicom/typescript/src/read-dicom-encapsulated-pdf-node.ts @@ -1,6 +1,7 @@ // Generated file. Do not edit. import { + BinaryFile, BinaryStream, InterfaceTypes, PipelineOutput, @@ -17,12 +18,12 @@ import path from 'path' /** * Extract PDF file from DICOM encapsulated PDF. * - * @param {string} dicomFile - Input DICOM file + * @param {BinaryFile} dicomFile - Input DICOM file * * @returns {Promise} - result object */ async function readDicomEncapsulatedPdfNode( - dicomFile: string, + dicomFile: BinaryFile, options: ReadDicomEncapsulatedPdfOptions = {} ) : Promise { @@ -30,12 +31,12 @@ async function readDicomEncapsulatedPdfNode( { type: InterfaceTypes.BinaryStream }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, + { type: InterfaceTypes.BinaryFile, data: dicomFile }, ] const args = [] // Inputs - args.push('file0') + args.push(dicomFile.path) // Outputs args.push('0') // Options diff --git a/packages/dicom/typescript/src/read-dicom-encapsulated-pdf.ts b/packages/dicom/typescript/src/read-dicom-encapsulated-pdf.ts index ad3349696..83741d8fd 100644 --- a/packages/dicom/typescript/src/read-dicom-encapsulated-pdf.ts +++ b/packages/dicom/typescript/src/read-dicom-encapsulated-pdf.ts @@ -1,6 +1,7 @@ // Generated file. Do not edit. import { + BinaryFile, BinaryStream, InterfaceTypes, PipelineOutput, @@ -20,13 +21,13 @@ import { getPipelineWorkerUrl } from './pipeline-worker-url.js' /** * Extract PDF file from DICOM encapsulated PDF. * - * @param {string} dicomFile - Input DICOM file + * @param {BinaryFile} dicomFile - Input DICOM file * * @returns {Promise} - result object */ async function readDicomEncapsulatedPdf( webWorker: null | Worker, - dicomFile: string, + dicomFile: BinaryFile, options: ReadDicomEncapsulatedPdfOptions = {} ) : Promise { @@ -34,12 +35,12 @@ async function readDicomEncapsulatedPdf( { type: InterfaceTypes.BinaryStream }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, + { type: InterfaceTypes.BinaryFile, data: dicomFile }, ] const args = [] // Inputs - args.push('file0') + args.push(dicomFile.path) // Outputs args.push('0') // Options diff --git a/packages/dicom/typescript/src/structured-report-to-html-node.ts b/packages/dicom/typescript/src/structured-report-to-html-node.ts index f971f831a..892b346b2 100644 --- a/packages/dicom/typescript/src/structured-report-to-html-node.ts +++ b/packages/dicom/typescript/src/structured-report-to-html-node.ts @@ -1,7 +1,9 @@ // Generated file. Do not edit. import { + BinaryFile, TextStream, + TextFile, InterfaceTypes, PipelineOutput, PipelineInput, @@ -17,12 +19,12 @@ import path from 'path' /** * Render DICOM SR file and data set to HTML/XHTML * - * @param {string} dicomFile - Input DICOM file + * @param {BinaryFile} dicomFile - Input DICOM file * * @returns {Promise} - result object */ async function structuredReportToHtmlNode( - dicomFile: string, + dicomFile: BinaryFile, options: StructuredReportToHtmlOptions = {} ) : Promise { @@ -30,12 +32,12 @@ async function structuredReportToHtmlNode( { type: InterfaceTypes.TextStream }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, + { type: InterfaceTypes.BinaryFile, data: dicomFile }, ] const args = [] // Inputs - args.push('file0') + args.push(dicomFile.path) // Outputs args.push('0') // Options @@ -115,9 +117,8 @@ async function structuredReportToHtmlNode( args.push('--css-reference', inputCountString) } if (typeof options.cssFile !== "undefined") { - const inputFile = 'file' + inputs.length.toString() - inputs.push({ type: InterfaceTypes.TextFile, data: { data: options.cssFile, path: inputFile } }) - args.push('--css-file', inputFile) + inputs.push({ type: InterfaceTypes.TextFile, data: options.cssFile as TextFile }) + args.push('--css-file', options.cssFile.path) } if (typeof options.expandInline !== "undefined") { args.push('--expand-inline') diff --git a/packages/dicom/typescript/src/structured-report-to-html-options.ts b/packages/dicom/typescript/src/structured-report-to-html-options.ts index 01420c4a6..5e337d062 100644 --- a/packages/dicom/typescript/src/structured-report-to-html-options.ts +++ b/packages/dicom/typescript/src/structured-report-to-html-options.ts @@ -1,3 +1,5 @@ +import { TextFile } from 'itk-wasm' + interface StructuredReportToHtmlOptions { /** read file format only */ readFileOnly?: boolean @@ -76,7 +78,7 @@ by Specific Character Set (0008,0005) to UTF-8 */ cssReference?: string /** [f]ilename: string. Embed content of specified CSS into document */ - cssFile?: string + cssFile?: TextFile /** expand short content items inline (default) */ expandInline?: boolean diff --git a/packages/dicom/typescript/src/structured-report-to-html.ts b/packages/dicom/typescript/src/structured-report-to-html.ts index ceb181e17..2e2794d62 100644 --- a/packages/dicom/typescript/src/structured-report-to-html.ts +++ b/packages/dicom/typescript/src/structured-report-to-html.ts @@ -1,7 +1,9 @@ // Generated file. Do not edit. import { + BinaryFile, TextStream, + TextFile, InterfaceTypes, PipelineOutput, PipelineInput, @@ -20,13 +22,13 @@ import { getPipelineWorkerUrl } from './pipeline-worker-url.js' /** * Render DICOM SR file and data set to HTML/XHTML * - * @param {string} dicomFile - Input DICOM file + * @param {BinaryFile} dicomFile - Input DICOM file * * @returns {Promise} - result object */ async function structuredReportToHtml( webWorker: null | Worker, - dicomFile: string, + dicomFile: BinaryFile, options: StructuredReportToHtmlOptions = {} ) : Promise { @@ -34,12 +36,12 @@ async function structuredReportToHtml( { type: InterfaceTypes.TextStream }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, + { type: InterfaceTypes.BinaryFile, data: dicomFile }, ] const args = [] // Inputs - args.push('file0') + args.push(dicomFile.path) // Outputs args.push('0') // Options @@ -119,9 +121,8 @@ async function structuredReportToHtml( args.push('--css-reference', inputCountString) } if (typeof options.cssFile !== "undefined") { - const inputFile = 'file' + inputs.length.toString() - inputs.push({ type: InterfaceTypes.TextFile, data: { data: options.cssFile, path: inputFile } }) - args.push('--css-file', inputFile) + inputs.push({ type: InterfaceTypes.TextFile, data: options.cssFile as TextFile }) + args.push('--css-file', options.cssFile.path) } if (typeof options.expandInline !== "undefined") { args.push('--expand-inline') diff --git a/packages/dicom/typescript/src/structured-report-to-text-node.ts b/packages/dicom/typescript/src/structured-report-to-text-node.ts index 65f0b73b7..6e7edea6a 100644 --- a/packages/dicom/typescript/src/structured-report-to-text-node.ts +++ b/packages/dicom/typescript/src/structured-report-to-text-node.ts @@ -1,6 +1,7 @@ // Generated file. Do not edit. import { + BinaryFile, TextStream, InterfaceTypes, PipelineOutput, @@ -17,12 +18,12 @@ import path from 'path' /** * Read a DICOM structured report file and generate a plain text representation * - * @param {string} dicomFile - Input DICOM file + * @param {BinaryFile} dicomFile - Input DICOM file * * @returns {Promise} - result object */ async function structuredReportToTextNode( - dicomFile: string, + dicomFile: BinaryFile, options: StructuredReportToTextOptions = {} ) : Promise { @@ -30,12 +31,12 @@ async function structuredReportToTextNode( { type: InterfaceTypes.TextStream }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, + { type: InterfaceTypes.BinaryFile, data: dicomFile }, ] const args = [] // Inputs - args.push('file0') + args.push(dicomFile.path) // Outputs args.push('0') // Options diff --git a/packages/dicom/typescript/src/structured-report-to-text.ts b/packages/dicom/typescript/src/structured-report-to-text.ts index d65a562a6..41eeccdf4 100644 --- a/packages/dicom/typescript/src/structured-report-to-text.ts +++ b/packages/dicom/typescript/src/structured-report-to-text.ts @@ -1,6 +1,7 @@ // Generated file. Do not edit. import { + BinaryFile, TextStream, InterfaceTypes, PipelineOutput, @@ -20,13 +21,13 @@ import { getPipelineWorkerUrl } from './pipeline-worker-url.js' /** * Read a DICOM structured report file and generate a plain text representation * - * @param {string} dicomFile - Input DICOM file + * @param {BinaryFile} dicomFile - Input DICOM file * * @returns {Promise} - result object */ async function structuredReportToText( webWorker: null | Worker, - dicomFile: string, + dicomFile: BinaryFile, options: StructuredReportToTextOptions = {} ) : Promise { @@ -34,12 +35,12 @@ async function structuredReportToText( { type: InterfaceTypes.TextStream }, ] const inputs: Array = [ - { type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } }, + { type: InterfaceTypes.BinaryFile, data: dicomFile }, ] const args = [] // Inputs - args.push('file0') + args.push(dicomFile.path) // Outputs args.push('0') // Options diff --git a/packages/dicom/typescript/test/node.js b/packages/dicom/typescript/test/node.js index 1e4facf32..c9d9c73c2 100644 --- a/packages/dicom/typescript/test/node.js +++ b/packages/dicom/typescript/test/node.js @@ -19,11 +19,11 @@ test('structuredReportToText', async t => { const dicomFileBuffer = fs.readFileSync(testFilePath) const dicomFile = new Uint8Array(dicomFileBuffer) - const { outputText } = await structuredReportToTextNode(dicomFile) + const { outputText } = await structuredReportToTextNode({ data: dicomFile, path: fileName }) t.assert(outputText.includes('Comprehensive SR Document')) - const { outputText: outputTextNoHeader } = await structuredReportToTextNode(dicomFile, { noDocumentHeader: true }) + const { outputText: outputTextNoHeader } = await structuredReportToTextNode({ data: dicomFile, path: fileName }, { noDocumentHeader: true }) t.assert(!outputTextNoHeader.includes('Comprehensive SR Document')) t.assert(outputTextNoHeader.includes('Breast Imaging Report')) }) @@ -35,19 +35,20 @@ test('structuredReportToHtml', async t => { const dicomFileBuffer = fs.readFileSync(testFilePath) const dicomFile = new Uint8Array(dicomFileBuffer) + const dicomBinaryFile = { data: dicomFile, path: fileName } - const { outputText } = await structuredReportToHtmlNode(dicomFile) + const { outputText } = await structuredReportToHtmlNode(dicomBinaryFile) t.assert(outputText.includes('Comprehensive SR Document')) t.assert(outputText.includes('Breast Diagnosis 010001 (female, #BreastDx-01-0001)')) t.assert(outputText.includes('PixelMed (XSLT from di3data csv extract)')) - const { outputText: outputTextNoHeader } = await structuredReportToHtmlNode(dicomFile, { noDocumentHeader: true }) + const { outputText: outputTextNoHeader } = await structuredReportToHtmlNode(dicomBinaryFile, { noDocumentHeader: true }) t.assert(!outputTextNoHeader.includes('Breast Diagnosis 010001 (female, #BreastDx-01-0001)')) t.assert(!outputTextNoHeader.includes('PixelMed (XSLT from di3data csv extract)')) - const { outputText: outputTextRenderAllCodes } = await structuredReportToHtmlNode(dicomFile, { renderAllCodes: true }) + const { outputText: outputTextRenderAllCodes } = await structuredReportToHtmlNode(dicomBinaryFile, { renderAllCodes: true }) t.assert(outputTextRenderAllCodes.includes('Overall Assessment (111413, DCM)')) @@ -61,7 +62,7 @@ test('read Radiation Dose SR', async t => { const dicomFileBuffer = fs.readFileSync(testFilePath) const dicomFile = new Uint8Array(dicomFileBuffer) - const { outputText } = await structuredReportToHtmlNode(dicomFile) + const { outputText } = await structuredReportToHtmlNode({ data: dicomFile, path: fileName }) t.assert(outputText.includes('X-Ray Radiation Dose SR Document')) t.assert(outputText.includes('

CT Accumulated Dose Data

')) @@ -73,7 +74,7 @@ test('readDicomEncapsulatedPdfNode', async t => { const testFilePath = `../../../build-emscripten/ExternalData/test/Input/${fileName}` const dicomFileBuffer = fs.readFileSync(testFilePath) const dicomFile = new Uint8Array(dicomFileBuffer) - const { pdfBinaryOutput: outputBinaryStream } = await readDicomEncapsulatedPdfNode(dicomFile) + const { pdfBinaryOutput: outputBinaryStream } = await readDicomEncapsulatedPdfNode({ data: dicomFile, path: fileName }) t.assert(outputBinaryStream != null) t.assert(outputBinaryStream.length === 91731) }) @@ -86,7 +87,7 @@ test('read Key Object Selection SR', async t => { const dicomFile = new Uint8Array(dicomFileBuffer) const { outputText } = await structuredReportToHtmlNode( - dicomFile, { + { data: dicomFile, path: fileName }, { urlPrefix: 'http://my-custom-dicom-server/dicom.cgi', cssReference: "https://css-host/dir/subdir/my-first-style.css", } @@ -101,7 +102,7 @@ test('read Key Object Selection SR', async t => { const cssFileBuffer = fs.readFileSync(testCssFilePath) const { outputText: outputWithCSSFile } = await structuredReportToHtmlNode( - dicomFile, { cssFile: cssFileBuffer }) + { data: dicomFile, path: fileName }, { cssFile: { data: cssFileBuffer, path: cssfileName }}) t.assert(outputWithCSSFile.includes('