Probabilistic Atlas (PAQD)
PAQD Atlas
Code
import NiiVue from '@niivue/niivue'
const aboutBtn = document.getElementById('aboutBtn')const clipBtn = document.getElementById('clipBtn')const gl1 = document.getElementById('gl1')const paqdSelect = document.getElementById('paqdSelect')const webgpuCheck = document.getElementById('webgpuCheck')
paqdSelect.onchange = function () { const _index = this.selectedIndex /** @type {[number, number, number, number]} */ let paqdUniforms = [0.2, 0.7, 0.9, 0.4] switch (this.value) { case 'rim': paqdUniforms = [0.2, 0.7, 0.9, 0.4] break case 'opaque': paqdUniforms = [0.01, 0.5, 0.5, 1.0] break case 'translucent': paqdUniforms = [0.01, 0.5, 0.25, 0.4] break } nv1.volumePaqdUniforms = paqdUniforms nv1.updateGLVolume()}clipBtn.onclick = () => { if (nv1.getClipPlaneDepthAziElev()[0] >= 1.0) { nv1.setClipPlane([0.0, 180, 30]) } else { nv1.setClipPlane([2, 180, 30]) }}webgpuCheck.onclick = function () { nv1.reinitializeView({ backend: this.checked ? 'webgpu' : 'webgl2' })}aboutBtn.onclick = () => { window.alert( 'Probabilistic atlas of the cerebellum PMID: 19457380 DOI: 10.1016/j.neuroimage.2009.01.045', )}
function handleLocationChange(data) { document.getElementById('location').innerHTML = ` ${data.string}`}// Click a legend colour box to hide/show that region, double-click to show only// it; the name moves the crosshair.const nv1 = new NiiVue({ backgroundColor: [0.1, 0.1, 0.2, 1], is3DCrosshairVisible: true, isLegendToggleEnabled: true,})nv1.addEventListener('locationChange', (e) => handleLocationChange(e.detail))await nv1.attachToCanvas(gl1)nv1.showRender = 1await nv1.loadVolumes([ { url: '/volumes/MNI152NLin6AsymC.nii.gz' }, { url: '/volumes/atl-Anatom.nii.gz' }, { url: '/volumes/spmMotor.nii.gz', colormap: 'warm', calMin: 4, calMax: 8 },])// The label table is the only remote asset here. If it can't be reached the// atlas still renders in its default colors, so report the loss and carry on// rather than letting the rejection strand the rest of the setup below.try { await nv1.addColormapFromUrl( 'https://niivue.github.io/niivue-demo-images/Cerebellum/atl-Anatom.json', ) await nv1.setVolume(1, { colormap: 'atl-Anatom' })} catch (err) { console.error('loading the atlas labels failed', err) document.getElementById('location').textContent = ` Could not load the atlas labels: ${err?.message ?? err}`}nv1.volumeIllumination = 0.4nv1.isColorbarVisible = truenv1.setVolume(0, { isColorbarVisible: false })nv1.setVolume(1, { isColorbarVisible: false })paqdSelect.onchange()