Installing wholebrain on Ubuntu/Debian

  1. Install R, FFTW and OpenCV 3
  2. Install STAN from within R
  3. Install wholebrain from within R

Install R, FFTW and OpenCV 3

Install from terminal using apt:

sudo apt-get install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev
sudo apt-get -y install r-base
sudo apt-get install fftw3 fftw3-dev pkg-config

WholeBrain requires OpenCV 3.0.0 or higher, currently sudo apt-get for opencv will install 2.4 which is missing several key functions.

This is how you compile OpenCV 3.0.0 or higher form source on debian/ubuntu:

Install required and recommended packages:

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Download OpenCV 3.0.0 source:

sudo apt-get install -y unzip wget
cd ~
cd opencv-3.0.0

Make a build/release directory:

mkdir release
cd release

Use cmake to make a make-file and then compile:

make -j4
sudo make install

Fix -lippicv linking error that will otherwise happen during R installation:

sudo cp ~/opencv-3.0.0/3rdparty/ippicv/unpack/ippicv_lnx/lib/intel64/libippicv.a /usr/local/lib
sudo ldconfig

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);


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')