- Read/Write Images
- Visualization of Images
- Inhomogeneity/Bias Field Correction
- Skull Stripping/Brain Extraction
- Image Registration
- Tissue-Class Segmentation
- Image operations
- Complex Modeling (yeah - it's R)
April 10, 2016
Multi-modal dataset from HAMMER, (NIfTI conversion from ANALYZE).
Data from https://www.nitrc.org/frs/?group_id=187 (testing folder in White_Matter_Lesion_Segmentation_Testdata.zip)
4 MRI sequences: T1-weighted, T2-weighted, PD, FLAIR
files t1 t2 pd flair "T1.nii.gz" "T2.nii.gz" "PD.nii.gz" "FLAIR.nii.gz"
oro.dicom
- read/write DICOM data, the nifti object
dcm2niir
- uses dcm2nii
from Chris Rorden
matlabr
- could use dicomread
MATLAB code and excecute through R
Medical Imaging Task View
dti
- adaptive smoothing and diffusion tensor tools
fmri
- post-processing analysis: linear models and p-value smoothingAnalyzeFMRI
- fMRI analysis (last updated in 2013)spm12r
package calls out MATLAB using SPM
Medical Imaging Task View
oro.nifti
: read/write data, the nifti objectfslr
: process data (need FSL for most of the functionality)ANTsR
: process data (full toolbox)
extrantsr
: makes ANTsR work with nifti objectsfslr: readnii
uses oro.nifti::readNIfTI
:
library(fslr) base_t1 = readnii(files["t1"])
library(fslr) fslr::ortho2(base_t1)
over_50 = mask_img(base_t1, base_t1 > 40); ortho2(base_t1, over_50)
image(base_t1, z = 55, plot.type = "single")
over_50[over_50 <= 0] = NA; over_50 = cal_img(over_50) overlay(base_t1, over_50, z = 55, plot.type = "single")
ANTsR/extrantsr
bias_correct
from extrantsr
package calls ANTsR::n4BiasFieldCorrection
(N. J. Tustison et al. 2010)library(extrantsr) n4_t1 = bias_correct(file = base_t1, correction = "N4", retimg = TRUE)
fslr: Uses method by Sled, Zijdenbos, and Evans (1998) (slow)
bc_t1 = fsl_biascorrect(file = base_t1) FSLDIR='/usr/local/fsl/'; export FSLDIR; sh "${FSLDIR}/etc/fslconf/fsl.sh"; FSLOUTPUTTYPE=NIFTI_GZ; export FSLOUTPUTTYPE; $FSLDIR/bin/fast -B --nopve --out="/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//Rtmpa4mKOM/file15e6f7f9ff9a7" "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/Rtmpa4mKOM/file15e6f60841581.nii.gz";
ratio = finite_img(n4_t1 / base_t1) ortho2(n4_t1, ratio, col.y = alpha(hotmetal(), 0.75))
ss_t1 = fslbet(n4_t1, outfile = "SS_Image") FSLDIR='/usr/local/fsl/'; export FSLDIR; sh "${FSLDIR}/etc/fslconf/fsl.sh"; FSLOUTPUTTYPE=NIFTI_GZ; export FSLOUTPUTTYPE; $FSLDIR/bin/bet2 "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/Rtmpa4mKOM/file15e6f2126f0db.nii.gz" "./SS_Image"
mask = ss_t1 > 0 ortho2(base_t1, y = mask, col.y = alpha("red", 0.5))
cropped = dropEmptyImageDimensions(ss_t1) image(cropped, z = floor(dim(cropped)[3]/2), plot.type = "single")
rgl
, misc3d
(contour3d
function)brainR
- put on a webpage with some controlsdevtools::source_gist("bd40d10afabc503d71e8")
ANTsR/extrantsr
antsRegistration
- rigid/affine/non-linear diffeomorphicextrantsr::registration
- wraps antsRegistration to use nifti
objectsfslr
flirt
- linear/affine registrationfnirt
- non-linear registration (need affine first)fnirt_with_affine
- wraps above 2
registration
from extrantsr
is a general function to do linear/non-linear registration, using antsRegistration
ants_reg_flair = registration( filename = files["flair"], template.file = n4_t1, typeofTransform = "Rigid")
template.file = mni_fname(mm = "1", brain = TRUE) ss_t1_to_mni = registration( filename = ss_t1, template.file = template.file, typeofTransform = "SyN", remove.warp = FALSE, outprefix = "temp")
ANTsR/extrantsr: uses Atropos (Brian B Avants et al. 2011)
ANTsR
- atropos
, extrantsr
- otropos
tissue_seg = otropos(a = ss_t1, x = mask)
fslr: uses FAST (Zhang, Brady, and Smith 2001)
--nobias
as an option does not do bias field correctionfast_t1 = fast(ss_t1, opts = "--nobias") FSLDIR='/usr/local/fsl/'; export FSLDIR; sh "${FSLDIR}/etc/fslconf/fsl.sh"; FSLOUTPUTTYPE=NIFTI_GZ; export FSLOUTPUTTYPE; $FSLDIR/bin/fast --nobias --out="/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//Rtmpa4mKOM/file15e6f60cbfee3" "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/Rtmpa4mKOM/file15e6f682913b1.nii.gz";
See alos spm12r_segment
fslr
fslsmooth
- Gaussian/box smoothingfslerode/fsldilate
- erosion/dilationfslfill/fslfill2
- fill holesspm12r
spm_bwlabel
- label connected componentsANTsR
smooth_image
- Gaussian smoothingoMath("ME")/oMath("MD")
- erosion/dilationoMath("FillHoles")
- fill holesoMath("GetLargestComponent")
- find largest componentsfsl_slicetimer
- slice timing correctionANTsR::preprocessfMRI
spm12r
Avants, B. B., C. L. Epstein, M. Grossman, and J. C. Gee. 2008. “Symmetric Diffeomorphic Image Registration with Cross-Correlation: Evaluating Automated Labeling of Elderly and Neurodegenerative Brain.” Medical Image Analysis, Special issue on the third international workshop on biomedical image registration - WBIR 2006, 12 (1): 26–41. doi:10.1016/j.media.2007.06.004.
Avants, Brian B, Nicholas J Tustison, Jue Wu, Philip A Cook, and James C Gee. 2011. “An Open Source Multivariate Framework for N-Tissue Segmentation with Evaluation on Public Data.” Neuroinformatics 9 (4). Springer: 381–400.
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. doi:10.1016/j.nicl.2014.08.008.
Sled, John G, Alex P Zijdenbos, and Alan C Evans. 1998. “A Nonparametric Method for Automatic Correction of Intensity Nonuniformity in MRI Data.” Medical Imaging, IEEE Transactions on 17 (1). IEEE: 87–97.
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. doi:10.1109/TMI.2010.2046908.
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). IEEE: 45–57.