Shiny Contest Submission: ShinyMRI - View MRI images in Shiny

shinyapps.io example: https://haozhu233.shinyapps.io/shinyMRI-contest/
rstudio cloud project: Posit Cloud

(I’m running out of hours for my shinyapps.io. In you can’t open the app above, check out this one below on our connect server)

self-hosted version (somehow our server has some issues to close graphical devices. If you run into an error, refresh the page will likely solve the issue).

shinymri

shinymri2

About

This app demonstrates using R shiny to dynamically visualize 3D/4D medical imaging data in the conventional way. It offers a basic yet useful tool for researchers and clinicians to quickly check MRI data inside a browser. More importantly, the mechanism we used here can be used to visualize any 3D voxel data. Here we are using MRI images as an example because this is a well-known format for the public and it's fun to play with.

This app provides two modes to visualize the data. In the first mode, you can play the images like a movie. We call it "animation" mode. Behind the scene, the images are rendered into pngs under a different environment (See lazyr.R). Therefore, we can enjoy the ultimate streaming speed provided by renderImage while the main Shiny thread won't get blocked when generating those plots. This is different from the strategy of promises as promises is good for "a few operations that take a long time" while we have "lots of little operations that a bit slow".

In the second mode, you can play with the app interactively by clicking a point on any of the three plots. This 3D position will then be mapped to the other two plots and show you the cross-sectional picture of that point in the 3D space (indicated by the crosshair). In our field, clinicians uses this to diagnostic cerebrovascular diseases or other things like white matter disease.

If you check the source code of app.R, you will see the app itself is very small. The truth is that this time we also wraped up the two modes I just described as shiny modules. In the near future, we will release this two modules as a separate R package so people can use them more easily.

Authors:

  • Hao Zhu
  • Nischal Mahaveer Chand
  • Thomas Travison
20 Likes

This is very cool. Do you have any type of walkthrough, tutorial, and/or blog post on the lazyr.R code? This seems like a very interesting and widely applicable use case.

1 Like

This is really nice. We have made something similar using papaya called papayaWidget: https://github.com/muschellij2/papayaWidget. Grabbing the indices requires a bit of JavaScript, so not really R only, but may want to look at.

Keep up the great work

1 Like

We've also tried to get nifti images into a ggplot2 format in ggneuro (https://github.com/muschellij2/ggneuro) and into an app here https://jhubiostatistics.shinyapps.io/neuroshiny/.

Keep up the great work

1 Like

Yes! Our intern Nischal Chand wrote up a very nice blog post about this lazyr approach. Check it out here: https://towardsdatascience.com/lazy-loading-data-in-r-2b100acb63fc

1 Like

Hi,
Great Post

Please point me to the r code,

Thanks
Bharath

Here you go. :slight_smile:

2 Likes

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.