An interactive WebGL based neuroimaging viewer built on top of Bonito.jl and NiiVue.
This package is not registered yet. Installation can be performed via
import Pkg
Pkg.add(url="https://github.com/korbinian90/Niivue.jl")This should work in almost any julia environment (REPL, vscode, Pluto, Jupyter)
using Niivue
arr = rand(50,50,20)
nv = niivue(arr)using Niivue
# initialization settings
volumes = [
Dict(
:url => "https://niivue.github.io/niivue-demo-images/mni152.nii.gz",
:colormap => "gray",
),
Dict(
:url => "https://niivue.github.io/niivue-demo-images/spmMotor.nii.gz",
:colormap => "redyell",
:opacity => 0.5,
)
]
nv = niivue(volumes)
# interactively adapt settings
nv.setCrosshairWidth(5)
nv.setCrosshairColor([0,1,1,0.5])
nv.isColorbar = trueThe methods (e.g. nv.setCrosshairWidth(5)) and options (e.g. nv.isColorbar = true) can be found in the niivue javascript documentation.
To use an Electron display instead of the browser, add in the beginning
using Electron
use_electron_display(devtools=false)In vscode, by default the plot pane is used. To use the Electron display, deactivate the plotting pane via the command palette (ctrl+shift+p) -> Julia: Disable Plot Pane
Have a look at the 'examples' subfolder.
Javascript can be directly executed from Julia and the nv object is available as window.nv
using Niivue
nv = niivue()
width = 10
js = Niivue.Bonito.js"""
window.nv.setCrosshairWidth($(width))
"""
Niivue.Bonito.evaljs(nv.app.session.x, js)Return a value from javascript to julia:
using Niivue
nv = niivue()
js_return = Niivue.Bonito.js"""
window.nv.colormaps()
"""
cmaps = Niivue.Bonito.evaljs_value(nv.app.session.x, js_return)- some functions don't work with the Julian Syntax yet and need to be called via the javascript "hacking" way
- use niivue-vscode as alternative pre-configured viewer
- Support access to volumes (e.g.
nv.volumes[1].opacity = 0.3) and functions with return values (e.g.cmaps = nv.colormaps()) directly from julia - observable in julia that stores the crosshair location
Development of an initial prototype was supported by Chris Rorden (University of South Carolina)
