From b05bede64baea2071ae2f6f0f4d1cfd7468bd2b3 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Thu, 2 May 2024 14:31:58 -0400 Subject: [PATCH 1/4] Interpolation for partial volume --- index.html | 2 ++ main.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/index.html b/index.html index c67cd14..9d405e0 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,8 @@
+ +   diff --git a/main.js b/main.js index 31dbad5..87e78be 100644 --- a/main.js +++ b/main.js @@ -5,6 +5,9 @@ import { isChrome, localSystemDetails } from "./brainchop-telemetry.js" import MyWorker from "./brainchop-webworker.js?worker" async function main() { + smoothCheck.onchange = function () { + nv1.setInterpolation(smoothCheck.checked) + } aboutBtn.onclick = function () { window.alert("BrainChop models https://github.com/neuroneural/brainchop") } From cc2610dd0002d2c77473bb09830e6872b24e22a7 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Thu, 2 May 2024 14:46:48 -0400 Subject: [PATCH 2/4] Nearest neighbor is true in NiiVue convention --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 87e78be..b7190f3 100644 --- a/main.js +++ b/main.js @@ -6,7 +6,7 @@ import MyWorker from "./brainchop-webworker.js?worker" async function main() { smoothCheck.onchange = function () { - nv1.setInterpolation(smoothCheck.checked) + nv1.setInterpolation(!smoothCheck.checked) } aboutBtn.onclick = function () { window.alert("BrainChop models https://github.com/neuroneural/brainchop") From c28b8da051fdbb1d5ff5e24092fadd86bfa00c96 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Fri, 3 May 2024 08:03:36 -0400 Subject: [PATCH 3/4] Do not use performance.now() between main thread and webworker --- brainchop-mainthread.js | 2 +- brainchop-telemetry.js | 5 ++--- brainchop-webworker.js | 2 +- index.html | 2 +- main.js | 5 +++-- package-lock.json | 8 ++++---- package.json | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/brainchop-mainthread.js b/brainchop-mainthread.js index 221a633..435ef30 100644 --- a/brainchop-mainthread.js +++ b/brainchop-mainthread.js @@ -2010,7 +2010,7 @@ async function enableProductionMode(textureF16Flag = true) { async function runInference(opts, modelEntry, niftiHeader, niftiImage, callbackImg, callbackUI) { const statData = [] - statData.startTime = performance.now() + statData.startTime = Date.now() // for common webworker/mainthread do not use performance.now() callbackUI('Segmentation started', 0) const startTime = performance.now() const batchSize = opts.batchSize diff --git a/brainchop-telemetry.js b/brainchop-telemetry.js index 603d132..f3f1234 100644 --- a/brainchop-telemetry.js +++ b/brainchop-telemetry.js @@ -149,7 +149,6 @@ async function isChrome() { } async function localSystemDetails(statData, gl = null) { - const Preprocess_t = ((performance.now() - statData.startTime) / 1000).toFixed(4) // -- Timing data to collect const today = new Date() if (statData.isModelFullVol) { @@ -168,9 +167,9 @@ async function localSystemDetails(statData, gl = null) { statData["State"] = "" statData["City"] = "" } */ - + statData.Total_t = (Date.now() - statData.startTime) / 1000.0 + delete statData.startTime statData.Date = parseInt(today.getMonth() + 1) + '/' + today.getDate() + '/' + today.getFullYear() - statData.Time_Elapsed = Preprocess_t statData.Browser = await detectBrowser() statData.Browser_Ver = await detectBrowserVersion() statData.OS = await detectOperatingSys() diff --git a/brainchop-webworker.js b/brainchop-webworker.js index cc851d3..35ced15 100644 --- a/brainchop-webworker.js +++ b/brainchop-webworker.js @@ -2013,7 +2013,7 @@ async function enableProductionMode(textureF16Flag = true) { async function runInferenceWW(opts, modelEntry, niftiHeader, niftiImage, callbackImg, callbackUI) { const statData = [] - statData.startTime = performance.now() + statData.startTime = Date.now() // for common webworker/mainthread do not use performance.now() callbackUI('Segmentation started', 0) const batchSize = opts.batchSize const numOfChan = opts.numOfChan diff --git a/index.html b/index.html index 9d405e0..33f0bf2 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@
- +   diff --git a/main.js b/main.js index b7190f3..7fdbdf2 100644 --- a/main.js +++ b/main.js @@ -102,8 +102,6 @@ async function main() { nv1.setClipPlane([2, 0, 90]) } } - - async function fetchJSON(fnm) { const response = await fetch(fnm) const js = await response.json() @@ -119,6 +117,8 @@ async function main() { if (modelEntry.colormapPath) { let cmap = await fetchJSON(modelEntry.colormapPath) overlayVolume.setColormapLabel(cmap) + // n.b. most models create indexed labels, but those without colormap mask scalar input + overlayVolume.hdr.intent_code = 1002 // NIFTI_INTENT_LABEL } else { let colormap = opts.atlasSelectedColorTable.toLowerCase() const cmaps = nv1.colormaps() @@ -182,6 +182,7 @@ async function main() { nv1.opts.multiplanarForceRender = true nv1.opts.yoke3Dto2DZoom = true nv1.opts.crosshairGap = 11 + smoothCheck.onchange() await nv1.loadVolumes([{ url: "./t1_crop.nii.gz" }]) for (let i = 0; i < inferenceModelsList.length; i++) { var option = document.createElement("option") diff --git a/package-lock.json b/package-lock.json index 290232c..1bdeb3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "niivue-brainchop", "version": "0.1.0", "dependencies": { - "@niivue/niivue": "^0.42.0", + "@niivue/niivue": "^0.43.0", "@tensorflow/tfjs": "^4.18.0", "gl-matrix": "^3.4.3" }, @@ -404,9 +404,9 @@ } }, "node_modules/@niivue/niivue": { - "version": "0.42.0", - "resolved": "https://registry.npmjs.org/@niivue/niivue/-/niivue-0.42.0.tgz", - "integrity": "sha512-aHuSF78MU0GHKFdXecJDmvZOC0/pmV8yqfyfsqeHCJDe5vaCueO8WwGTIUDfoxCQ0uLqtFvRtbcJvehxlxInDw==", + "version": "0.43.0", + "resolved": "https://registry.npmjs.org/@niivue/niivue/-/niivue-0.43.0.tgz", + "integrity": "sha512-qj2lx+F3xPcYvGHNPwxaI6pd2O3BKOD/r9eE28zjZlFNebFuu6bSODUOkb6sKH1CTp6QtncTkVSmejotgOyiMQ==", "dependencies": { "@lukeed/uuid": "^2.0.1", "@ungap/structured-clone": "^1.2.0", diff --git a/package.json b/package.json index db90b01..1af9c29 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "dependencies": { - "@niivue/niivue":"^0.42.0", + "@niivue/niivue":"^0.43.0", "@tensorflow/tfjs": "^4.18.0", "gl-matrix": "^3.4.3" }, From ff733f6147c4d9bcc66ea49aae168f33b6db3bd1 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Fri, 3 May 2024 08:07:13 -0400 Subject: [PATCH 4/4] Bump tfjs --- package-lock.json | 68 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1bdeb3a..d3d43ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@niivue/niivue": "^0.43.0", - "@tensorflow/tfjs": "^4.18.0", + "@tensorflow/tfjs": "^4.19.0", "gl-matrix": "^3.4.3" }, "devDependencies": { @@ -629,16 +629,16 @@ ] }, "node_modules/@tensorflow/tfjs": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-4.18.0.tgz", - "integrity": "sha512-MjA2M91wSkTkpFSuyQAuZm+DT9Y7DFu3rsTaO1BjCbf1S7o8DgJPKMmh6hk6uEn6/SBBbZVXPu+ZTQ/SyrP2Pw==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-4.19.0.tgz", + "integrity": "sha512-d2A1lTc6my7GJ5LwqzXa+igJ5+18exwsnaphZ3roi5nJ197uwxVSMIc2vSJnqZz1KajC5/mZgQr67EZrpTFlBg==", "dependencies": { - "@tensorflow/tfjs-backend-cpu": "4.18.0", - "@tensorflow/tfjs-backend-webgl": "4.18.0", - "@tensorflow/tfjs-converter": "4.18.0", - "@tensorflow/tfjs-core": "4.18.0", - "@tensorflow/tfjs-data": "4.18.0", - "@tensorflow/tfjs-layers": "4.18.0", + "@tensorflow/tfjs-backend-cpu": "4.19.0", + "@tensorflow/tfjs-backend-webgl": "4.19.0", + "@tensorflow/tfjs-converter": "4.19.0", + "@tensorflow/tfjs-core": "4.19.0", + "@tensorflow/tfjs-data": "4.19.0", + "@tensorflow/tfjs-layers": "4.19.0", "argparse": "^1.0.10", "chalk": "^4.1.0", "core-js": "3.29.1", @@ -650,9 +650,9 @@ } }, "node_modules/@tensorflow/tfjs-backend-cpu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-4.18.0.tgz", - "integrity": "sha512-zk6NyGGsv0mCDnc5xWxLB5Zi8GaHVI2gg7KC0FSw/r5wW9SfA3ZIqUHVZhbIVhNqZSWy6L/+EIJa7l6q1XCkrg==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-4.19.0.tgz", + "integrity": "sha512-7pT05Ea6GTXjbqRgkmayZRYvaiNl3LLk1TyfUvC8iIqMw5d7p4Wgte2pfM2gMbIZ/opOxURhFYuI0FiQvUrW6g==", "dependencies": { "@types/seedrandom": "^2.4.28", "seedrandom": "^3.0.5" @@ -661,15 +661,15 @@ "yarn": ">= 1.3.2" }, "peerDependencies": { - "@tensorflow/tfjs-core": "4.18.0" + "@tensorflow/tfjs-core": "4.19.0" } }, "node_modules/@tensorflow/tfjs-backend-webgl": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-4.18.0.tgz", - "integrity": "sha512-ZLQ8MnWnIttMDqHepEzPL0Y4HkTePl8+AaYm9AcNnDUK7VF2jn+BXcTHCUOGfiwKu/OMwRc6osDrjxr0cCqNrA==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-4.19.0.tgz", + "integrity": "sha512-R0DC1W65lqTOccCwxMhH+VOKCgSrhd9GEejIIGhjeXt6oZlACFnOx4SuUr/qKLCDsL5I4E9iFLxAJMmsfYvARw==", "dependencies": { - "@tensorflow/tfjs-backend-cpu": "4.18.0", + "@tensorflow/tfjs-backend-cpu": "4.19.0", "@types/offscreencanvas": "~2019.3.0", "@types/seedrandom": "^2.4.28", "seedrandom": "^3.0.5" @@ -678,21 +678,21 @@ "yarn": ">= 1.3.2" }, "peerDependencies": { - "@tensorflow/tfjs-core": "4.18.0" + "@tensorflow/tfjs-core": "4.19.0" } }, "node_modules/@tensorflow/tfjs-converter": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-4.18.0.tgz", - "integrity": "sha512-b7utNMvmI986OPaQvDyHoiHKiIyip7ubSjG4KzTcFOWEKTsirtHxRp/6QKY/XSuH3AJK9Switu1/B5QC7xR2Zg==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-4.19.0.tgz", + "integrity": "sha512-xIOE6enaVHPYCXKpHxJnUlN8hzlcQkgFSymHjBmdDnNCresuRwBGz4dqYAQMeQG21Ei3lxCQFdDDH7aSvUEAPw==", "peerDependencies": { - "@tensorflow/tfjs-core": "4.18.0" + "@tensorflow/tfjs-core": "4.19.0" } }, "node_modules/@tensorflow/tfjs-core": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-4.18.0.tgz", - "integrity": "sha512-wjyq+F8AZJjhtr5xUBAON4VrNBXr9Poows/LnRh1K7wS+w41sCk0EQfeo6NfgUZXbHE/jgcqU6+fZDUKt3qRrg==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-4.19.0.tgz", + "integrity": "sha512-GZ0d53PG0HGQCC7hbWv1qDnZctHYe/cafHZrBY5eNeQjQE6fBr3NsR5GfLadT0TELwmX9/nyritGDzvy6xmzHQ==", "dependencies": { "@types/long": "^4.0.1", "@types/offscreencanvas": "~2019.7.0", @@ -712,25 +712,25 @@ "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==" }, "node_modules/@tensorflow/tfjs-data": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-4.18.0.tgz", - "integrity": "sha512-JGfEwq8a0nEXwwU04/PW7O6kZ3FdqAd6ofMboM9qwGTv47QdeO/G1657sy4N21Q/qiz5qFDbGLhim3Nq9gZm9g==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-4.19.0.tgz", + "integrity": "sha512-n0ZgJp5UhhBatohUt9pXSCCApusK+1Flyk6yDrQYuxOTjhRppd6jYrF7LCDG3hMFi3QLGl0jab1zYrn9BwtC/w==", "dependencies": { "@types/node-fetch": "^2.1.2", "node-fetch": "~2.6.1", "string_decoder": "^1.3.0" }, "peerDependencies": { - "@tensorflow/tfjs-core": "4.18.0", + "@tensorflow/tfjs-core": "4.19.0", "seedrandom": "^3.0.5" } }, "node_modules/@tensorflow/tfjs-layers": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-4.18.0.tgz", - "integrity": "sha512-9AyxUdvjMDbDOkNzdkMRToJZF/le5ia8X3lVfGRGxzsuyoWDBGlV9V1ICufD+Z8sODXVyu+cgE8kAMtVK4aHFA==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-4.19.0.tgz", + "integrity": "sha512-NufvuRaZdIyoG+R13d7oL8G5Bywox+ihPMiMZ3tWU+me8C8Y0pVC69mrnhOS9R8an7GDxKKSTTNEZhUvPvMGiQ==", "peerDependencies": { - "@tensorflow/tfjs-core": "4.18.0" + "@tensorflow/tfjs-core": "4.19.0" } }, "node_modules/@types/estree": { diff --git a/package.json b/package.json index 1af9c29..d8e5e7c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@niivue/niivue":"^0.43.0", - "@tensorflow/tfjs": "^4.18.0", + "@tensorflow/tfjs": "^4.19.0", "gl-matrix": "^3.4.3" }, "devDependencies": {