Name: ANTsR
Owner: Advanced Normalization Tools Ecosystem
Description: Advanced Normalization Tools in R
Created: 2012-09-12 16:28:03.0
Updated: 2018-01-18 07:55:04.0
Pushed: 2018-01-18 17:01:52.0
Size: 27010
Language: HTML
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A package providing ANTs features in R as well as imaging-specific data representations, spatially regularized dimensionality reduction and segmentation tools. See also the Neuroconductor site.
Version: 0.4.0
License: Apache License 2.0
Depends: R (? 3.0), methods
Imports: Rcpp, tools, magrittr
LinkingTo: Rcpp, ITKR, ANTsRCore
Author: Brian B. Avants, Benjamin M. Kandel, Jeff T. Duda, Philip A. Cook, Nicholas J. Tustison, Dorian Pustina
Maintainer: Brian B. Avants
URL: homepage
BugReports: github issues
NeedsCompilation: yes
Travis checks: ANTsR results
Reference manual: ANTsR.pdf
Wiki: Notes and work in progress examples
Package source: from github
OS X Mavericks, Yosemite binaries: OSX
Linux binaries: Ubuntu
Windows installation option here
Install the binary, after downloading, via command line:
D INSTALL ANTsR_*.tgz
Inter-modality inference yet to be added RIPMMARC
Eigenanatomy for multiple modality population studies function sparseDecom
Tumor segmentation function mrvnrfs
(not exactly the same but close)
Multiple modality pediatric template and population study employs several aspects of ANTsR
Structural networks from subject-level data function makeGraph
plus yet to be added RIPMMARC
SCCAN relating neuroimaging and cognitive batteries function sparseDecom2
Sparse regression with manifold smoothness constraints function sparseRegression
Prior-based eigenanatomy function sparseDecom
Corrective learning for segmentation functions segmentationRefinement.train
and segmentationRefinement.predict
.
Please read this entire section before choosing which method you prefer.
In general, these assume you have git installed / accessible in your environment, as well as a compiler, preferably clang
. you may also need cmake if you do/can not install cmaker
.
Windows users should see Rtools and maybe, also, installr for assistance in setting up their environment for building (must have a compiler too). To my knowledge, there are no recorded instances of ANTsR being installed on Windows. If someone does so, we would like to know.
You will need to install R packages that ANTsR requires. Minimally: Install ITKR and ANTsRCore here and here then do:
ps <- c( "Rcpp", "RcppEigen", "tools", "methods", "magrittr", "rsvd" )
all.packages( pkgs = mydeps, dependencies = TRUE )
You can gain additional functionality by installing packages that
are listed in the DESCRIPTION
file under Suggests
.
A complete list of recommended ancillary packages here.
Method 1: with devtools in R
ary( devtools )
stall_github("stnava/cmaker") # if you do not have cmake
all_github("stnava/ANTsR")
Method 2: from command line (most traditional method)
Assumes git, cmake and compilers are available in your environment (as above).
First, clone the repository:
t clone https://github.com/stnava/ITKR.git
t clone https://github.com/ANTsX/ANTsRCore.git
t clone https://github.com/ANTsX/ANTsR.git
Install the package as follows:
CMD INSTALL ITKR
CMD INSTALL ANTsRCore
CMD INSTALL ANTsR
The travis.yml
file also shows a way to install from Linux command line.
Method 3: from binaries
Note that version numbers will change over time.
https://github.com/stnava/ITKR/releases/download/latest/ITKR_0.4.12_R_x86_64-pc-linux-gnu.tar.gz
D INSTALL ITKR_0.4.12_R_x86_64-pc-linux-gnu.tar.gz
https://github.com/ANTsX/ANTsRCore/releases/download/v0.4.2.1/ANTsRCore_0.4.2.1_R_x86_64-pc-linux-gnu.tar.gz
D INSTALL ANTsRCore_0.4.2.1_R_x86_64-pc-linux-gnu.tar.gz
https://github.com/ANTsX/ANTsR/releases/download/latest/ANTsR_0.6_R_x86_64-pc-linux-gnu.tar.gz
D INSTALL ANTsR_0.6_R_x86_64-pc-linux-gnu.tar.gz
Method 4: platform independent via docker and kitematic
This is a beta operation that is in flux but may be convenient for some users.
based on this approach
create a docker username
download and install kitematic
login to kitematic with your docker username
search for antsr
in the kitematic repository search bar
create a new container from the stnava
version of antsr
start the container
type the “access url” address into a browser to run rstudio with antsr.
it should be something like http://192.168.99.100:32989/
you can also add your home folders to the container instance by adjusting the “volumes” option under the settings tab. then you can access local data.
Load the package:
ary(ANTsR)
List the available functions in the namespace ANTsR:
R::<double-tab>
Call help on a function via ?functionName or see function arguments
via args(functionName)
If nothing else, ANTsR makes it easy to read and write medical images and to map them into a format compatible with R.
Read, write, access an image
ilename<-getANTsRData("mni")
-antsImageRead(mnifilename)
ImageWrite(img,mnifilename)
GetSpacing(img)
GetDirection(img)
GetOrigin(img)
t( img[50,60,44] )
t(max(img))
Index an image with a label
yimg<-array( data=(1:125), dim=c(5,5,5))
-as.antsImage( arrayimg )
t( max(img) )
t( mean(img[ img > 50 ]))
t( max(img[ img >= 50 & img <= 99 ]))
t( mean( img[ img >= 50 & img <= 99 ]) )
Convert a 4D image to a matrix
simg<-array( data=rnorm(125*10), dim=c(5,5,5,10))
simg<-as.antsImage(gaussimg)
t(dim(gaussimg))
<-getAverageOfTimeSeries( gaussimg )
lselect <- mask < 0
<-timeseries2matrix( gaussimg, voxelselect )
t(dim(gmat))
Convert a list of images to a matrix
ges<-100
t<-list()
( i in 1:nimages )
mimg<-makeImage( c(50,50) , rnorm(2500) )
mimg<-smoothImage(simimg,1.5)
ist[i]<-simimg
t a mask from the first image
<-getMask( ilist[[1]],
wThresh=mean(ilist[[1]]), cleanup=TRUE )
-imageListToMatrix( ilist, mask )
t(dim(mat))
Do fast statistics on a big matrix
Once we have a matrix representation of our population, we might run a quick voxel-wise regression within the mask. Then we look at some summary statistics.
-imageListToMatrix( ilist, mask )
-rnorm( nrow(mat) ) # simulated age
er<-rep( c("F","M"), nrow(mat)/2 ) # simulated gender
is creates "real" but noisy effects to detect
-mat*(age^2+rnorm(nrow(mat)))
-lm( mat ~ age + gender )
<-bigLMStats( mdl, 1.e-4 )
t(names(mdli))
t(rownames(mdli$beta.t))
t(paste("age",min(p.adjust(mdli$beta.pval[1,]))))
t(paste("gen",min(p.adjust(mdli$beta.pval[2,]))))
Write out a statistical map
We might also write out the images so that we can save them for later or look at them with other software.
etas<-makeImage( mask , mdli$beta.t[1,] )
ImageWrite( agebetas, tempfile(fileext ='.nii.gz') )
Neighborhood operations
Images neighborhoods contain rich shape and texture information. We can extract neighborhoods for further analysis at a given scale.
<-getANTsRData("mni")
<-antsImageRead(mnit)
<- resampleImage( mnit , rep(4, mnit@dimension) )
2<-getMask(mnit,lowThresh=mean(mnit),cleanup=TRUE)
us <- rep(2,mnit@dimension)
<-getNeighborhoodInMask(mnit, mask2, radius,
ysical.coordinates = FALSE,
undary.condition = "mean" )
The boundary.condition
says how to treat data that is outside of the mask
or the image boundaries. Here, we replace this data with the mean
in-mask value of the local neighborhood.
Eigenanatomy & SCCAN
Images often have many voxels ($p$-voxels) and, in medical applications, this means that $p>n$ or even $p»n$, where $n$ is the number of subjects. Therefore, we often want to “intelligently” reduce the dimensionality of the data. However, we want to retain spatial locality. This is the point of “eigenanatomy” which is a variation of sparse PCA that uses (optionally) biologically-motivated smoothness, locality or sparsity constraints.
sume you ran the population example above
t<-sparseDecom( mat, mask, 0.2, 5, cthresh=2, its=2 )
<-eigSeg(mask,eanat$eig,F)
The parameters for the example above are set for fast processing. You can see our paper for some theory on these methods[@Kandel2014a].
More information is available within the examples that can be seen within
the help for sparseDecom
, sparseDecom2
and the helper function
initializeEigenanatomy
. You might also
see the sccan tutorial.
Other useful tools
th
esholdImage
ntifyCBF
sPreprocessfMRI
Perfusion
puteDVARS
ROIValues
odynamicRF
pectImageData3D
eGraph
rixToImages
sRegistration
tPrettyGraph
tBasicNetwork
TemplateCoordinates
sSet*
Parts of ImageMath
from ANTs are accessible via
th
for more fMRI focused tools, see RKRNS and its github site github RKRNS.
A good visualization alternative is antsSurf.
Alternatively, one can use any function in the namespace by providing arguments exactly same as one provides to the corresponding command-line version.
For example, to call the antsRegistration routine:
R::antsRegistration( "-d", "2", "-m", "mi[r16slice.nii.gz,r64slice.nii.gz,1,20,Regular,0.05]", "-t", "affine[1.0]", "-c", "2100x1200x1200x0", "-s", "3x2x1x0", "-f", "4x3x2x1","-u", "1", "-o", "[xtest,xtest.nii.gz,xtest_inv.nii.gz]" )
R::antsRegistration( "-d", "2", "-m", "mi[r16slice.nii.gz,r64slice.nii.gz,1,20,Regular,0.05]", "-t", "affine[1.0]", "-c", "2100x1200x1200x0", "-s", "3x2x1x0", "-f", "4x3x2x1", "-m", "cc[r16slice.nii.gz,r64slice.nii.gz,1,4]", "-t", "syn[5.0,3,0.0]", "-i", "100x100x0", "-s", "2x1x0", "-f", "3x2x1", "-u", "1", "-o", "[xtest,xtest.nii.gz,xtest_inv.nii.gz]" )
tag -d beta
push origin :refs/tags/beta
tag beta
push --tags origin
More like development highlights, as opposed to release notes. See git log
for the complete history. We try to follow these versioning recommendations for R packages. Under these guidelines, only major.minor
is an official release.
ENH: added domainImg option to plot.antsImage which can standardize plot.
COMP: test for DVCL define requirement to improve clang and gcc compilations
WIP: transform objects can be created on the fly and manipulated thanks to jeff duda
ENH: automation for eigenanatomy
ENH: reworked SCCAN and eanat
ENH: mrvnrfs
ENH: resting state Vignette
DOC: clarify/extend antsApplyTransforms
ENH: multidimensional images
STYLE: iMath not ImageMath in ANTsR
WIP: iMath improvements
WIP: ASL pipeline fuctionality
BUG: Fixed image indexing bug
BUG: plot.antsImage improvements
ENH: more antsRegistration options
ENH: geoSeg
ENH: JointLabelFusion and JointIntensityFusion
ENH: Enable negating images
ENH: weingarten curvature
ENH: antsApplyTransformsToPoints with example
ENH: renormalizeProbabilityImages
ENH: Suppress output from imageWrite.
First official release.