GithubHelp home page GithubHelp logo

xianhui-he / glm-hmm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zashwood/glm-hmm

0.0 0.0 0.0 126 KB

Code to reproduce figures for "Mice alternate between discrete strategies during perceptual decision-making" from Ashwood, Roy, Stone, IBL, Churchland, Pouget and Pillow (2021)

Python 100.00%

glm-hmm's Introduction

glm-hmm

Code to reproduce figures in "Mice alternate between discrete strategies during perceptual decision-making" from Ashwood, Roy, Stone, IBL, Urai, Churchland, Pouget and Pillow (2020). Note: while this code reproduces the figures/analyses for our paper, the easiest way to get started applying the GLM-HMM to your own data, is with this notebook.

Code is ordered so that the IBL dataset discussed in the paper is preprocessed into the desired format by the scripts in "1_preprocess_data". Within this directory, run the scripts in the order indicated by the number at the beginning of the file name (i.e . run "1_download_data_begin_processing.py" first to obtain the IBL data locally and then run "2_create_design_mat.py" to obtain the design matrix used as input for all of the models discussed in our paper). Next , you can fit the GLM, lapse and GLM-HMM models discussed in the paper using the code contained in "2_fit_models". As discussed in the paper, the GLM should be run first as the GLM fit is used to initialize the global GLM-HMM (the model that is fit with data from all animals). The lapse model fits, while not used for any initialization purposes, should be run next so as to be able to perform model comparison with the global and individual GLM-HMMs. The global GLM-HMM should be run next, as it is used to initialize the models for all individual animals. Finally GLM-HMMs can be fit to the data from individual animals using the code in the associated directory.

Assuming that you have downloaded and preprocessed the datasets, and that you have fit all models on these datasets, you can reproduce the figures of our paper corresponding to the IBL dataset by running the code contained in "3_make_figures". In order to produce Figures 5 and 7, replace the IBL URL in the preprocessing pipeline scripts, with the URLs for the Odoemene et al. (2018) and Urai et al. (2017) datasets, and rerun the GLM, lapse and GLM-HMM models on these datasets before running the provided figure plotting code.

Before beginning, create a conda environment from the environment yaml file by running

conda env create -f environment.yml

Note: this may take a while as ibllib relies on OpenCV, and installing this can take a while. Activate this environment by running

conda activate glmhmm

We use version 0.0.1 of the Bayesian State Space Modeling framework from Scott Linderman's lab to perform GLM-HMM inference. Within the glmhmm environment, install the forked version of the ssm package available here. This is a lightly modified version of the master branch of the ssm package available at https://github.com /lindermanlab/ssm. It is modified so as to handle violation trials as described in Section 4 of our manuscript. In order to install this version of ssm, follow the instructions provided there, namely:

cd ssm
pip install numpy cython
pip install -e .

glm-hmm's People

Contributors

zashwood avatar jingyangke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.