code: http://github.com/muschellij2/JSM_2016

Problem: Explore 3D images of brain (MRI)

How big is a brain image?

  • Images come from NIfTI files
    • comprised of 3D pixels called voxels
  • Image dimensions are: \(197\times233\times189\) (> 8 million voxels)

Explore results: e.g. gray matter classification

Let's make it interactive!

Let's make it interactive!

Let's make it interactive!

But other (standalone) programs can do this!

Also known as "I can do that in X already"

Some (of my) principles of interactivity

  1. Should be scriptable to get the interactive graphic
    • still hard to script/reproduce the interaction
  2. Within the analysis workflow
    • Others are just standalone viewers
    • Relies on fewer systems/dependencies
  3. Easy to navigate for the user

First attempt: Use manipulate package

The manipulate package (Allaire 2014) from RStudio can add interactivity:

First attempt: Use manipulate package

The manipulate package (Allaire 2014) from RStudio can add interactivity, BUT:

  • Images rendering was slow
    • due to the R plotting and viewer interaction
  • Only works with
  • Can't embed output in a document

Second attempt: set of PDFs or GIFs!

The animation package (Xie 2013, Xie et al. (2015)) can make GIFs:

Pros:

  • Plotting with standard functions
    • Can be embedded into an html easily

Cons:

  • Not really "interactive"
    • less choice on user's end
    • no other views

Papaya JavaScript library

papayar R package, port of Papaya

library(papayar); papaya(image)

Is it an htmlwidget!?

No

Is it an htmlwidget!?

Not yet.

Lessons learned

  • Borrow (heavily) other people's stuff
  • htmlwidgets framework is great
    • some JS libraries have odd rules
  • Porting to R can help the community
    • need some non-R knowledge, usually JavaScript
    • not always so straightforward
    • Functionality at the whim of the JS maintainer

Bibliography