-
Notifications
You must be signed in to change notification settings - Fork 2
/
Linear_alternateWells_rewardFirstPoke_TESTNEWBEH.sc
89 lines (70 loc) · 1.99 KB
/
Linear_alternateWells_rewardFirstPoke_TESTNEWBEH.sc
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
81
82
83
84
85
86
87
88
% PROGRAM NAME: LINEAR TRACK ALTERNATION
% AUTHOR: MCZ
% DESCRIPTION:
% This program delivers reward from each reward well (on a linear track) when the beam is broken, and the animal successfully alternates from one well to the other. Reward delivery ceases after 1sec.
%CONSTANTS
int deliverPeriod= 500 % how long to deliver the reward
%VARIABLES
int count= 0 % blink count
int lastWell= 0 % last well
int currWell= 0 % current well
int rewardWell= 0 % reward well
int nowRewarding = 0 % keep track of reward being dispensed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTIONS
% -----------------------
% Function Name: Reward
% Description: This function administers reward to a marked well.
% -----------------------
function 1
nowRewarding = 1 % nowRewarding
portout[rewardWell]=1 % reward
do in deliverPeriod % NOTE: USING A VARIABLE HERE WORKS
portout[rewardWell]=0 % reset reward
nowRewarding=0 % no longer rewarding
end
end;
% -----------------------
% Function Name: Reward first poke
% Description: This function adminsters reward to the first poke.
% -----------------------
function 2
if lastWell==0 do
rewardWell=currWell
trigger(1)
end
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CALLBACKS -- EVENT-DRIVEN TRIGGERS
callback portin[1] up
disp('portin1 up')
currWell=1 % well currently active
trigger(2)
if lastWell == 2 do
disp('Poke 1 rewarded')
rewardWell=3 % dispense reward from here
trigger(1)% trigger reward
else do
disp('Poke 2 not rewarded')
end
end;
callback portin[1] down
disp('portin1 down')
lastWell=1 % well left, now last well
end;
callback portin[2] up
disp('portin2 up')
currWell=2 % well currently active
trigger(2)
if lastWell == 1 do
disp('Poke 2 rewarded')
rewardWell=4 % dispense reward from here
trigger(1) % trigger reward
else do
disp('Poke 2 not rewarded')
end
end;
callback portin[2] down
disp('portin2 down')
lastWell=2 % well left, now last well
end;