Commit d981d91e authored by Taylor Hanayik's avatar Taylor Hanayik
Browse files

Initial commit

parents
node_modules
package-lock.json
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>image-rater</title>
<script src="https://unpkg.com/@niivue/niivue@0.6.0/dist/niivue.js"></script>
</head>
<body>
<section>
<h1>Image to rate</h1>
</section>
<section>
<canvas id="gl" height=480 width=640></canvas>
</section>
<section>
<button onclick="nextImage()">
Next
</button>
</section>
</body>
<script>
let index = 0
var volumeList = [
// first object in array is brackground image
{
url: "./some_image.nii.gz",
volume: {hdr: null, img: null},
name: "some_image",
intensityMin: 0, // not used yet
intensityMax: 100, // not used yet
intensityRange:[0, 100], // not used yet
colorMap: "gray",
opacity: 100,
visible: true,
}
]
// Niivue will adjust the canvas to 100% of its parent container's size
// the parent element can be any size you want (small or large)
var nv = new niivue.Niivue()
nv.attachTo('gl') // the canvas element id
// nv.loadVolumes(volumeList)
// nv.setSliceType(nv.sliceTypeMultiPlanar)
let nextImage = () => {
fetch('/next')
.then(res => res.json())
.then((data) => {
v = [
{
url: '/base/' + data.index,
volume: {hdr:null, img:null},
colorMap: "gray",
opacity: 100,
visible:true
},
{
url: '/overlay/' + data.index,
volume: {hdr:null, img:null},
colorMap: "red",
opacity: 80,
visible:true
}
]
nv.loadVolumes(v)
v[0].cal_min = 0
v[0].cal_max = 100
})
}
</script>
</html>
\ No newline at end of file
const express = require('express')
const fs = require('fs');
const path = require('path');
const app = express()
const port = 3000
let args = process.argv.slice(2);
let dir = args[0]
let files = [];
const getFilesRecursively = (directory) => {
const filesInDirectory = fs.readdirSync(directory);
for (const file of filesInDirectory) {
const absolute = path.join(directory, file);
if (fs.statSync(absolute).isDirectory()) {
getFilesRecursively(absolute);
} else {
if (absolute.indexOf('_CT.nii.gz') != -1) {
files.push(absolute);
}
}
}
};
getFilesRecursively(dir)
fileIdx = -1
//process.exit()
app.get('/', (req, res) => {
res.sendFile('index.html', {root: '.'})
})
app.get('/base/:index', (req, res) => {
res.sendFile(files[req.params.index])
})
app.get('/overlay/:index', (req, res) => {
res.sendFile(files[req.params.index].replace('_CT','_thrbinCSF'))
})
app.get('/next', (req, res) => {
fileIdx = fileIdx+1
res.json({index: fileIdx})
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
\ No newline at end of file
{
"name": "nifti-rater",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Taylor Hanayik",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment