This is the readme for the models and data associated with the paper:

Powers AR III, Mathys CH, Corlett PR (2017) Pavlovian conditioning-induced hallucinations result from overweighting of perceptual priors. Science357(6351):596-600 [PubMed]

These files were contributed by Albert Powers.

System requirements:

Use of this code requires installation of MATLAB ( and the tapas toolbox ( as well as data generated by the Conditioned Hallucinations task 1.0.


Documentation regarding the input and output variables are found in individual functions.

The following basic classes of functions are included (input: CH data structure):

ch_hgf_analysis - basic analysis of CH data with no constraints on parameters.

ch_hgf_calcx - calculation of x trajectory

ch_hgf_sim - generation of synthetic data using parameters fit from CH data.

The sub-types of functions (_startpoints, _nu, _nu2) correspond to functions that constrain initial model parameters by: 1) decreased precision on prior for trajectory starting points; 2) adding the variable nu that encodes relative weighting of priors versus sensory evidence precision in leading to decision-making; and 3) decreased precision on prior for nu.


To run the basic HGF analysis on data from participant ch_hc_03, load this participant’s data into the workspace:


Then run ch_hgf_analysis using this data structure and store the results as either a separate variable or a newly-updated version of ch_hc_03 (as is done below):

ch_hc_03 = ch_hgf_analysis(ch_hc_03);

Note that this also produces a figure depicting belief trajectories mu1-mu3, similar to Fig 3 BCD in the paper:


Note: Reminder to beforehand add the paths to the analysis folder in this archive and the paths to the tapas toolbox by running the tapas_init command.

These commands can look like

cd HGF/analysis
addpath('/Users/yourusername/Documents/MATLAB/tapas-master') % or whereever you installed tapas