Skip to content

korbinian90/Niivue.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Niivue

Stable Dev Build Status Coverage

An interactive WebGL based neuroimaging viewer built on top of Bonito.jl and NiiVue.

 Screenshot of a Niivue.jl view, showing a NIfTI file and random array together. The viewer renders directly in the VS Code plot pane. NiiVue settings can be modified interactively in the REPL

Installation

This package is not registered yet. Installation can be performed via

import Pkg
Pkg.add(url="https://github.com/korbinian90/Niivue.jl")

Quickstart

This should work in almost any julia environment (REPL, vscode, Pluto, Jupyter)

using Niivue

arr = rand(50,50,20)
nv = niivue(arr)

Use settings

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 = true

The methods (e.g. nv.setCrosshairWidth(5)) and options (e.g. nv.isColorbar = true) can be found in the niivue javascript documentation.

Electron Display

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

Examples

Have a look at the 'examples' subfolder.

Hacking

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)

Limitations

  • some functions don't work with the Julian Syntax yet and need to be called via the javascript "hacking" way

Future plans

  • 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

Acknowledgements

Development of an initial prototype was supported by Chris Rorden (University of South Carolina)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages