Hierarchical Gaussian Filter (HGF) model of conditioned hallucinations task (Powers et al 2017)

 Download zip file 
Help downloading and running models
Accession:229278
This is an instantiation of the Hierarchical Gaussian Filter (HGF) model for use with the Conditioned Hallucinations Task.
Reference:
1 . Powers AR, Mathys C, Corlett PR (2017) Pavlovian conditioning-induced hallucinations result from overweighting of perceptual priors. Science 357:596-600 [PubMed]
Citations  Citation Browser
Model Information (Click on a link to find other models with that property)
Model Type:
Brain Region(s)/Organism:
Cell Type(s):
Channel(s):
Gap Junctions:
Receptor(s):
Gene(s):
Transmitter(s):
Simulation Environment: MATLAB;
Model Concept(s): Hallucinations;
Implementer(s): Powers, Al [albert.powers at yale.edu]; Mathys, Chris H ;
/
HGF
analysis
hgfToolBox_condhalluc1.4
README
COPYING *
example_binary_input.txt
example_categorical_input.mat
example_usdchf.txt
Manual.pdf
tapas_autocorr.m
tapas_bayes_optimal.m
tapas_bayes_optimal_binary.m
tapas_bayes_optimal_binary_config.m
tapas_bayes_optimal_binary_transp.m
tapas_bayes_optimal_categorical.m
tapas_bayes_optimal_categorical_config.m
tapas_bayes_optimal_categorical_transp.m
tapas_bayes_optimal_config.m
tapas_bayes_optimal_transp.m
tapas_bayes_optimal_whatworld.m
tapas_bayes_optimal_whatworld_config.m
tapas_bayes_optimal_whatworld_transp.m
tapas_bayes_optimal_whichworld.m
tapas_bayes_optimal_whichworld_config.m
tapas_bayes_optimal_whichworld_transp.m
tapas_bayesian_parameter_average.m
tapas_beta_obs.m
tapas_beta_obs_config.m
tapas_beta_obs_namep.m
tapas_beta_obs_sim.m
tapas_beta_obs_transp.m
tapas_boltzmann.m
tapas_cdfgaussian_obs.m
tapas_cdfgaussian_obs_config.m
tapas_cdfgaussian_obs_transp.m
tapas_condhalluc_obs.m
tapas_condhalluc_obs_config.m
tapas_condhalluc_obs_namep.m
tapas_condhalluc_obs_sim.m
tapas_condhalluc_obs_transp.m
tapas_condhalluc_obs2.m
tapas_condhalluc_obs2_config.m
tapas_condhalluc_obs2_namep.m
tapas_condhalluc_obs2_sim.m
tapas_condhalluc_obs2_transp.m
tapas_Cov2Corr.m
tapas_datagen_categorical.m
tapas_fit_plotCorr.m
tapas_fit_plotResidualDiagnostics.m
tapas_fitModel.m
tapas_gaussian_obs.m
tapas_gaussian_obs_config.m
tapas_gaussian_obs_namep.m
tapas_gaussian_obs_sim.m
tapas_gaussian_obs_transp.m
tapas_hgf.m
tapas_hgf_ar1.m
tapas_hgf_ar1_binary.m
tapas_hgf_ar1_binary_config.m
tapas_hgf_ar1_binary_namep.m
tapas_hgf_ar1_binary_plotTraj.m
tapas_hgf_ar1_binary_transp.m
tapas_hgf_ar1_config.m
tapas_hgf_ar1_mab.m
tapas_hgf_ar1_mab_config.m
tapas_hgf_ar1_mab_plotTraj.m
tapas_hgf_ar1_mab_transp.m
tapas_hgf_ar1_namep.m
tapas_hgf_ar1_plotTraj.m
tapas_hgf_ar1_transp.m
tapas_hgf_binary.m
tapas_hgf_binary_condhalluc_plotTraj.m
tapas_hgf_binary_config.m
tapas_hgf_binary_config_startpoints.m
tapas_hgf_binary_mab.m
tapas_hgf_binary_mab_config.m
tapas_hgf_binary_mab_plotTraj.m
tapas_hgf_binary_mab_transp.m
tapas_hgf_binary_namep.m
tapas_hgf_binary_plotTraj.m
tapas_hgf_binary_pu.m
tapas_hgf_binary_pu_config.m
tapas_hgf_binary_pu_namep.m
tapas_hgf_binary_pu_tbt.m
tapas_hgf_binary_pu_tbt_config.m
tapas_hgf_binary_pu_tbt_namep.m
tapas_hgf_binary_pu_tbt_transp.m
tapas_hgf_binary_pu_transp.m
tapas_hgf_binary_transp.m
tapas_hgf_categorical.m
tapas_hgf_categorical_config.m
tapas_hgf_categorical_namep.m
tapas_hgf_categorical_norm.m
tapas_hgf_categorical_norm_config.m
tapas_hgf_categorical_norm_transp.m
tapas_hgf_categorical_plotTraj.m
tapas_hgf_categorical_transp.m
tapas_hgf_config.m
tapas_hgf_demo.m
tapas_hgf_demo_commands.m
tapas_hgf_jget.m
tapas_hgf_jget_config.m
tapas_hgf_jget_plotTraj.m
tapas_hgf_jget_transp.m
tapas_hgf_namep.m
tapas_hgf_plotTraj.m
tapas_hgf_transp.m
tapas_hgf_whatworld.m
tapas_hgf_whatworld_config.m
tapas_hgf_whatworld_namep.m
tapas_hgf_whatworld_plotTraj.m
tapas_hgf_whatworld_transp.m
tapas_hgf_whichworld.m
tapas_hgf_whichworld_config.m
tapas_hgf_whichworld_namep.m
tapas_hgf_whichworld_plotTraj.m
tapas_hgf_whichworld_transp.m
tapas_hhmm.m
tapas_hhmm_binary_displayResults.m
tapas_hhmm_config.m
tapas_hhmm_transp.m
tapas_hmm.m
tapas_hmm_binary_displayResults.m
tapas_hmm_config.m
tapas_hmm_transp.m
tapas_kf.m
tapas_kf_config.m
tapas_kf_namep.m
tapas_kf_plotTraj.m
tapas_kf_transp.m
tapas_logit.m
tapas_logrt_linear_binary.m
tapas_logrt_linear_binary_config.m
tapas_logrt_linear_binary_minimal.m
tapas_logrt_linear_binary_minimal_config.m
tapas_logrt_linear_binary_minimal_transp.m
tapas_logrt_linear_binary_namep.m
tapas_logrt_linear_binary_sim.m
tapas_logrt_linear_binary_transp.m
tapas_logrt_linear_whatworld.m
tapas_logrt_linear_whatworld_config.m
tapas_logrt_linear_whatworld_transp.m
tapas_ph_binary.m
tapas_ph_binary_config.m
tapas_ph_binary_namep.m
tapas_ph_binary_plotTraj.m
tapas_ph_binary_transp.m
tapas_quasinewton_optim.m
tapas_quasinewton_optim_config.m
tapas_riddersdiff.m
tapas_riddersdiff2.m
tapas_riddersdiffcross.m
tapas_riddersgradient.m
tapas_riddershessian.m
tapas_rs_belief.m
tapas_rs_belief_config.m
tapas_rs_precision.m
tapas_rs_precision_config.m
tapas_rs_precision_whatworld.m
tapas_rs_precision_whatworld_config.m
tapas_rs_surprise.m
tapas_rs_surprise_config.m
tapas_rs_transp.m
tapas_rs_whatworld_transp.m
tapas_rw_binary.m
tapas_rw_binary_config.m
tapas_rw_binary_dual.m
tapas_rw_binary_dual_config.m
tapas_rw_binary_dual_plotTraj.m
tapas_rw_binary_dual_transp.m
tapas_rw_binary_namep.m
tapas_rw_binary_plotTraj.m
tapas_rw_binary_transp.m
tapas_sgm.m
tapas_simModel.m
tapas_softmax.m
tapas_softmax_2beta.m
tapas_softmax_2beta_config.m
tapas_softmax_2beta_transp.m
tapas_softmax_binary.m
tapas_softmax_binary_config.m
tapas_softmax_binary_namep.m
tapas_softmax_binary_sim.m
tapas_softmax_binary_transp.m
tapas_softmax_config.m
tapas_softmax_namep.m
tapas_softmax_sim.m
tapas_softmax_transp.m
tapas_squared_pe.m
tapas_squared_pe_config.m
tapas_squared_pe_transp.m
tapas_sutton_k1_binary.m
tapas_sutton_k1_binary_config.m
tapas_sutton_k1_binary_plotTraj.m
tapas_sutton_k1_binary_transp.m
tapas_unitsq_sgm.m
tapas_unitsq_sgm_config.m
tapas_unitsq_sgm_mu3.m
tapas_unitsq_sgm_mu3_config.m
tapas_unitsq_sgm_mu3_transp.m
tapas_unitsq_sgm_namep.m
tapas_unitsq_sgm_sim.m
tapas_unitsq_sgm_transp.m
                            
