Skip to content

Commit dc4c916

Browse files
Merge pull request #118 from colleenjg/cjg-dev
Changed how firingrate is scaled to maximum for BVCs.
2 parents 906aab5 + 009dabf commit dc4c916

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

ratinabox/Neurons.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,8 @@ class BoundaryVectorCells(VectorCells):
15421542
"n": 10,
15431543
"name": "BoundaryVectorCells",
15441544
"dtheta": 2, #angular resolution in degrees used for integration over all angles (smaller is more accurate but slower)
1545-
"max_fr":1.0, # note the max_fr of a BVC is environment-dependent so is epirically estimated at initialisation by calculating the firing rate at all points in the environment, this can lead to small overshoots (see issue #110 for discussion)
1546-
"min_fr":0.0,
1545+
"max_fr": 1.0, # note the max_fr of a BVC is now computed analytically, and therefore reflects its maximal activity, regardless of the actual environment (see issue #110 for discussion)
1546+
"min_fr": 0.0,
15471547
}
15481548

15491549
def __init__(self, Agent, params={}):
@@ -1587,17 +1587,13 @@ def __init__(self, Agent, params={}):
15871587
self.test_directions = np.array(test_directions)
15881588
self.test_angles = np.array(test_angles)
15891589

1590-
1591-
# calculate normalising constants for BVS firing rates in the current environment. Any extra walls you add from here onwards you add will likely push the firingrate up further.
1592-
locs = self.Agent.Environment.discretise_environment(dx=0.04)
1593-
locs = locs.reshape(-1, locs.shape[-1])
1594-
1595-
self.cell_fr_norm = np.ones(self.n) #value for initialization
1596-
with warnings.catch_warnings():
1597-
warnings.simplefilter("ignore")
1598-
# ignores the warning raised during initialisation of the BVCs
1599-
cell_fr_norm = np.max(self.get_state(evaluate_at=None, pos=locs), axis=1)
1600-
self.cell_fr_norm = (cell_fr_norm - self.min_fr) / (self.max_fr - self.min_fr)
1590+
# calculate maximum possible firing rates for each BVC to use as normalization values.
1591+
self.cell_fr_norm = utils.von_mises(
1592+
theta=self.test_angles.reshape(1, -1),
1593+
mu=0,
1594+
sigma=self.sigma_angles.reshape(-1, 1),
1595+
norm=1,
1596+
).sum(axis=1)
16011597

16021598
# list of colors for each cell, just used by `.display_vector_cells()` plotting function
16031599
color = np.array(matplotlib.colors.to_rgba(self.color if self.color is not None else "C1")).reshape(1,-1)

0 commit comments

Comments
 (0)