CRAN Packages 5-10 years ago vs. today

Imaging in R: 5 years ago

Workflow: 5 years ago

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

Workflow: 5 years ago

Multiple pieces of software used

  • all different syntax
flow

R: Programming and Interface Language

Workflow: Now

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

Complete pipeline

  • preprocessing and analysis
flow

Imaging in R: Now

Weaknesses of Imaging in R

Strengths of Imaging in R

  • Free
  • Large/strong R community
  • RStudio
  • Validated statistical models
  • Package development system
  • Neuroconductor
  • Shiny

Threats of Imaging in R

  • Not much different than Python
    • scikit-learn/ Nipype
  • Neural Networks
  • BME have tools for advanced statistical analysis
  • Study design is not as valued in imaging (neuro)
    • one stronghold of statisticians
  • Credit/Incentives for software

Opportunities of Imaging in R

Opportunities: CONSORT diagrams

Opportunities: Moving from Linear Models

  • Task fMRI: compare baseline to 1+ conditions
  • Smoothed to account for neighborhood
  • Run LM on time-series voxelwise with AR-type correlation with HRF-convolved design matrix (\(X\)) + motion/other factors (\(Z\))

\[ Y_{iv} = X_{i} \beta_{iv} + Z_{i}\theta_{iv} + \varepsilon_{iv} \\ \varepsilon_{iv} \sim N(0, \Sigma_{iv}) \\ \Sigma_{iv} \sim \text{AR} \]

\(Z_{i}\) can be different for each \(i\) (scrubbing), but usually isn’t.

Opportunities of Stats in Imaging

  • Get \(β_i\) map in MNI space
  • Run t-test, random effects analysis (hard to find sometimes), or permutation test
  • Perform multiple comparisons correction (maybe with spatial compoent)

Opportunities of Stats in Imaging

  • What if the motion had a non-linear effect?
    • currently: use derivatives and squared effects
    • why not GAMs? (speed)voxel package
  • fully Bayes (spatial) hard because of data size (maybe empirical)

Opportunities of Stats in Imaging

Opportunities: Data

What we need: tutorials

What we really need: tutorials on fMRI

What we need: Shiny GUIs

(Maybe) What we need: challenges

“Pre”-processing is Important

“Pre”-processing is Hard

Package Showcase

Data

  • EveTemplate/MNITemplate - templates
  • kirby21 series
  • sri24 - SRI24 MRI Atlas
  • malf.templates - templates for label fusion
  • neurohcp - download data from HCP/INDI
  • nitrcbot - download data from NITRC
  • neurovault - download data from https://neurovault.org/

General Imaging Tools

Starting from Raw Data/DICOM

  • oro.dicom - read/write DICOM data
  • dcm2niir - uses dcm2niix from Chris Rorden
  • divest - Rcpp wrapped dcm2niix
  • dcmtk - interface package for DCMTK
  • matlabr - could use dicomread MATLAB code and excecute through R

Interactive Visualization using papayaWidget

ggneuro visualization: ggplot2 object

Intensity Normalization

  • whitestripe - WhiteStripe (Shinohara et al. 2014)
  • Quantile transform quantile_img (in neurobase)
  • Whole brain z-scoring: zscore_img in neurobase
  • RAVEL - Fortin et al. (2016)
  • Histogram matching (in RAVEL)
  • General standardization methods

MS Lesion Segmentation

  • sublime - E. Sweeney et al. (2013)
  • oasis - Sweeney et al. (2013)
  • mimosa - Valcarcel et al. (2018)
  • smri.process - my package on sMRI processing

Step 1: Image Processing: Workflow

The N4 (Tustison et al. 2010) EM-style model assumed is: \[ \log(x(v)) = \log(u(v)) + \log( f(v) ) \]

  • \(x\): given image
  • \(u\): uncorrupted image
  • \(f\): bias field
  • \(v\): location in the image

Image Processing: MALF

