/
OlfactoryShapingV3.sc
95 lines (80 loc) · 1.93 KB
/
OlfactoryShapingV3.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
89
90
91
92
93
94
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Name: OlfactoryShaping
%%
%% Purpose: Runs a task where the animal must hold its nose
%% in the nosepoke for an extended period of time to
%% receive a reward from a reward well
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%port variables
int reward_port1 = 1
int reward_port2 = 2
int reward_identity = 0
int odor1 = 3
int odor2 = 4
%poke variables
int nose_in = 0
int nose_check_interval = 100
int nose_held_time
int nose_held_time_start
%reward variables
int reward_delivery_time = 500
int rewards_earned = 0
%loop variables
int not_exit_condition = 1;
function 2
do in 500
portout[odor1] = 0
portout[odor2] = 0
end
end;
function 1
not_exit_condition=1
while not_exit_condition == 1 do every nose_check_interval
if nose_in == 1 do
nose_held_time = clock() - nose_held_time_start
end
trigger(2)
if (nose_held_time >=500) && (nose_in == 1) do
disp('Nose held time is acceptable.')
disp(nose_held_time)
if reward_identity == odor1 do
portout[reward_port1] = 1
else if reward_identity == odor2 do
portout[reward_port2] = 1
end
not_exit_condition = 0
rewards_earned = rewards_earned + 1
disp(rewards_earned)
do in reward_delivery_time
portout[reward_port1] = 0
portout[reward_port2] = 0
disp('reward off')
end
end
end
end;
% Nose Poke Callback
callback portin[1] up
disp('Nose Poke!')
nose_in = 1
if reward_identity == odor2 do
portout[odor1] = 1
reward_identity = odor1
else do
portout[odor2] = 1
reward_identity = odor2
end
nose_held_time_start = clock()
trigger(1)
end;
% Nose Out Callback
callback portin[1] down
disp('Nose out!')
disp(nose_held_time)
nose_held_time = 0
nose_in = 0
not_exit_condition = 0
end;