Code tested on MAC OS 10.15.7, MATLAB 2020a, and Python 3.9
- Install MATLAB, python, anaconda and jupyter notebook if these have not been installed
- Clone the directory
git clone https://github.com/nhat-le/switching-simulations
- Add the folder
block-hmm-simulations
to the MATLAB path - Install the following Python packages:
smartload
:python -m pip install [package_name]
- Install the following fork of the
ssm
package:https://github.com/nhat-le/ssm
(Note: modified from original packagehttps://github.com/lindermanlab/ssm
)
- To generate and fit the synthetic data, run
blockHMM_simulations.ipynb
.
Raw data files will be saved in the file blockhmm_simulated.mat
.
Data for the K-selection will be saved in blockhmm_synthetic_K_validation.mat
.
- Then run the MATLAB script
blockhmm_synthetic.m
to generate the figures.
Code for producing the figures in the paper can be run by calling the scripts figX.m
in MATLAB. Data required for
running the code is available here
Some jupyter notebooks are provided for data pre-processing:
-
session_average_parameters_per_animal.ipynb
generates the summary parameter fits of session-averaged transition functions of animals (Fig. 1) -
switching_world_classifier.ipynb
performs the forward simulations that generate results in Fig. 5, S3, S4 -
switching_world_classifier.ipynb
generates the evaluation dataset used to evaluate the classifier performance in Fig. 5f. -
src.run_multi_hmm_fits.py
is run to generate the HMM fits for each animal.