Skip to content

Commit

Permalink
Merge pull request #951 from thewtex/demo-file-output
Browse files Browse the repository at this point in the history
Demo file output
  • Loading branch information
thewtex authored Sep 24, 2023
2 parents a7594b7 + 9dc3181 commit b906087
Show file tree
Hide file tree
Showing 25 changed files with 269 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ class CompareDoubleImagesController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'compareDoubleImages-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'compareDoubleImages') {
Expand All @@ -142,10 +148,16 @@ class CompareDoubleImagesController {
url.search = params
window.history.replaceState({ functionName: 'compareDoubleImages' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'compareDoubleImages') {
preRun()
}
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated file. To retain edits, remove this comment.

export default null
// export default async function compareDoubleImagesLoadSampleInputs (model) {
// export default async function compareDoubleImagesLoadSampleInputs (model, preRun=false) {

// Load sample inputs for the compareDoubleImages function.
//
Expand All @@ -25,4 +25,4 @@ export default null
// Use this function to run the pipeline when this tab group is select.
// This will load the web worker if it is not already loaded, download the wasm module, and allocate memory in the wasm model.
// Set this to `false` if sample inputs are very large or sample pipeline computation is long.
export usePreRun = true
export const usePreRun = true
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,14 @@ class VectorMagnitudeController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'vectorMagnitude-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'vectorMagnitude') {
Expand All @@ -83,10 +89,16 @@ class VectorMagnitudeController {
url.search = params
window.history.replaceState({ functionName: 'vectorMagnitude' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'vectorMagnitude') {
preRun()
}
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated file. To retain edits, remove this comment.

export default null
// export default async function vectorMagnitudeLoadSampleInputs (model) {
// export default async function vectorMagnitudeLoadSampleInputs (model, preRun=false) {

// Load sample inputs for the vectorMagnitude function.
//
Expand All @@ -25,4 +25,4 @@ export default null
// Use this function to run the pipeline when this tab group is select.
// This will load the web worker if it is not already loaded, download the wasm module, and allocate memory in the wasm model.
// Set this to `false` if sample inputs are very large or sample pipeline computation is long.
export usePreRun = true
export const usePreRun = true
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ class CompressStringifyController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'compressStringify-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'compressStringify') {
Expand All @@ -89,10 +95,16 @@ class CompressStringifyController {
url.search = params
window.history.replaceState({ functionName: 'compressStringify' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'compressStringify') {
preRun()
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ compressStringify.setPipelineWorkerUrl(pipelineWorkerUrl)
import './compress-stringify-controller.js'
import './parse-string-decompress-controller.js'

const tabGroup = document.querySelector('sl-tab-group')
const params = new URLSearchParams(window.location.search)
if (params.has('functionName')) {
const functionName = params.get('functionName')
tabGroup.show(functionName + '-panel')
} else {
tabGroup.show('compressStringify-panel')
if (!params.has('functionName')) {
params.set('functionName', 'compressStringify')
const url = new URL(document.location)
url.search = params
window.history.replaceState({ functionName: 'compressStringify' }, '', url)
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ class ParseStringDecompressController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'parseStringDecompress-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'parseStringDecompress') {
Expand All @@ -79,10 +85,16 @@ class ParseStringDecompressController {
url.search = params
window.history.replaceState({ functionName: 'parseStringDecompress' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'parseStringDecompress') {
preRun()
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async function applyPresentationStateToImageNode(
{ type: InterfaceTypes.Image },
]

mountDirs.add(path.dirname(imageIn as string))
mountDirs.add(path.dirname(presentationStateFile as string))
mountDirs.add(path.dirname(value as string))
mountDirs.add(path.dirname(value as string))
const inputs: Array<PipelineInput> = [
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function readDicomEncapsulatedPdfNode(
{ type: InterfaceTypes.BinaryStream },
]

mountDirs.add(path.dirname(dicomFile as string))
mountDirs.add(path.dirname(value as string))
const inputs: Array<PipelineInput> = [
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ async function readImageDicomFileSeriesNode(
args.push('--input-images')

options.inputImages.forEach((value) => {
mountDirs.add(path.dirname(value as string))
mountDirs.add(path.dirname(value as string))
args.push(value as string)

})
}
if (typeof options.singleSortedSeries !== "undefined") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function structuredReportToHtmlNode(
{ type: InterfaceTypes.TextStream },
]

mountDirs.add(path.dirname(dicomFile as string))
mountDirs.add(path.dirname(value as string))
const inputs: Array<PipelineInput> = [
]

Expand Down Expand Up @@ -127,7 +127,7 @@ async function structuredReportToHtmlNode(
}
if (typeof options.cssFile !== "undefined") {
const cssFile = options.cssFile
mountDirs.add(path.dirname(cssFile as string))
mountDirs.add(path.dirname(value as string))
args.push('--css-file')

const name = cssFile as string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function structuredReportToTextNode(
{ type: InterfaceTypes.TextStream },
]

mountDirs.add(path.dirname(dicomFile as string))
mountDirs.add(path.dirname(value as string))
const inputs: Array<PipelineInput> = [
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ class ApplyPresentationStateToImageController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'applyPresentationStateToImage-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'applyPresentationStateToImage') {
Expand All @@ -128,10 +134,16 @@ class ApplyPresentationStateToImageController {
url.search = params
window.history.replaceState({ functionName: 'applyPresentationStateToImage' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'applyPresentationStateToImage') {
preRun()
}
})

Expand Down
11 changes: 5 additions & 6 deletions packages/dicom/typescript/test/browser/demo-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import './structured-report-to-text-controller.js'
import './read-dicom-tags-controller.js'
import './read-image-dicom-file-series-controller.js'

const tabGroup = document.querySelector('sl-tab-group')
const params = new URLSearchParams(window.location.search)
if (params.has('functionName')) {
const functionName = params.get('functionName')
tabGroup.show(functionName + '-panel')
} else {
tabGroup.show('applyPresentationStateToImage-panel')
if (!params.has('functionName')) {
params.set('functionName', 'applyPresentationStateToImage')
const url = new URL(document.location)
url.search = params
window.history.replaceState({ functionName: 'applyPresentationStateToImage' }, '', url)
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@ class ReadDicomTagsController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'readDicomTags-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'readDicomTags') {
Expand All @@ -87,10 +93,16 @@ class ReadDicomTagsController {
url.search = params
window.history.replaceState({ functionName: 'readDicomTags' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'readDicomTags') {
preRun()
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,14 @@ class StructuredReportToTextController {
}
})

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', async (event) => {
const preRun = async () => {
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
}

const onSelectTab = async (event) => {
if (event.detail.name === 'structuredReportToText-panel') {
const params = new URLSearchParams(window.location.search)
if (!params.has('functionName') || params.get('functionName') !== 'structuredReportToText') {
Expand All @@ -159,10 +165,16 @@ class StructuredReportToTextController {
url.search = params
window.history.replaceState({ functionName: 'structuredReportToText' }, '', url)
}
if (!this.webWorker && loadSampleInputs && usePreRun) {
await loadSampleInputs(model, true)
await this.run()
}
await preRun()
}
}

const tabGroup = document.querySelector('sl-tab-group')
tabGroup.addEventListener('sl-tab-show', onSelectTab)
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search)
if (params.has('functionName') && params.get('functionName') === 'structuredReportToText') {
preRun()
}
})

Expand Down
2 changes: 2 additions & 0 deletions src/bindgen/typescript/demo/input-parameters-demo-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function inputParametersDemoHtml (functionName, prefix, indent, parameter, requi
}
break
case 'TEXT':
case 'OUTPUT_TEXT_FILE':
case 'OUTPUT_BINARY_FILE':
result += `${prefix}${indent}<sl-input ${requiredAttr}name="${parameter.name}" type="text" label="${label}" help-text="${description}"></sl-input>\n`
break
case 'INT':
Expand Down
Loading

0 comments on commit b906087

Please sign in to comment.