BigBrain Atlas
Voxel Atlas
Code
import NiiVue from '@niivue/niivue'
const aboutBtn = document.getElementById('aboutBtn')const colorBtn = document.getElementById('colorBtn')const colorbarCheck = document.getElementById('colorbarCheck')const darkCheck = document.getElementById('darkCheck')const gl1 = document.getElementById('gl1')const legendCheck = document.getElementById('legendCheck')const nearestCheck = document.getElementById('nearestCheck')const opacitySlider = document.getElementById('opacitySlider')const webgpuCheck = document.getElementById('webgpuCheck')
// Label volumes default to nearest (NIFTI_INTENT_LABEL or a label colormap);// this overrides it for the atlas.nearestCheck.onclick = function () { nv1.setVolume(1, { isNearestInterpolation: this.checked })}darkCheck.onclick = function () { nv1.volumeIsAlphaClipDark = this.checked}opacitySlider.oninput = function () { nv1.setVolume(1, { opacity: this.value * 0.01, })}legendCheck.onclick = async function () { await nv1.setVolume(1, { isLegendVisible: this.checked })}colorbarCheck.onclick = function () { nv1.isColorbarVisible = this.checked}colorBtn.addEventListener('input', (event) => { const input = event.target const hex = input.value const r = parseInt(hex.slice(1, 3), 16) / 255 const g = parseInt(hex.slice(3, 5), 16) / 255 const b = parseInt(hex.slice(5, 7), 16) / 255 nv1.backgroundColor = [r, g, b, 1.0]})webgpuCheck.onclick = function () { nv1.reinitializeView({ backend: this.checked ? 'webgpu' : 'webgl2' })}aboutBtn.onclick = () => { window.alert('The Automated Anatomical Labeling atlas PMID: 11771995.')}
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.3, 0.3, 0.5, 1], isLegendToggleEnabled: true,})nv1.addEventListener('locationChange', (e) => handleLocationChange(e.detail))await nv1.attachToCanvas(gl1)
nv1.showRender = 1var volumeList = [ { url: '/volumes/bigbrain/ICBM2009asym.nii.gz' }, { url: '/volumes/bigbrain/bigbrain.nii.gz' },]await nv1.loadVolumes(volumeList)// Registered under its file name; a `labels` array makes it a label map.await nv1.addColormapFromUrl('/volumes/bigbrain/bigbrain.json')await nv1.setVolume(1, { colormap: 'bigbrain' })darkCheck.onclick()legendCheck.onclick()nearestCheck.onclick()opacitySlider.oninput()