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 for further updates.
Alternatively build OpenCV 3.0.0 from source:
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.


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.


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.

int N;
real y[N];
real mu;
real sigma;
y ~ normal(mu, sigma);

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

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



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

Install wholebrain from within R

Run R:


Compile and install wholebrain using the devtools R package:

if (!require(devtools)) { 


Try running wholebrain:

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