function c = tapas_hhmm_config
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Contains the configuration for the hierarchical hidden Markov model (HHMM)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This implementation follows the exposition in Fine, Singer, & Tishby (1998). The hierarchical
% hidden Markov model: Analysis and Applications. Machine Learning, 32, 41–62.
%
% The structure returned by fitModel() contains the estimated transition matrices A (responsible for
% horizontal transitions), the vertical transition probabilities V and the outcome contingencies B.
%
% The configuration is best explained by way of example, so please see the template below. Briefly,
% the model tree is configured as a cell array N of nodes. Each node therefore has its unique id,
% namely its position in that array. Id 1 (the first position) is reserved for the root node. Apart
% from that, the id has nothing to do with the structure of the tree. That is defined in the
% individual nodes by setting N{id}.parent and N{id}.children. While setting both is strictly
% speaking redundant, it is required because it is convenient and provides an additional basis
% for sanity checking. That said, while some sanity checking is done, it is your responsibility
% to define a tree that makes sense. The nodes at the bottom of the tree (the ones generating
% output) are called production nodes.
%
% Estimated quantities are the vertical transition probabilities V (called pi in Fine et
% al. (1998)), the transition matrices A, and the outcome contingencies B of the production
% nodes. Each node, except the root, has N{id}.V, containing the prior for V (Gaussian in
% logit space) defined by the mean logitmu and the variance (not standard deviation)
% logitsa. Likewise, each node, except production nodes, has N{id}.A, containing the prior of the
% transition matrix between its children, also in logit space. Production nodes have N{id}.B, the
% outcome contingency vector. V is an empty array for the root node, A is empty for production
% nodes, and B is empty for non-production nodes.
%
% --------------------------------------------------------------------------------------------------
% Copyright (C) 2013 Christoph Mathys, TNU, UZH & ETHZ
%
% This file is part of the HGF toolbox, which is released under the terms of the GNU General Public
% Licence (GPL), version 3. You can redistribute it and/or modify it under the terms of the GPL
% (either version 3 or, at your option, any later version). For further details, see the file
% COPYING or <http://www.gnu.org/licenses/>.

