]> git.armaanb.net Git - norepinephrine_wm.git/blob - norepinephrine_wm/newmodel.py
Initial commit
[norepinephrine_wm.git] / norepinephrine_wm / newmodel.py
1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
3
4 import numpy as np
5 import matplotlib.pyplot as plt
6 import nengo
7
8 # Refer to parameters.txt for documentation
9 dt = 0.001
10 t_cue = 1.0
11 cue_scale = 1.0
12 perceived = 0 # ???
13 time_scale = 0.4
14 steps = 100
15
16 class Alpha(object):
17     def __init__(self):
18         self.x = np.logspace(0, 3, steps)
19         self.y = 1 / (1 + (999 * np.exp(-0.1233 * (self.x / self.offset))))
20         
21         self.gain = []
22         self.bias = []
23         
24     def calcgb(self, gaind, biasd):
25         for i in range(steps):
26             y = self.y[i]
27             self.gain.append(1 + gaind * y)
28             self.bias.append(1 + biasd * y)
29
30     def plot(self):
31         plt.plot(self.x, self.y)
32
33         plt.xlabel("Norepinephrine concentration (nM)")
34         plt.ylabel("Activity (%)")
35         plt.title("Norepinepherine Concentration vs Neuron Activity in " + self.pretty)
36
37         plt.vlines(self.ki, 0, 1, linestyles="dashed")
38         plt.text(1.1 * self.ki, 0.1, "Affinity")
39
40         plt.hlines(0.5, 0, 1000, linestyles="dashed")
41         plt.text(1, 0.51, "50%")
42
43         plt.xscale("log")
44         gc = plt.gca()
45         gc.set_yticklabels(['{:.0f}%'.format(x * 100) for x in gc.get_yticks()])
46
47         plt.draw()
48         plt.savefig(self.__class__.__name__ + "-norep-activity.png", dpi=1000)
49         plt.show()
50         
51         #######################################################################
52         
53         plt.plot(self.x, self.gain)
54         
55         plt.xlabel("Norepinephrine concentration (nM)")
56         plt.ylabel("Gain")
57         plt.title("Concentration vs Gain in " + self.pretty)
58         
59         plt.draw()
60         plt.savefig(self.__class__.__name__ + "-concentration-gain.png", dpi=1000)
61         plt.show()
62         
63         #######################################################################
64         
65         plt.plot(self.x, self.bias)
66         
67         plt.xlabel("Norepinephrine concentration (nM)")
68         plt.ylabel("Bias")
69         plt.title("Concentration vs Bias in " + self.pretty)
70         
71         plt.draw()
72         plt.savefig(self.__class__.__name__ + "-concentration-bias.png", dpi=1000)
73         plt.show()
74
75 class Alpha1(Alpha):
76     def __init__(self):
77         self.ki = 330
78         self.offset = 5.895
79         self.pretty = u"α1 Receptor"
80         self.gaind = 0.1
81         self.biasd = 0.1
82         super().__init__()
83         
84     def calcgb(self):
85         super().calcgb(self.gaind, self.biasd)
86
87 class Alpha2(Alpha):
88     def __init__(self):
89         self.ki = 56
90         self.offset = 1
91         self.pretty = u"α2 Receptor"
92         self.gaind = -0.04
93         self.biasd = -0.02
94         super().__init__()
95         
96     def calcgb(self):
97         super().calcgb(self.gaind, self.biasd)
98
99 def main():
100     plt.style.use("ggplot")
101     
102     a1 = Alpha1()
103     a1.calcgb()
104     a1.plot()
105
106     a2 = Alpha2()
107     a2.calcgb()
108     a2.plot()
109
110 if __name__ == "__main__":
111     main()