Skip to content

Commit

Permalink
BUG: Updates to typescript tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Sep 25, 2023
1 parent 6abb5c3 commit ec6f4d7
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 26 deletions.
2 changes: 1 addition & 1 deletion wasm/elastix-wasm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PipelineFunctor
pipeline.add_option("-m,--moving", movingImage, "Moving image")->type_name("INPUT_IMAGE");

std::string initialTransformFile;
pipeline.add_option("-i,--initial-transform", initialTransformFile, "Initial transform to apply before registrtion ")->type_name("INPUT_BINARY_FILE");
pipeline.add_option("-i,--initial-transform", initialTransformFile, "Initial transform to apply before registration")->type_name("INPUT_BINARY_FILE");

itk::wasm::InputTextStream parameterObjectJson;
pipeline.add_option("parameter-object", parameterObjectJson, "Elastix parameter object representation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def elastix_async(
:param moving: Moving image
:type moving: Image
:param initial_transform: Initial transform to apply before registrtion
:param initial_transform: Initial transform to apply before registration
:type initial_transform: os.PathLike
:return: Resampled moving image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def elastix(
:param moving: Moving image
:type moving: Image
:param initial_transform: Initial transform to apply before registrtion
:param initial_transform: Initial transform to apply before registration
:type initial_transform: os.PathLike
:return: Resampled moving image
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion wasm/python/itkwasm-elastix/itkwasm_elastix/elastix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def elastix(
:param moving: Moving image
:type moving: Image
:param initial_transform: Initial transform to apply before registrtion
:param initial_transform: Initial transform to apply before registration
:type initial_transform: os.PathLike
:return: Resampled moving image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def elastix_async(
:param moving: Moving image
:type moving: Image
:param initial_transform: Initial transform to apply before registrtion
:param initial_transform: Initial transform to apply before registration
:type initial_transform: os.PathLike
:return: Resampled moving image
Expand Down
7 changes: 4 additions & 3 deletions wasm/typescript/cypress/e2e/write-parameter-files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ describe('writeParameterFiles', () => {
it('Write parameter files from a parameter object representation', function () {
cy.get('sl-tab[panel="writeParameterFiles-panel"]').click()

const parametersFile = { contents: new Uint8Array(this['parameters_multiple.json']), fileName: 'parameters_multiple.json' }
cy.get('#writeParameterFilesInputs input[name="parameter-object-file"]').selectFile([parametersFile,], { force: true })
cy.get('#writeParameterFilesInputs sl-button[name="loadSampleInputs"]').click()
cy.get('#writeParameterFiles-parameter-object-details').should('contain', '"AutomaticScalesEstimation"')
// cy.get returns a jquery object -- invoke to get the underlying element
cy.get('#writeParameterFilesInputs [name="parameter-files"]').invoke('get', '0').its('value').should('contain', 'translation')

cy.get('#writeParameterFilesInputs sl-button[name="run"]').click()

cy.get('#writeParameterFiles-parameter-files-details').should('contain', '"AutomaticScalesEstimation"')
cy.get('#writeParameterFiles-parameter-files-details').should('contain', 'AutomaticScalesEstimation')
})
})
Binary file modified wasm/typescript/dist/pipelines/elastix.wasm
Binary file not shown.
24 changes: 12 additions & 12 deletions wasm/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wasm/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"itk-wasm": "^1.0.0-b.140"
"itk-wasm": "^1.0.0-b.142"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.0",
Expand All @@ -53,7 +53,7 @@
"ava": "^5.3.1",
"cypress": "^13.2.0",
"debug": "^4.3.4",
"itk-image-io": "^1.0.0-b.140",
"itk-image-io": "^1.0.0-b.142",
"rollup": "^3.9.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-ignore": "^1.0.10",
Expand Down
2 changes: 1 addition & 1 deletion wasm/typescript/src/elastix-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function elastixNode(
}
if (typeof options.initialTransform !== "undefined") {
const initialTransform = options.initialTransform
mountDirs.add(path.dirname(value as string))
mountDirs.add(path.dirname(initialTransform as string))
args.push('--initial-transform')

const name = initialTransform as string
Expand Down
2 changes: 1 addition & 1 deletion wasm/typescript/src/elastix-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ElastixOptions {
/** Moving image */
moving?: Image

/** Initial transform to apply before registrtion */
/** Initial transform to apply before registration */
initialTransform?: string | File | BinaryFile

/** Fixed-to-moving transform path */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import { readImageArrayBuffer } from "itk-wasm"

export default async function elastixLoadSampleInputs (model, preRun=false) {
const dataUrl = 'https://w3s.link/ipfs/bafybeifq7m3mb4m3mgbhft2vqejjgwxx4azmmzuxwf5cubajpyaf4hq2gq/data/input'

const parameterObjectButton = document.querySelector("#elastixInputs [name=parameter-object-file-button]")
if (!preRun) {
parameterObjectButton.loading = true
}
const parameterObjectFile = 'parameters_multiple.json'
const parameterObjectResponse = await fetch(`${dataUrl}/${parameterObjectFile}`)
const parameterObject = await parameterObjectResponse.json()
model.inputs.set("parameterObject", parameterObject)

const parameterObjectElement = document.getElementById('elastix-parameter-object-details')
if (!preRun) {
parameterObjectElement.innerHTML = `<pre>${globalThis.escapeHtml(JSON.stringify(parameterObject), globalThis.interfaceTypeJsonReplacer, 2)}</pre>`
parameterObjectElement.disabled = false
parameterObjectButton.loading = false
}

const fixedButton = document.querySelector('#elastixInputs sl-button[name=fixed-file-button]')
if (!preRun) {
fixedButton.loading = true
Expand Down
2 changes: 1 addition & 1 deletion wasm/typescript/test/browser/demo-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h3>👨‍💻 Live API Demo ✨</h3>
<sl-tooltip content="Use the Upload button to provide the moving"><sl-details id="elastix-moving-details" summary="moving: Moving image" disabled></sl-details></sl-tooltip>
<label for="moving-file"><sl-button name="moving-file-button" variant="primary" outline onclick="this.parentElement.nextElementSibling.click()">Upload</sp-button></label><input type="file" name="moving-file" style="display: none"/>
<br /><br />
<sl-tooltip content="Use the Upload button to provide the initialTransform"><sl-details id="elastix-initial-transform-details" summary="initialTransform: Initial transform to apply before registrtion " disabled></sl-details></sl-tooltip>
<sl-tooltip content="Use the Upload button to provide the initialTransform"><sl-details id="elastix-initial-transform-details" summary="initialTransform: Initial transform to apply before registration" disabled></sl-details></sl-tooltip>
<label for="initial-transform-file"><sl-button name="initial-transform-file-button" variant="primary" outline onclick="this.parentElement.nextElementSibling.click()">Upload</sl-button></label><input type="file" name="initial-transform-file" style="display: none"/>
<br /><br />
<sl-input required name="transform" type="text" label="transform" help-text="Fixed-to-moving transform"></sl-input>
Expand Down
3 changes: 2 additions & 1 deletion wasm/typescript/test/node/elastix-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ try {
test('Default 2D registration', async t => {
const fixedImage = await readImageLocalFile(path.join(testDataInputDirectory, 'CT_2D_head_fixed.iwi.cbor'))
const movingImage = await readImageLocalFile(path.join(testDataInputDirectory, 'CT_2D_head_moving.iwi.cbor'))
const parameterObject = JSON.parse(fs.readFileSync(path.join(testDataInputDirectory, 'parameters_single.json')))
const transform = path.join(testDataOutputDirectory, 'CT_2D_head_node_transform.txt')
const { result } = await elastixNode({ fixed: fixedImage, moving: movingImage, transformPath: transform })
const { result } = await elastixNode(parameterObject, { fixed: fixedImage, moving: movingImage, transformPath: transform })

t.is(result.imageType.dimension, 2)
t.is(result.imageType.componentType, 'int16')
Expand Down

0 comments on commit ec6f4d7

Please sign in to comment.