diff --git a/README.md b/README.md index af08d03..a7ad682 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,20 @@ -# NiiVue brainchop +### NiiVue brainchop Provided a lesion map and an acute [Center of Cancellation](https://github.com/neurolabusc/Cancel) score, this web page will predict the chronic neglect severity. The provided lesion map should be normalized to standard space. This is an edge-based solution: the values are computed directly on the web browser, and are not shared with a cloud service. [Try the live demo](https://niivue.github.io/niivue-neglect/) -### To serve locally +### Usage + + 1. Open the [live demo](https://niivue.github.io/niivue-neglect/). + 2. Press the `Open Lesion Map` button and select the normalized lesion. You can normalize lesions using [the clinical toolbox for SPM](https://github.com/neurolabusc/Clinical). + 3. You can visually inspect the lesion (shown as red) with respect to the grayscale atlas and the core prediction voxels (shown in blue). + 4. Set the [Center of Cancellation (CoC)](https://github.com/neurolabusc/Cancel) score that was measured acutely. + 5. Press the `Prediction` button to see the expected outcome score. + +![niivue-neglect user interface](niivue-neglect.png) + +### For Developers + +You can serve a hot-reloadable web page that allows you to interactively modify the source code. ```bash git clone https://github.com/niivue/niivue-neglect diff --git a/index.html b/index.html index a3d1373..f4df563 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@
- + acc + coefficients_i[index] * kernel_value, 0) + prediction += bias_i + prediction_sum += prediction + // Feature weights and bias term (if needed for further use) + // let w = support_vectors_i.map((sv, index) => sv.map((value, j) => value * coefficients_i[index])) + // let b = bias_i + } + let prediction_mean = prediction_sum / models.length + return [acuteCoC , ROI_volML, prediction_mean] } openBtn.onclick = async function () { let input = document.createElement('input') @@ -77,7 +114,9 @@ async function main() { input.click() } predictBtn.onclick = function () { - window.alert('Outcome prediction: 0.70289') + const [acuteCoC , ROI_volML, prediction] = neglect_predict() + const str = (`Given ${ROI_volML}ml lesion, and ${acuteCoC} acute CoC, predicted recovery is ${prediction}`) + window.alert(str) } aboutBtn.onclick = function () { window.alert('Drag and drop NIfTI images. Use pulldown menu to choose brainchop model') @@ -88,7 +127,8 @@ async function main() { const defaults = { backColor: [0.4, 0.4, 0.4, 1], show3Dcrosshair: true, - onLocationChange: handleLocationChange + onLocationChange: handleLocationChange, + dragAndDropEnabled: false, } maskSlider.oninput = function () { nv1.setOpacity(1, this.value /255) @@ -102,14 +142,13 @@ async function main() { const pca_mu = (await nv1.loadFromUrl('./pca_values_mu.nii.gz')).img async function loadRBFmodel() { const rbf = (await nv1.loadFromUrl('./models_5x10_diff.nii.gz')).img - let v = 0; + let v = 0 const nModels = rbf[v++] - const models = [] + const fmodels = [] for (let i = 0; i < nModels; i++) { let model = {} model.dim0 = rbf[v++] model.dim1 = rbf[v++] - model.bias_i = rbf[v++] model.gamma_i = rbf[v++] model.SVs = new Float64Array(model.dim0 * model.dim1) @@ -118,8 +157,9 @@ async function main() { model.sv_coef = new Float64Array(model.dim0) for (let j = 0; j < model.dim0; j++) model.sv_coef[j] = rbf[v++] - models.push(model) + fmodels.push(model) } + return fmodels } const models = await loadRBFmodel() nv1.opts.dragMode = nv1.dragModes.pan @@ -134,7 +174,6 @@ async function main() { ]) maskSlider.oninput() lesionSlider.oninput() - neglect_predict() } main() diff --git a/niivue-neglect.png b/niivue-neglect.png new file mode 100644 index 0000000..feac096 Binary files /dev/null and b/niivue-neglect.png differ