R is a language and environment
for statistical computing
and graphics.
https://cran.r-project.org/

R is a base set of foundational functions

flow

With by user-written packages of functions

flow

Benefits of R

  • Free, open-source
  • Cross-platform
  • Over 11000 packages
  • Taught by stat/biostat departments
  • Packaging system is good (well-documented, tested, relatively-understandable)
  • RStudio - company and software

Everything that exists is an object.
Everything that happens is a function call.
(Chambers 2014)

For example:

library(neurobase)
library(fslr)
img = readrpi("anat.nii.gz", verbose = FALSE)

Plotting orthographic

ortho2(img)

Workflow for an Analysis

  • bash flow
  • FSL flow
  • ANTs flow
  • MRIcroGL flow
  • OsiriX flow
  • SPM 12 flow
flow

Workflow for an Analysis

Multiple pieces of software used

  • all different syntax
flow

It’s typical to have lots of software choices

flow

Carp, Joshua. “The secret lives of experiments: methods reporting in the fMRI literature.” Neuroimage 63.1 (2012): 289-300.

My Goal:

Lower the bar to entry

  • all R code
    • pipeline tool
    • “native” R code

Complete pipeline

  • preprocessing and analysis
flow

What did R have?

What did R have?

flow

Bioinformatics Repository: Bioconductor
flow

Bioinformatics Repository: Bioconductor
flow

  • centralized bioinformatics/genomics packages
  • large community/number of packages (> 1300)
  • published tutorials and workflows
  • additional requirements to CRAN (e.g. packages need vignettes)

Bioinformatics Repository: Bioconductor
flow

  • team of developers/maintainers
  • multiple grants of support

Python Framework: NiPy flow

  • integrates multiple neuroimaging software
  • standardizes the syntax
  • provides workflows
  • allows the user to take advantage of all of Python
    • pandas, scikit-learn, Jupyter notebooks

flow
An R Platform for
Medical Imaging Analysis

What is Neuroconductor?

  1. A community of developers and users of R packages for imaging
  2. A website https://neuroconductor.org/.
    • with tutorials and help
  3. A team helping developers and users (John, Adi Gherman, Ciprian Crainiceanu, Brian Caffo)
  4. A centralized repository of maintained packages

Goal: Centralize the packages (currently 56)

flow

Solution: Build a Bioconductor-like Solution using Current Tools

Git and GitHub

  • Git version control system: stores changes of files flow

  • GitHub is an online server of repositories
  • Distribute packages and install them via devtools::install_github

flow

Continuous Integration: Travis and Appveyor

  • Builds and checks R packages on Windows (Appveyor) and Linux/OS X (Travis CI)
  • Works well with GitHub

flow     flow

Development Pipeline:

Check the package for stability

  • check against other imaging software (e.g. FSL)

flow

Helping Developers

  • GitHub allows the Neuroconductor team to help fix issues
  • Pull Requests to developers
  • Standardized checking of Packages (Travis configuration)
  • Remove unnecessary hurdles for developers

Neuroconductor installer:

Provide an installer to download the current packages:

source("https://neuroconductor.org/neurocLite.R")
neurocLite("kirby21.fmri")
neurocLite("neurobase")
neurocLite("ANTsR")

Neuroconductor Capabilities

Capabilities Packages
DICOM Images oro.dicom, dcm2niir, divest, ANTsR
NIfTI Images oro.nifti, RNifti, ANTsR
Image Registration spm12r, fslr, ANTsR, freesurfer
Inhomogeneity Correction spm12r, fslr, ANTsR
Brain Extraction spm12r, fslr, ANTsR, extrantsr
Structure Segmentation spm12r, fslr, ANTsR, extrantsr, freesurfer
Intensity Normalization WhiteStripe, neurobase, ANTsR
3D Smoothing ANTsR, spm12r, fslr
Temporal Filtering spm12r, fslr, ANTsR
Slice-timing correction spm12r, fslr
DTI models rcamino, oro.dti, fslr

Benefits of Neuroconductor:

Allow imaging to use all R has to offer:

  • Statistics and Machine Learning
  • Versioning and testing
  • Reproducibile reports and analyses
  • Shiny (web applications)
  • Genomics/Imaging analysis in one platform
    • Bioconductor

flow Neuroconductor Downsides

  1. More control over the workflow = more work
  2. Users need external software (versions/installation)
  3. No control over external software
    • if maintainer changes something, not much recourse
  4. Need the content (buy-in from the community)

Training we are providing

Example Packages

Using R as a Pipeline Tool: fslr

  • fslr package - call FSL from R

  • Requires FSL to be installed and in PATH
    • FSL only available on Unix-style systems

flow

RNifti

  • provides lightweight objects as C++ pointers (fast operations)
  • Wrapped in Rcpp: Works on all platforms

RNiftyReg

  • Registration of Images
  • Wrapped in Rcpp: Works on all platforms

ANTsR

Based on ANTs: Advanced Normalization Tools

  • State-of-the-art image processing pipelines
  • Built at UPenn under Brian Avants
    • Group has won challenges for imaging analysis
  • Still actively maintained and developed
  • Depends on the Insight ToolKit (ITK) medical image processing library

dcm2niir and divest: Converting DICOM data

  • dcm2nii by Dr. Chris Rorden
    • jackknife for almost any DICOM type to NIfTI
  • dcm2niir wraps a binary executable of dcm2nii
    • calls the command prompt (not always Windows-friendly)
  • divest wraps the background C++ code of dcm2nii
    • runs in “native” R

neurohcp: Human Connectome Project

rcamino: Port of Camino Software

kirby21.t1/kirby21.fmri: fMRI data from Kirby21

malf.templates: Segmented T1-weighted Images

  • Data from the MICCAI 2012 Challenge on Multi-atlas Labelling Data
  • From OASIS project and the labeled data as provided by Neuromorphometrics, Inc. (http://Neuromorphometrics.com/)

MALF: Skull Stripping Example

From (Doshi et al. 2013):

  • Register templates to an subject T1
  • Apply transformation to the label/mask, average over voxels
    • there are “smarter” (e.g. weighted) ways

spant: MR Spectroscopy Analysis Tools

  • Metabolite combination analysis
  • Non-brain imaging!

lungct: tools for Lung CT analysis

  • Non-brain imaging!
  • Not MR!

Current limitations

  • R is cross platform, but some packages that depend on *nix-only software can only be run on those systems
  • Still in beta testing, but more likely to incorporate requests
  • Rcpp requires compiled code, which can be tricky (but still cross-platform!)
  • Licenses with data can be tricky

spm12r: Wrapper Functions for SPM

Resources

References

Chambers, John M. 2014. “Object-Oriented Programming, Functional Programming and R.” Statistical Science 29 (2). Institute of Mathematical Statistics: 167–80.

Doshi, Jimit, Guray Erus, Yangming Ou, Bilwaj Gaonkar, and Christos Davatzikos. 2013. “Multi-Atlas Skull-Stripping.” Academic Radiology 20 (12). Elsevier: 1566–76.

Landman, Bennett A, Alan J Huang, Aliya Gifford, Deepti S Vikram, Issel Anne L Lim, Jonathan AD Farrell, John A Bogovic, et al. 2011. “Multi-Parametric Neuroimaging Reproducibility: A 3-T Resource Study.” Neuroimage 54 (4). Elsevier: 2854–66.