Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix sample data URL #81

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"license": "Apache-2.0",
"homepage": "https://github.com/KitwareMedical/ITKIOScanco#readme",
"dependencies": {
"itk-image-io": "1.0.0-b.132",
"itk-wasm": "1.0.0-b.132"
"@itk-wasm/image-io": "^0.3.0",
"itk-wasm": "1.0.0-b.149"
},
"devDependencies": {
"@itk-wasm/dam": "^1.0.1",
Expand All @@ -38,4 +38,4 @@
"type": "git",
"url": "https://github.com/KitwareMedical/ITKIOScanco"
}
}
}
35 changes: 20 additions & 15 deletions app/pnpm-lock.yaml

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

11 changes: 5 additions & 6 deletions app/src/conversion-controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readImageArrayBuffer, writeImageArrayBuffer } from "itk-wasm"
import { readImage, writeImage } from "@itk-wasm/image-io"

import conversionLoadSampleInputs from "./conversion-load-sample-inputs.js"
import { notify, downloadFile } from "./utilities.js"
Expand Down Expand Up @@ -91,19 +91,18 @@ class ConversionController {
runButton.loading = true
const t0 = performance.now()

const { webWorker, image } = await readImageArrayBuffer(this.webWorker,
model.inputVolume.slice(),
'volume.aim'
const { webWorker, image } = await readImage(this.webWorker,
{ data: model.inputVolume.slice(), path: 'volume.isq' }
)
this.webWorker = webWorker
// Avoid later use of detached buffer
const direction = image.direction.slice()
const { arrayBuffer } = await writeImageArrayBuffer(webWorker, image, `${model.inputFileName}.${model.outputFormat}`)
const { serializedImage } = await writeImage(webWorker, image, `${model.inputFileName}.${model.outputFormat}`)

const t1 = performance.now()
notify("conversion successfully completed", `in ${t1 - t0} milliseconds.`, "success", "rocket-fill")

model.outputVolume = new Uint8Array(arrayBuffer)
model.outputVolume = new Uint8Array(serializedImage.data)

outputOutputDownload.variant = "success"
outputOutputDownload.disabled = false
Expand Down
4 changes: 2 additions & 2 deletions app/src/conversion-load-sample-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default async function conversionLoadSampleInputs (model) {

const inputVolumeDescription = document.getElementById("input-volume-description")

const url = import.meta.env.DEV ? '/sample-data/AIMIOTestImage.AIM' : 'https://itk.mypinata.cloud/ipfs/QmPaZBXqb99fsKQi28tCuGpW1LgiVrBYKRimY28nA9mYgE'
const url = import.meta.env.DEV ? '/sample-data/AIMIOTestImage.AIM' : 'https://data.kitware.com/api/v1/file/653283f75be10c8fb6ed4efc/download'
const response = await fetch(url)
const contentLength = parseInt(response.headers.get('Content-Length'))
inputVolumeDescription.innerHTML = `Sample AIM volume size: <sl-format-bytes value="${contentLength}"></sl-format-bytes>`
Expand Down Expand Up @@ -43,4 +43,4 @@ export default async function conversionLoadSampleInputs (model) {
progressBar.value = 0

return model
}
}
6 changes: 6 additions & 0 deletions app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
import * as imageIo from '@itk-wasm/image-io'

// Use local, vendored WebAssembly module assets
const pipelinesBaseUrl: string | URL = new URL('/itk/image-io', document.location.origin).href
imageIo.setPipelinesBaseUrl(pipelinesBaseUrl)

import './conversion-controller.js'
// import './calibration-controller.js'
19 changes: 7 additions & 12 deletions app/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ export default defineConfig({
outDir: 'dist',
emptyOutDir: true,
},
worker: {
format: 'es'
},
optimizeDeps: {
exclude: ['@itk-wasm/image-io']
},
plugins: [
// put lazy loaded JavaScript and Wasm bundles in dist directory
viteStaticCopy({
targets: [
{ src: 'node_modules/itk-wasm/dist/web-workers/*', dest: 'itk/web-workers' },
{
src: 'node_modules/itk-image-io/*',
dest: 'itk/image-io',
},
{ src: 'node_modules/@itk-wasm/image-io/dist/pipelines/*.{js,wasm.zst}', dest: 'itk/image-io' },
],
})
],
resolve: {
// where itk-wasm code has 'import ../itkConfig.js` point to the path of itkConfig
alias: {
'../itkConfig.js': itkConfig,
'../../itkConfig.js': itkConfig
}
}
})
Loading