Installing wholebrain on Archlinux

  1. Install R, OpenCV, and FFTW
  2. Build and install gcc-4.9.3
  3. Tell R to use gcc-4.9 and enable C++11 support
  4. Install STAN from within R
  5. Install wholebrain from within R

Install R, OpenCV and FFTW

R is in the official Archlinux repositories. Install it with:

sudo pacman -S r
sudo pacman -S opencv
sudo pacman -S fftw

Currently (Nov. 2015) this will install OpenCV 2.4 and not OpenCV 3. We recommend using OpenCV 3. See https://www.archlinux.org/todo/opencv-300/ for further updates.
Alternatively build OpenCV 3.0.0 from source:
http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/linux_install/linux_install.html
We highly recommend building OpenCV 3.0.0 since we most likely will add features from OpenCV 3.0.0 such as High Dynamic Range Imaging in the future.

Build and install gcc-4.9.3

At the time of writing, Arch is shipping gcc version 5.2.0. wholebrain did not compile with this version. gcc 4.9.3 can be build from AUR, and successfully compiles wholebrain. E.g. with cower:

cower -d gcc49
cd gcc49
makepkg -s
sudo pacman -U gcc49-4.9.3-1-x86_64.pkg.tar.xz

For more detailed instructions on how to use AUR to build software please refer to the Arch Wiki.

Tell R to use gcc-4.9 and enable C++11 support

Open up a new session of R.

R 

To change compiler flags for R when building packages from source you can change the .Makevars file within R console by running the following R commands:

dotR <- file.path(Sys.getenv("HOME"), ".R") #set file path to R path, ~/.R
if (!file.exists(dotR)) dir.create(dotR) #if R path does not exist create it.
M <- file.path(dotR, "Makevars") #.Makevars
if (!file.exists(M)) file.create(M) #check if .Makevars exist otherwise create it
cat("\nCXX=g++-4.9\n\nCXXFLAGS+=-std=c++11\nCXXFLAGS=-O3", file = M, sep = "\n", append = TRUE) #append flags to makevars

Install STAN from within R

Open up a new session of R.

R 

Set the number of processes to use for the build to the number of cores on your machine you want to devote to the build. For example, if you are running a quad core machine and want to use 4 processes, execute the following in R.

Sys.setenv(MAKEFLAGS = "-j4")

Install the latest version of rstan from CRAN:

install.packages("rstan", dependencies = TRUE)

If the installation worked restart R.
Then tryout that STAN works by running the following code form within R.


library(rstan)
model<-'data{
int N;
real y[N];
}
parameters{
real mu;
real sigma;
}
model{
y ~ normal(mu, sigma);
}'

model_data<- list( y = rnorm(10), N = 10  )

fit<-stan(model_code = model, data = model_data, iter = 4000, chains =4)

la<-extract(fit)

hist(la$mu)

If it produces a histogram of the posterior samples of the mean parameter mu everything works.

Install wholebrain from within R

Run R:

R 

Compile and install wholebrain using the devtools R package:

if (!require(devtools)) { 
    install.packages("devtools") 
}

devtools::install_github("tractatus/wholebrain") 

Try running wholebrain:

library(wholebrain) 
filename<-system.file('sample_tiles/rabiesEGFP.tif', package='wholebrain') 
filter<-createfilter(filename)