Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooram committed Sep 13, 2015
1 parent 94d1b5a commit 3e52d3a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 99 deletions.
Binary file added .DS_Store
Binary file not shown.
122 changes: 24 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,25 @@
## Import modules
```python
import funs.util as util
import funs.engine as engine
import matplotlib.pyplot as plt
import numpy as np
```
## Initialize random number generator
```python
np.random.seed(123)
```
## Specify dataset & fitting parameters
```python
xdim = 2
ydim = 30
numTrials = 50
trialDur = 200 # in ms
binSize = 20 # in ms
maxEMiter = 100
dOffset = 1 # controls firing rate
```
## Sample from the model (simulate a dataset)
```python
training_set = util.dataset(
seed = np.random.randint(10000),
xdim = xdim,
ydim = ydim,
numTrials = numTrials,
trialDur = trialDur,
binSize = binSize,
dOffset = dOffset,
fixTau = True,
fixedTau = np.linspace(0.1,0.5,xdim),
drawSameX = True)
```
__Output:__
```
+------------- Simulated Dataset Options -------------+
| Dimensionality of Latent State: 2 |
| Dimensionality of Observed State (# neurons): 30 |
| Duration of trials (ms): 200 |
| Size of bins (ms): 20 |
| Number of Trials: 50 |
+-----------------------------------------------------+
Sampling trial 50 ...
Average firing rate per neuron in this dataset: 65.003 Hz.
```
## Initialize parameters using Poisson-PCA
```python
initParams = util.initializeParams(xdim, ydim, training_set)
```
## Fit using vanilla (batch) EM
```python
fitBatch = engine.PPGPFAfit(
experiment = training_set,
initParams = initParams,
inferenceMethod = 'laplace',
EMmode = 'Batch',
maxEMiter = maxEMiter)
```
__Output:__
```
+-------------------- Fit Options --------------------+
| Dimensionality of Latent State: 2 |
| Dimensionality of Observed State (# neurons): 30 |
| EM mode: Batch |
| Max EM iterations: 100 |
| Inference Method: laplace |
+-----------------------------------------------------+
Iteration: 100 of 100, nPLL: = -224.6181
This dataset is a simulated dataset.
Processing performance against ground truth parameters...
```
# Poisson-GPFA

This package is written by:
* Hooram Nam, `hooramnam@openmailbox.org`
* Jakob Macke, `jakob.macke@caesar.de`

This repository contains different methods for the Gaussian process model withPoisson observations. It has been developed and implemented with the goal of modelling spike-train recordings from neural populations, but some of the methods will be applicable more generally.

In particular, the repository includes methods for

* Laplace approximation for state-inference
* Variational method for state-inference
* Expectation maximisation for parameter learning, using Laplace or Variational inference
* Full EM, where all available trials are processed in each iteration
* Variants of stochastic EM, where a subset of avilable trials are processed in each iteration

## Usage

To get started the the example script either by `python example.py` in bash or`run example.py` inside iPython. The software is developed within the Anaconda python 3 environment.

If you notice a but, watnt to request a feature, or have a question or feedback, please make use of the issue-tracking capabilities of the repository. We love to hear from people using our code -- please send an email to info@mackelab.org.

The code in this repository is a work in progress. This work is published under the GNU General Public License. The code is provided "as is" and has not warranty whatsoever.


## Fit using online EM
```python
fitOnline = engine.PPGPFAfit(
experiment = training_set,
initParams = initParams,
EMmode = 'Online',
maxEMiter = maxEMiter,
inferenceMethod = 'laplace',
batchSize = 5)
```
__Output:__
```
+-------------------- Fit Options --------------------+
| Dimensionality of Latent State: 2 |
| Dimensionality of Observed State (# neurons): 30 |
| EM mode: Online |
| Max EM iterations: 100 |
| Inference Method: laplace |
| Online Param Update Method: `diag` |
| Batch size (trials): 5 |
+-----------------------------------------------------+
Iteration: 100 of 100, nPLL: = -226.2654
This dataset is a simulated dataset.
Processing performance against ground truth parameters...
```
Binary file added data/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@
inferenceMethod = 'laplace',
batchSize = 5)

# Make plots
training_set.plotTrajectory();plt.show()
fitBatch.plotParamSeq()
fitOnline.plotParamSeq();plt.show()

fitBatch.plotTrajectory()
fitOnline.plotTrajectory();plt.show()
fitOnline.plotTrajectory();plt.show()
Binary file added funs/.DS_Store
Binary file not shown.

0 comments on commit 3e52d3a

Please sign in to comment.