Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Reaction-time modeling with Gaussian process models

This repository contains code to analysis reaction-time from experimental data collected by Ivana Orsolic.

This code accompanies the paper Mesoscale cortical dynamics reflect the interaction of sensory evidence and temporal expectation during perceptual decision-making, Ivana Orsolic, Maxime Rio, Thomas D. Mrsic-Flogel, Petr Znamenskiy (


To retrieve the code, just clone the repository:

git clone

To run the analysis code, you will need the following to be installed on your computer:

  • python 3
  • pipenv
  • cuda (to use tensorflow with gpu computations)

The remaining dependencies can be installed from the command line in a virtual environment, using pipenv:

pipenv install  # create a virtual environment and populate it
pipenv install --dev  # install development related dependencies
pipenv shell  # spawn a shell in the virtual environment

Remark: A virtual environment is a good practice to isolate the code and its dependencies from your system.

Getting started

You can either:

  • run snakemake in the top folder to compute all analyses (fitting, scores, figures, ...)
  • run any of the python scripts in src folder to test different parameters.

Scripts have a -h/--help flag to provide more information about the available options, expected input files and output files.

To reproduce the figures from the paper, you will also need the corresponding data available on figshare. Unzip the data and results folders directly into the repository folder.

Code organisation

Provided scripts in src folder are:

  • generates the figures for the paper,
  • fits the parameters of a Gaussian process model on behavioral data,
  • estimates predictive distributions from fitted models,
  • computes scores for different models and output figures for comparison purpose,
  • samples from the models to check if they realistically capture the behavior,
  • transforms models with variational posteriors for the kernel hyperparameters into models with point estimates,
  • displays the variational posterior distributions of the kernel hyperparameters,
  • is a dummy example of a GP model with ADVI inference applied on the kernel hyperparameters.

The remaining .py files are modules containing common code.


Installing cuda reliably can tricky, here is a summary of command lines to achieve it on an Ubuntu 16.04:

sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
sudo apt-key add /var/cuda-repo-9-0-local/
sudo apt update
sudo apt install cuda
sudo dpkg -i libcudnn7*9.0*

It assumes that you downloaded cuda and cudnn packages from Nvidia website.

Another common issue is the number of threads used by script. This can be due to the openblas library linked with your numpy package. You can limit this using the OPENBLAS_NUM_THREADS environment variable as follows:

OPENBLAS_NUM_THREADS=4 src/ <ouput folder> <input datasets> ...

Troubleshooting (advanced)

If you have a recent GPU requiring cuda 10.0, you will have to recompile tensorflow, as it's compiled for cuda 9.0 (2018/11/20).

First, install cuda 10.0 and libcudnn7 from Nvidia. The following steps are described on tensorflow website and bazel website. The bug in bazel 0.19 is described in an issue.

In a terminal, install bazel:

sudo apt-get install openjdk-8-jdk  # install JDK 8
echo "deb [arch=amd64] stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel

Then clone tensorflow:

git clone
cd tensorflow
git checkout r1.9

Populate a virtual environment with dependencies:

python3 -m venv .venv
. .venv/bin/activate
pip install -U pip six numpy wheel mock
pip install -U keras_applications==1.0.5 --no-deps
pip install -U keras_preprocessing==1.0.3 --no-deps

Test, configure and build tensorflow:

bazel test -c opt -- //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/lite/...
cat tools/bazel.rc .tf_configure.bazelrc > tf_configure.bazelrc; mv tf_configure.bazelrc .tf_configure.bazelrc  # needed for bazel 0.19
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

The final package is saved as /tmp/tensorflow_pkg/tensorflow-1.9.0-<tags>.whl and can be installed with pip install <package path>. You should uninstall any version of tensorflow before, e.g. using pip uninstall tensorflow-gpu.

You can’t perform that action at this time.