Skip to content

Commit

Permalink
Update code comments and figure key.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkp8000 committed May 7, 2019
1 parent 8c13096 commit 15f1a38
Show file tree
Hide file tree
Showing 17 changed files with 1,137 additions and 154 deletions.
67 changes: 43 additions & 24 deletions 1A_memory.ipynb

Large diffs are not rendered by default.

46 changes: 21 additions & 25 deletions 2A_replay.ipynb

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion 3A_param_regimes_sweep.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Explore parameter dependence of LTP-IE-induced spike sequences"
"# Parameter dependence of LTP-IE-induced spike sequences\n",
"## (Runs parameter sweeps for Fig A-C)\n",
"## (No manuscript figures in this notebook)"
]
},
{
Expand Down
9 changes: 9 additions & 0 deletions 3B_param_regimes_sweep_ext.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Parameter sweeps for replay speed analysis\n",
"## (Runs param sweep for Fig 3G)\n",
"## (No manuscript figures in this notebook)"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down
2 changes: 1 addition & 1 deletion 3C_param_regimes_sweep_tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Param sweep results tables"
"# Table view of basic param sweep results (speed not included)"
]
},
{
Expand Down
210 changes: 144 additions & 66 deletions 3D_param_regimes_sweep_stats.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion 3E_param_regimes_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Rerun examples simulations discovered in param search"
"# Rerun examples simulations discovered in param search\n",
"## (Auxiliary code; no manuscript figures in this notebook)"
]
},
{
Expand Down
50 changes: 47 additions & 3 deletions 3F_speed_psd_examples.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example speed analyses and power spectral densities\n",
"\n",
"## (Figure 3F, H)"
]
},
{
"cell_type": "code",
"execution_count": 35,
Expand Down Expand Up @@ -217,7 +226,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Speed overlay for two different parameter regimes\n",
"## Speed analysis for two different parameter regimes (Figure 3F)\n",
"Show overlaid replay speed calculations for example events."
]
},
Expand All @@ -230,6 +239,13 @@
"FAST: SWEEP 0: EXT_ID: 72: W_PC_PC = 0.026, L_PC_PC = 0.0582 (ORIG_SMLN_ID: 140)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run slow simulation"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down Expand Up @@ -293,6 +309,13 @@
"evts_slow = analysis.get_evts(rslt_slow, rslt_slow.a_params)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run fast simulation"
]
},
{
"cell_type": "code",
"execution_count": 5,
Expand Down Expand Up @@ -388,6 +411,13 @@
"print('Ends:', evts_fast[1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Calculate and plot speeds for two simulations (Figure 3F)"
]
},
{
"cell_type": "code",
"execution_count": 7,
Expand Down Expand Up @@ -462,14 +492,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Plot example PSDs"
"# Plot example PSDs (Figure 3H)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SWEEP 1"
"### Run simulation 1"
]
},
{
Expand Down Expand Up @@ -535,6 +565,13 @@
"rslt_0 = rerun_smln('PARAM_SWEEP_RESULTS_1_W_PC_PC_W_PC_INH.txt', 90, 0, d_smln=10, t_lim=(0, 10))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run simulation 2"
]
},
{
"cell_type": "code",
"execution_count": 58,
Expand Down Expand Up @@ -587,6 +624,13 @@
"rslt_1 = rerun_smln('PARAM_SWEEP_RESULTS_1_W_PC_PC_W_PC_INH.txt', 195, 1, d_smln=10, t_lim=(0, 10))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot PSDs (Figure 3H)"
]
},
{
"cell_type": "code",
"execution_count": 63,
Expand Down
6 changes: 3 additions & 3 deletions 4A_paired_associates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Build network with multiple trajecs embedded for associative mapping"
"# Demo associative memory through LTP-IE (Figure 4)"
]
},
{
Expand Down Expand Up @@ -48,7 +48,7 @@
" 'T_M_INH': 0.005, 'E_L_INH': -0.06, 'V_TH_INH': -0.05, 'V_R_INH': -0.06, 'T_R_INH': 0.002,\n",
" \n",
" # Inh. architecture\n",
" 'N_INH': 1200, # unused\n",
" 'N_INH': 1200,\n",
" 'W_INH_PC': 0.003, 'W_PC_INH': 0.00002,\n",
" \n",
" # gating inputs\n",
Expand Down Expand Up @@ -518,7 +518,7 @@
"metadata": {},
"source": [
"# Demo network with no spontaneous but successful triggered replay\n",
"For auxiliary purposes."
"## (For auxiliary purposes; no manuscript figures below)"
]
},
{
Expand Down
34 changes: 17 additions & 17 deletions 5A_complex_trajectory.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions 5B_nonspatial_associations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploration of non-spatial associations through LTP-IE"
"# Non-spatial associations through LTP-IE (Figure 5D-E)"
]
},
{
Expand Down Expand Up @@ -514,7 +514,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tests to check network for correct structure"
"# Auxiliary tests to check network for correct structure\n",
"## (No figure manuscripts below)"
]
},
{
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
Code for modeling rapid sequence embedding in spiking neural networks via heterosynaptic input modulation
Code for [Pang, R, and Adrienne L Fairhall. "Fast and Flexible Sequence Induction in Spiking Neural Networks Via Rapid Excitability Changes". bioRxiv 2019](https://www.biorxiv.org/content/10.1101/494310v1).

### Figure reproduction key

Figure 1: Notebook 1A

Figure 1-supplementary figure 1: Notebook 1A

Figure 2: Notebook 2A

Figure 2-supplementary figure 1: Notebook 2A

Figure 3A-C: Notebook 3D

Figure 3D-E: Notebook 2A

Figure 3F: Notebook 3F

Figure 3G: Notebook 3D

Figure 3H: Notebook 3F

Figure 3I-J: Notebook 2A

Figure 4: Notebook 4A

Figure 5A-C: Notebook 5A

Figure 5D-E: Notebook 5B
16 changes: 8 additions & 8 deletions T1_ntwk.ipynb

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions assoc/cxn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""
Functions for creating structured synaptic weight matrices
for sequence replay simulations.
"""
import numpy as np

from aux import lognormal_mu_sig

cc = np.concatenate


def apx_lattice(lb, ub, n, randomize):
"""
Arrange n points on an apx. lattice within a rectangle.
(Apx. b/c rectangle dims may not evenly divide n.)
"""
lb_x, lb_y = lb
ub_x, ub_y = ub

r_x = ub_x - lb_x
r_y = ub_y - lb_y

# get apx factors of n
n_x = np.sqrt((r_x/r_y) * n)
n_y = n/n_x

# get # pts per row
n_rows = int(np.round(n_y))
n_pts = [len(row) for row in np.array_split(np.arange(n), n_rows)]

# evenly distribute n_pts so that largest rows are not clumped at top
if len(set(n_pts)) > 1:

## split into groups of same n_pts
gp_0, gp_1 = [[ii for ii in n_pts if ii == i] for i in set(n_pts)]

if len(gp_1) > len(gp_0):
gp_0, gp_1 = gp_1, gp_0

## assign float "t" to each n_pt
n_0 = len(gp_0)
n_1 = len(gp_1)

ts_0 = [k * (n - 1) / (n_0 - 1) for k in range(n_0)]
ts_1 = [k * (n - 1) / (n_1 + 1) for k in range(1, n_1 + 1)]

ts = cc([ts_0, ts_1])

## sort n_pts according to ts
n_pts = cc([gp_0, gp_1])[np.argsort(ts)]

# assign (x, y) positions
ys_row = np.linspace(lb_y, ub_y, n_rows+2)[1:-1]

xs = []
ys = []

## add group of positions for each row
for y_row, n_pts_ in zip(ys_row, n_pts):

xs_ = list(np.linspace(lb_x, ub_x, n_pts_ + 2)[1:-1])
ys_ = list(np.repeat(y_row, len(xs_)))

xs.extend(xs_)
ys.extend(ys_)

xs = np.array(xs)
ys = np.array(ys)

if randomize:
shuffle = np.random.permutation(n)

xs = xs[shuffle]
ys = ys[shuffle]

return xs, ys


def _w_pc_pc_vs_d(d, p):
"""Return distance-dependent portion of w_pc_pc computation."""
assert np.all(d >= 0)

# decrease weights as squared exp of dist
w = p['W_PC_PC'] * np.exp(-d**2/(2*p['L_PC_PC']**2))

# set all weights below min weight th to 0
w[w < p['W_MIN_PC_PC']] = 0

return w


def make_w_pc_pc(pfxs, pfys, p):
"""Make PC-PC weight mat w/ weight increasing w/ proxim."""
n_pc = p['N_PC']

# build distance matrix
dx = np.tile(pfxs[None, :], (n_pc, 1)) - np.tile(pfxs[:, None], (1, n_pc))
dy = np.tile(pfys[None, :], (n_pc, 1)) - np.tile(pfys[:, None], (1, n_pc))
d = np.sqrt(dx**2 + dy**2)

# build weight matrix
return _w_pc_pc_vs_d(d, p)


def make_w_inh_pc(pfxs_inh, pfys_inh, pfxs_pc, pfys_pc, p):
"""
Make proximally biased PC->INH weight matrix.
"""
n_inh = p['N_INH']
n_pc = p['N_PC']

# build weight matrix
w_inh_pc = p['W_INH_PC'] * (np.random.rand(n_inh, n_pc) < 0.5).astype(float)
return w_inh_pc


def make_w_pc_inh(pfxs_pc, pfys_pc, pfxs_inh, pfys_inh, p):
"""
Make center-surround structured INH->PC weight matrix.
"""
n_pc = p['N_PC']
n_inh = p['N_INH']

# build weight matrix
w_pc_inh = p['W_PC_INH'] * (np.random.rand(n_pc, n_inh) < 0.5).astype(float)
return w_pc_inh
Loading

0 comments on commit 15f1a38

Please sign in to comment.