-
Notifications
You must be signed in to change notification settings - Fork 45
/
skeleton_habituationGWR.py
80 lines (62 loc) · 2.3 KB
/
skeleton_habituationGWR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Based on Tom Anastasio's habituationGWR.m
# this script sets up a very simple simulation of habituation
# of the Aplysia gill withdrawal reflex
#
# Modified for BU's RISE Practicum Comp Neuro lab by [email protected]
###############################
# import libraries with special
# functions needed in this script
###############################
import numpy as np
import matplotlib.pyplot as plt
###############################
# Define input stimulation
###############################
# TODO: Set a variable called stv to 4, this will define
# the weight of the connection from input to output
# stv =
dec=0.7 # set weight decrement for habituation
pls=[0, 0, 1, 0, 0] # set up a pulse
# TODO: then create a list of 6 pulses, called x, to use for input
# x =
v = stv # Set connection weight to start weight value
###############################
# Set up and run simulation
###############################
# TODO: Find the length of the input list (x)
# and assign its value to a new variable, nTs
# (which tracks the number of Time Steps)
# nTs =
# TODO: Create a numpy array named y, a 1D vector
# (row vector) padded with zeros, with one
# element per each time step
# y =
# TODO: use a for-loop to iterate
# through each time step in
# the input series and calculate
# the output at each time step. Ex:
# for ...
# then indent 4 spaces and write the equation that
# describes how each input value in the vector x is
# transformed to the output value in the vector y
# TODO: At each time step, check if the gill is receiving
# stimulation and, if it is, cause the connection
# weight to habituate (decrease)
###############################
# Plot the results
###############################
# Plot both the input series (vector x)
# and the resulting output series (vector y)
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax1.plot(x) #, color='white', antialiased=False, edgecolors='black', linewidth=1, shade=False, alpha=1)
ax1.set_ylabel('Input')
ax1.set_xlim(0, nTs)
ax1.set_ylim(0, 1.1)
ax2 = fig.add_subplot(212)
ax2.plot(y[0]) #, color='white', antialiased=False, edgecolors='black', linewidth=1, shade=False, alpha=1)
ax2.set_xlabel('Time step')
ax2.set_ylabel('Output')
ax2.set_xlim(0, nTs)
ax2.set_ylim(0, stv+0.5)
plt.show()