RAVEL
Intensity normalization of structural MRIs using RAVEL
Install / Use
/learn @Jfortin1/RAVELREADME
RAVEL <img src="sticker.png" width = "150" align="right" />
Intensity normalization methods for structural MRIs
Creator: Jean-Philippe Fortin, fortin946@gmail.com
Authors: Jean-Philippe Fortin, John Muschelli
License: GPL-2
Software status
| Resource: | Travis CI | | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | Platform: | OSX | | R CMD check | <a href="https://travis-ci.org/Jfortin1/RAVEL"><img src="https://travis-ci.org/Jfortin1/RAVEL.svg?branch=master" alt="Build status"></a> |
References
| Method | Citation | Paper Link | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | | RAVEL | Jean-Philippe Fortin, Elizabeth M Sweeney, John Muschelli, Ciprian M Crainiceanu, Russell T Shinohara, Alzheimer’s Disease Neuroimaging Initiative, et al. Removing inter-subject technical variability in magnetic resonance imaging studies. NeuroImage, 132:198–212, 2016. | Link | | WhiteStripe | Russell T Shinohara, Elizabeth M Sweeney, Jeff Goldsmith, Navid Shiee, Farrah J Mateen, Peter A Calabresi, Samson Jarso, Dzung L Pham, Daniel S Reich, Ciprian M Crainiceanu, Australian Imaging Biomarkers Lifestyle Flagship Study of Ageing, and Alzheimer’s Disease Neuroimaging Initiative. Statistical normalization techniques for magnetic resonance imaging. Neuroimage Clin, 6:9–19, 2014. | Link |
Table of content
1. Introduction
RAVEL is an R package that combines the preprocessing and statistical analysis of magnetic resonance imaging (MRI) datasets within one framework. Users can start with raw images in the NIfTI format, and end up with a variety of statistical results associated with voxels and regions of interest (ROI) in the brain. RAVEL stands for Removal of Artificial Voxel Effect by Linear regression, the main preprocessing function of the package that allows an effective removal of between-scan unwanted variation. We have shown in a recent paper that RAVEL improves significantly population-wide statistical inference. RAVEL is now part of the Neuroconductor project.
Installation
The following dependencies need to be installed first:
install.packages("devtools")
devtools::install_github("muschellij2/neurobase")
devtools::install_github("muschellij2/WhiteStripe")
RAVEL can be installed using the following command:
devtools::install_github("jfortin1/RAVEL")
2. Image preprocessing
We present a pre-normalization preprocessing pipeline implemented in the
R software, from raw images to images ready for intensity normalization
and statistical analysis. Once the images are preprocessed, users can
apply their favorite intensity normalization and the scan-effect
correction tool RAVEL as presented in Section 1 above. We present a
preprocessing pipeline that uses the R packages ANTsR and fslr.
While we have chosen to use a specific template space (JHU-MNI-ss), a
specific registration (non-linear diffeomorphic registration) and a
specific tissue segmentation (FSL FAST), users can choose other
algorithms prior to intensity normalization and in order for RAVEL to
work. The only requirement is that the images are registered to the same
template space.
2.1. Prelude
To preprocess the images, we use the packages fslr and ANTsR. The
package fslr is available on CRAN, and requires FSL to be installed on
your machine; see the FSL
website for installation. For
ANTsR, we recommend to install the latest stable version available at
the ANTsR GitHub page. The
version used for this vignette was ANTsR_0.3.2.tgz. For the template
space, we use the JHU-MNI-ss atlas (see Section 1.2) included in the
EveTemplate package, available on GitHub at
https://github.com/Jfortin1/EveTemplate. For data examples, we use 4
T1-w scans from the package RAVELData available on GitHub at
https://github.com/Jfortin1/RAVELData. Once the packages are properly
installed, we are ready to start our preprocessing of T1-w images. We
first load the packages into R:
library(fslr)
library(ANTsR)
library(RAVELData)
library(EveTemplate)
have.fsl() # Should be TRUE if fsl is correctly installed
and let’s specify the path for the different files that we will need:
# JHU-MNI-ss template:
library(EveTemplate)
template_path <- getEvePath("T1")
# JHU-MNI-ss template brain mask:
template_brain_mask_path <- getEvePath("Brain_Mask")
# Example of T1-w MPRAGE image
scan_path <- system.file(package="RAVELData", "extdata/scan1.nii.gz")
2.2. JHU-MNI-ss template (_EVE_ atlas)
2.3. Registration to template
Tp perform a non-linear registration to the JHU-MNI-ss template, one can
use the diffeomorphism algorithm via the ANTsR package. Note that we
perform the registration with the skulls on. Here is an example where we
register the scan1 from the RAVELData package to the JHU-MNI-ss
template:
library(ANTsRCore)
library(ANTsR)
template <- antsImageRead(template_path, 3)
scan <- antsImageRead(scan_path,3)
outprefix <- gsub(".nii.gz","",scan_path) # Prefix for the output files
output <- antsRegistration(fixed = template, moving = scan, typeofTransform = "SyN", outprefix = outprefix)
scan_reg <- antsImageClone(output$warpedmovout) # Registered brain
The object scan_reg contains the scan registed to the template. Note
that the object is in the ANTsR format. Since I prefer to work with
the oro.nifti package, which is compatible with flsr, I convert the
object to a nifti object using the function ants2oro as follows:
# devtools::install_github("muschellij2/extrantsr")
# or
# source("https://neuroconductor.org/sites/default/files/neurocLite.R")
# neuro_install("extrantsr")
library(extrantsr)
scan_reg <- extrantsr::ants2oro(scan_reg)
We can save the registered brain in the NIfTi format using the
writeNIfTI command:
writeNIfTI(scan_reg, "scan_reg")
Since scan_reg is converted to a nifti object, we can use the
function ortho2 from the fslr package to visualize the scan:
ortho2(scan_reg, crosshairs=FALSE, mfrow=c(1,3), add.orient=FALSE)
2.4. Intensity inhomogeneity correction
We perform intensity inhomogeneity correction on the registered scan
using the N4 Correction from the ANTsR package:
scan_reg <- extrantsr::oro2ants(scan_reg) # Convert to ANTsR object
scan_reg_n4 <- n4BiasFieldCorrection(scan_reg)
scan_reg_n4 <- extrantsr::ants2oro(scan_reg_n4) # Conversion to nifti object for further processing
2.5. Skull stripping
template_brain_mask <- readNIfTI(template_brain_mask_path, reorient=FALSE)
scan_reg_n4_brain <- niftiarr(scan_reg_n4, scan_reg_n4*template_brain_mask)
ortho2(scan_reg_n4_brain, crosshairs=FALSE, mfrow=c(1,3), add.orient=FALSE)
2.6. Tissue Segmentation
There are different tissue segmentation algorithms available in R. My
favorite is the FSL FAST segmentation via the
fslr
package. Let’s produce the tissue segmentation for the
scan_reg_n4_brain scan
above:
ortho2(scan_reg_n4_brain, crosshairs=FALSE, mfrow=c(1,3), add.orient=FALSE, ylim=c(0,400))
The last line of code produces via the ortho2 function from the fslr
package the following visualization of the template:
We perform a 3-class tissue segmentation on the T1-w image with the FAST segmentation algorithm:
scan_reg_n4_brain_seg <- fast(scan_reg_n4_brain, verbose=FALSE, opts="-t 1 -n 3")
ortho2(scan_reg_n4_brain_seg, crosshairs=FALSE, mfrow=c(1,3), add.orient=FALSE)
<p align="center">
<img src="images/seg.png" width="600"/>
</p>
The object scan_reg_n4_brain_seg is an image that contains the
segmentation labels 0,1,2 and 3 referring to Background, CSF, GM and
WM voxels respectively.
2.7. Creation of a tissue mask
Suppose we want to create a mask for CSF.
scan_reg_n4_brain_csf_mask <- scan_reg_n4_brain_seg
scan_reg_n4_brain_csf_mask[scan_reg_n4_brain_csf_mask!=1] <- 0
ortho2(scan_reg_n4_brain_csf_mask
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.2kCommit, push, and open a PR