Figure from MASS paper (Doshi et al. 2013):

  • Register templates to an image using the T1 for that subject
  • Apply transformation to the label/mask
  • Average each voxel over all templates
    • there are “smarter” (e.g. weighted) ways

Step 2: Create Predictors for each Sequence

Preds

  • Predictors created with intensity-normalized data
    • Quantile images, smoothers, local moments
  • Tissue class probability with local moments: MALF and FAST (Zhang, Brady, and Smith 2001)
  • Z-score to a population template

A package to do all this: smri.process

  • GitHub package (muschellij2/smri.process)

code

Publishing software

Tracking downloads

Conclusions

  • Many methods are being developed for processing neuroimaging in R
  • Analysis tools exist but need adaptation
  • Develop more standardization like BioConductor
    • standard data structures
  • GitHub and Neuroconductor

Where else can statisicians lead?

Do we need spatial results? If not, why register to the template?

Registration

ANTsR/extrantsr

  • antsRegistration - rigid/affine/non-linear diffeomorphic
  • extrantsr::registration - wraps antsRegistration to use nifti objects

fslr

  • flirt - linear/affine registration
  • fnirt - non-linear registration (need affine first)
  • fnirt_with_affine - wraps above 2

Bibliography

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

Fortin, Jean-Philippe, Elizabeth M Sweeney, John Muschelli, Ciprian M Crainiceanu, Russell T Shinohara, Alzheimer’s Disease Neuroimaging Initiative, and others. 2016. “Removing Inter-Subject Technical Variability in Magnetic Resonance Imaging Studies.” NeuroImage 132. Elsevier:198–212.

Shinohara, Russell T., Elizabeth M. Sweeney, Jeff Goldsmith, Navid Shiee, Farrah J. Mateen, Peter A. Calabresi, Samson Jarso, Dzung L. Pham, Daniel S. Reich, and Ciprian M. Crainiceanu. 2014. “Statistical Normalization Techniques for Magnetic Resonance Imaging.” NeuroImage: Clinical 6:9–19. https://doi.org/10.1016/j.nicl.2014.08.008.

Sweeney, Elizabeth M, Russell T Shinohara, Navid Shiee, Farrah J Mateen, Avni A Chudgar, Jennifer L Cuzzocreo, Peter A Calabresi, Dzung L Pham, Daniel S Reich, and Ciprian M Crainiceanu. 2013. “OASIS Is Automated Statistical Inference for Segmentation, with Applications to Multiple Sclerosis Lesion Segmentation in MRI.” NeuroImage: Clinical 2. Elsevier:402–13.

Sweeney, EM, RT Shinohara, CD Shea, DS Reich, and CM Crainiceanu. 2013. “Automatic Lesion Incidence Estimation and Detection in Multiple Sclerosis Using Multisequence Longitudinal Mri.” American Journal of Neuroradiology 34 (1). Am Soc Neuroradiology:68–73.

Tustison, Nicholas J., Brian B. Avants, Philip A. Cook, Yuanjie Zheng, Alexander Egan, Paul A. Yushkevich, and James C. Gee. 2010. “N4ITK: Improved N3 Bias Correction.” IEEE Transactions on Medical Imaging 29 (6):1310–20. https://doi.org/10.1109/TMI.2010.2046908.

Valcarcel, Alessandra M, Kristin A Linn, Simon N Vandekar, Theodore D Satterthwaite, John Muschelli, Peter A Calabresi, Dzung L Pham, Melissa Lynne Martin, and Russell T Shinohara. 2018. “MIMoSA: An Automated Method for Intermodal Segmentation Analysis of Multiple Sclerosis Brain Lesions.” Journal of Neuroimaging. Wiley Online Library.

Zhang, Yongyue, Michael Brady, and Stephen Smith. 2001. “Segmentation of Brain MR Images Through a Hidden Markov Random Field Model and the Expectation-Maximization Algorithm.” Medical Imaging, IEEE Transactions on 20 (1):45–57. http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=906424.