Skip to content

Lesymap Installation

dorianps edited this page Nov 3, 2017 · 27 revisions

Lesymap needs only 1-2 minutes to install. However, it relies on the ANTsR neuroimaging suite, which may take some effort to install. If you are in a hurry, start with trying METHOD 3.

METHOD 1: Use devtools to install everything without leaving R:

This will install ITKR/ANTsRCore/ANTsR and finally will install LESYMAP. It's a slow process.

# Step 1: get the devtools package
install.packages('devtools', repos='http://cloud.r-project.org/')
# Step 2: ask devtools to install everything else
devtools::install_github('dorianps/LESYMAP')

METHOD 2: Use command lines to install in two steps:

First install the dependencies required by ANTsR:

mylist = c("Rcpp", "RcppArmadillo", "graphics", "grDevices", 
           "magic", "magrittr", "misc3d", "pixmap",
           "psych", "rsvd", "stats", "utils", 
           "lmPerm", "nparcomp" )
needindx =  ! mylist %in% installed.packages()
if (any(needindx)) install.packages(mylist[needindx])

Then install ANTsR and LESYMAP in command line:

sudo apt-get -y install git # Ubuntu command
sudo apt-get -y install cmake # Ubuntu command
git clone https://github.com/stnava/ITKR.git
git clone https://github.com/stnava/ANTsRCore.git
git clone https://github.com/stnava/ANTsR.git
git clone https://github.com/dorianps/LESYMAP.git
sudo R CMD INSTALL ITKR
sudo R CMD INSTALL ANTsRCore
sudo R CMD INSTALL ANTsR
sudo R CMD INSTALL LESYMAP

METHOD 3: Use pre-compiled ANTSR binaries (might be outdated):

Note, this may install outdated versions.
As usual, first make sure all required packages exist in R:

mylist = c("Rcpp", "RcppArmadillo", "graphics", "grDevices", 
           "magic", "magrittr", "misc3d", "pixmap",
           "psych", "rsvd", "stats", "utils", 
           "lmPerm", "nparcomp" )
needindx =  ! mylist %in% installed.packages()
if (any(needindx)) install.packages(mylist[needindx])

Then get binaries and install them in command line.
Try the commands specific for your OS:

Linux

wget -O ITKR.tar.gz https://github.com/stnava/ITKR/releases/download/latest/ITKR_0.4.12_R_x86_64-pc-linux-gnu.tar.gz
R CMD INSTALL ITKR.tar.gz
wget -O ANTsRCore.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
R CMD INSTALL ANTsRCore.tar.gz
wget -O ANTsR.tar.gz https://github.com/ANTsX/ANTsR/releases/download/latest/ANTsR_0.6.1_R_x86_64-pc-linux-gnu.tar.gz
R CMD INSTALL ANTsR.tar.gz
git clone https://github.com/dorianps/LESYMAP.git
R CMD INSTALL LESYMAP

METHOD 4: Independent installations:

First install ANTsR following the instructions on the official page. Those instructions might be more accurate on how to install ANTsR considering all latest changes.
Then install LESYMAP within R:

devtools::install_github('dorianps/LESYMAP')

or in command line:

git clone https://github.com/dorianps/LESYMAP.git
sudo R CMD INSTALL LESYMAP



Installation frustrations

R is a powerful language with thousands of packages available, but installing packages in R can sometimes become frustrating. Because packages and R evolve rapidly, there is a high chance that something does not work well. My advise is to work on one of the latest R versions (i.e., >=3.3), this will save you headaches of some packages who think that your R version is too old.

The best way to resolve problems is to look for the error, starting from the first one, and attempt to fix it. If a package could not be installed try it again manually with install.packages('packageNAME'). Often packages have github pages, and you can get their fixed/latest versions with devtools::install_github('user/packageName').

Here is a typical install on a fresh Ubuntu inside Windows Linux Subsystem.

In this case the the libcurl library was missing, and R needed to be the most recent one. These are the lines I used to make things work:

apt-get install libcurl4-openssl-dev

sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base
sudo apt-get -y install git
sudo apt-get -y install cmake
install.packages('devtools', repos='http://cloud.r-project.org/')
devtools::install_github('dorianps/LESYMAP', dependencies = c("Depends", "Imports", "LinkingTo", "Suggests"))

Simply sourcing the files.

The LESYMAP package is nothing but a bunch of files that are read in R when you load the package. This means you can make R read them manually. This is not really useful because LESYMAP needs other packages to run properly, but here is the code if you want to try:

# Step 1: download the package from github and unzip it.
# Step 2: source all R files
for (myf in Sys.glob('/path/to/LESYMAP/R/*.R')) source(myf) # sourcing R file
for (myf in Sys.glob('/path/to/LESYMAP/src/*.cpp')) Rcpp::sourceCpp(myf) # compiling C++ files

If nothing of these work, and you tried other solutions online, you can post an issue here, or on the ANTsR issues page. When you post an issue include as much detail as possible, don't hesitate to post the long logs from the installation process.