% Config structure
c = struct;

% Model name
c.model = 'hhmm';

% Number of possible outcomes
c.n_outcomes = 2;

% Model tree (N is for node)
%
% The root node is the first element of the cell array of nodes
c.N{1} = struct;

% The root node has no parent
c.N{1}.parent = [];

% These nodes are the root's children
c.N{1}.children = [2, 3];

% The vertical transition probability into the root node is empty
c.N{1}.V = [];

% Prior of transition matrix A between the children of the root node.
% Its elements have Gaussian priors in logit space. Inf in logit space corresponds to 1 in native
% space; likewise, -Inf corresponds to 0.
c.N{1}.A.logitmu = [-Inf, Inf; Inf, -Inf];
c.N{1}.A.logitsa = [   0,   0;   0,    0];

% The outcome contingencies B of the root node are empty because the root is not a production
% node
c.N{1}.B = [];

% The further nodes follow the same pattern (see explanation at the top of the file)
% Adapt as needed below. Description of the nodes is just an example.

% The low volatility regime
c.N{2}.parent = 1;
c.N{2}.children = [4, 5];
c.N{2}.V.logitmu = logit(0.5,1);
c.N{2}.V.logitsa = 0;
c.N{2}.A.logitmu = [logit(0.9,1), logit(0.05,1); logit(0.05,1), logit(0.9,1)];
c.N{2}.A.logitsa = [           0,           0.1;           0.1,            0];
c.N{2}.B = [];

% The high volatility regime
c.N{3}.parent = 1;
c.N{3}.children = [6, 7];
c.N{3}.V.logitmu = logit(0.5,1);
c.N{3}.V.logitsa = 0;
c.N{3}.A.logitmu = [logit(0.6,1), logit(0.35,1); logit(0.35,1), logit(0.6,1)];
c.N{3}.A.logitsa = [           0,           0.1;           0.1,            0];
c.N{3}.B = [];

% Black urn (low volatility)
c.N{4}.parent = 2;
c.N{4}.children = [];
c.N{4}.V.logitmu = logit(0.5,1);
c.N{4}.V.logitsa = 0;
c.N{4}.A = [];
c.N{4}.B = [0.15, 0.85];

% White urn (low volatility)
c.N{5}.parent = 2;
c.N{5}.children = [];
c.N{5}.V.logitmu = logit(0.5,1);
c.N{5}.V.logitsa = 0;
c.N{5}.A = [];
c.N{5}.B = [0.85, 0.15];

% Black urn (high volatility)
c.N{6}.parent = 3;
c.N{6}.children = [];
c.N{6}.V.logitmu = logit(0.5,1);
c.N{6}.V.logitsa = 0;
c.N{6}.A = [];
c.N{6}.B = [0.15, 0.85];

% White urn (high volatility)
c.N{7}.parent = 3;
c.N{7}.children = [];
c.N{7}.V.logitmu = logit(0.5,1);
c.N{7}.V.logitsa = 0;
c.N{7}.A = [];
c.N{7}.B = [0.85, 0.15];

% END OF CONFIGURATION
% ~~~~~~~~~~~~~~~~~~~~

% Vectorize priors by walking through tree
mus = [];
sas = [];
for id = 1:length(c.N)
    if ~isempty(c.N{id}.V)
        mus = [mus, c.N{id}.V.logitmu];
        sas = [sas, c.N{id}.V.logitsa];
    end

    if ~isempty(c.N{id}.A)
        mus = [mus, c.N{id}.A.logitmu(:)'];
        sas = [sas, c.N{id}.A.logitsa(:)'];
    end
end


% Gather prior settings in vectors
c.priormus = mus;
c.priorsas = sas;

% Model function handle
c.prc_fun = @hhmm;

% Handle to function that transforms perceptual parameters to their native space
% from the space they are estimated in
c.transp_prc_fun = @hhmm_transp;

return;