Skip to content

Commit

Permalink
Merge pull request #76 from thewtex/prod-sample-data
Browse files Browse the repository at this point in the history
Prod sample data
  • Loading branch information
thewtex authored Jul 27, 2023
2 parents e72b860 + 7bd0c8a commit 2ef3107
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ <h2>ITK IO Scanco</h2>
</sl-select>
<br />
<sl-divider></sl-divider>
<br /><sl-button name="loadSampleInputs" variant="default" style="display: none;">Load sample input</sl-button>
<sl-button type="button" variant="success" name="run">Run</sl-button>
<br /><sl-button name="loadSampleInputs" variant="default" style="display: none;">Load sample</sl-button>
<sl-button type="button" variant="success" name="run">Convert</sl-button>
<br />
<br />
<sl-progress-bar name="progress" label="Progress" value="0" max="100" style="display: none;"></sl-progress-bar>
Expand Down
5 changes: 3 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"version": "0.1.0",
"description": "Convert and calibrate Scanco microCT volume .isq and .aim files.",
"scripts": {
"start": "npm run copyShoelaceAssets && npm run downloadSampleData && vite -c vite.config.js",
"start": "pnpm copyShoelaceAssets && pnpm downloadSampleData && vite",
"preview": "pnpm copyShoelaceAssets && pnpm downloadSampleData && vite build && vite preview",
"test": "echo \"tests are not configured\" && exit 1",
"downloadSampleData": "dam download -v public/sample-data public/sample-data.tar.gz bafybeiepwh5ppaeaja7q6kqc25tvzfpkygqomxzqq4csnjfntoxarqtdiq https://w3s.link/ipfs/bafybeihiuinvftya2jqrr7fhdrdf4a5zhx7gnmawwf45mid7j2s5zcn6xi",
"copyShoelaceAssets": "shx mkdir -p public/shoelace && shx cp -r node_modules/@shoelace-style/shoelace/dist/assets public/",
"build": "npm run copyShoelaceAssets && npm run downloadSampleData && vite -c vite.config.js build"
"build": "pnpm copyShoelaceAssets && pnpm downloadSampleData && vite build"
},
"keywords": [
"itk",
Expand Down
11 changes: 6 additions & 5 deletions app/src/conversion-load-sample-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export default async function conversionLoadSampleInputs (model) {

const inputVolumeElement = document.querySelector("#conversionInputs sl-input[name=input-volume]")

const response = await fetch('/sample-data/AIMIOTestImage.AIM')
const contentLength = +response.headers.get('Content-Length');
const url = import.meta.env.DEV ? '/sample-data/AIMIOTestImage.AIM' : 'https://itk.mypinata.cloud/ipfs/QmPaZBXqb99fsKQi28tCuGpW1LgiVrBYKRimY28nA9mYgE'
const response = await fetch(url)
const contentLength = parseInt(response.headers.get('Content-Length'))
inputVolumeElement.helpText = 'Input volume size: ' + contentLength + ' bytes'
progressBar.max = contentLength

const reader = response.body.getReader()

Expand All @@ -23,8 +23,9 @@ export default async function conversionLoadSampleInputs (model) {

chunks.push(value)
receivedLength += value.length
progressBar.value = receivedLength
progressBar.textContent = `${receivedLength.toString()} / ${contentLength.toString()} bytes`
const percent = receivedLength / contentLength * 100
progressBar.value = percent
progressBar.textContent = `${percent.toFixed(2)}%`
}

let inputVolume = new Uint8Array(receivedLength)
Expand Down

0 comments on commit 2ef3107

Please sign in to comment.