NiiVue is an open-source JavaScript library for WebGL2-based medical image viewing. This R package allows you to use NiiVue from R Shiny.
Demo for NiiVue's Tractography [code]
Partial demo for NiiVue's Time Series (toggle thumbnail doesn't work, but the other features do) [code]
- Install the devtools library
install.packages('devtools')
- Download this repo
git clone https://github.com/AnthonyAndroulakis/niivue.R
- Install niivue R library
cd niivue.R/niivue
devtools::install()
- Use it (for more examples, see the examples folder)
suppressWarnings(library(niivue))
library(shiny)
ui <- fluidPage(
fluidRow(
tags$div(style = "width: 100%; height: 600px;", NiivueWidget$new()$plot)
)
)
server <- function(input, output, session) {
volumeList <- list(
list(url = "https://niivue.github.io/niivue/images/mni152.nii.gz",
colormap = "gray", visible=TRUE, opacity=1)
)
nv <- NiivueWidget$new()
nv$loadVolumes(volumeList)
}
shinyApp(ui, server)
- you need a shiny server to run niivue.R
- usage mirrors that of the niivue library (camelcase)
- nv$opts and nv$graph are reactiveValues variables
- any large data arrays (ex: nv.volumes[0].img) are not sent back to R
- nv$thumbnailVisible(TRUE) doesn't work as intended
- only the onLocationChange niivue event handler is implemented
- no extensive documentation (just refer to https://niivue.github.io/niivue/devdocs/index.html)