An Active Efficient Coding Model

This is the MATLAB code for the Active Efficient Coding model introduced in:

Eckmann S, Klimmasch L, Shi BE, Triesch J (2020) Active efficient coding explains the development of binocular vision and its failure in amblyopia. Proc Natl Acad Sci U S A

It simulates an agent that self-calibrates vergence and accommodation eye movements in a simple visual environment. All algorithms are explained in detail in the main manuscript and the supplementary material of the paper.


Copy and rename one of the following files to ‘config.m’

filename description
config-hc.m healthy case without visual impairments
config-aniso.m anisometropic case with hyperopic right eye
config-mono.m monovision case with hyperopic right and myopic left eye

To start a simulation, open the main directory in MATLAB and type the following command:


Here, ‘INFO’ is an arbitrary description of the experiment.
When the simulation finished, all files relevant to the simulation can be found in:


A few plots are automatically generated that provide some basic insight.
The model object that includes the data recorded during the simulation as well as the trained reinforcement learning agents and all cortical receptive fields, is saved as ‘model.mat’.

Important Files

filename description
sim.m starts simulation, generates visual environment, renders visual input and interocular suppression
config.m main config file, defines visual impairment and all parameters of the model
model.m main model class, holds sparse coding and reinforcement learning instances, holds recordings collected during simulation
SparseCoding.m class file for the efficient coding algorithm
ReinforcementLearning.m class file for the reinforcement learning agents

Contribution & Acknowledgements

Over the last decade, more than three generations of graduate and post-graduate students in the research groups of Prof. Jochen Triesch and Prof. Bertram E. Shi have contributed to this and related projects with support from various funding agencies.

Among others:

This specific project was supported by the German Federal Ministry of Education and Research under Grants 01GQ1414 and 01EW1603A, the Hong Kong Research Grants Council under Grant 618713, and the Quandt Foundation.

Development Environment

All code was written and/or tested in MATLAB version R2017a (64-bit) under Kubuntu 18.04


This project is made available under a CC-BY-NC-ND 4.0 International license.