import NiiVue from '@niivue/niivue'
const decimationSlide = document.getElementById('decimationSlide')
const fiberColor = document.getElementById('fiberColor')
const gl1 = document.getElementById('gl1')
const radiusSlide = document.getElementById('radiusSlide')
const sliceType = document.getElementById('sliceType')
const webgpuCheck = document.getElementById('webgpuCheck')
const xrayCheck = document.getElementById('xrayCheck')
sliceType.onchange = () => {
nv1.sliceType = parseInt(sliceType.value, 10)
radiusSlide.oninput = async function () {
await nv1.setTractOptions(0, { fiberRadius: this.value * 0.1 })
decimationSlide.oninput = async function () {
await nv1.setTractOptions(0, { decimation: parseInt(this.value, 10) })
fiberColor.onchange = async function () {
await nv1.setTractOptions(0, { colorBy: this.value })
xrayCheck.onclick = function () {
nv1.meshXRay = +this.checked * 0.05
webgpuCheck.onclick = function () {
nv1.reinitializeView({ backend: this.checked ? 'webgpu' : 'webgl2' })
const nv1 = new NiiVue({ backgroundColor: [0, 0, 0, 1] })
await nv1.attachToCanvas(gl1)
nv1.clipPlaneColor = [0, 0, 0, 0]
await nv1.loadVolumes([{ url: '/volumes/mni152.nii.gz' }])
// Load DSI-Studio TinyTrack format (.tt.gz)
url: '/meshes/TR_S_R.tt.gz',
rgba255: [0, 255, 255, 255],
tractOptions: { fiberRadius: 0.5 },