forked from restrepd-zz/dropc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdropcFinalValveOK_purge.m
executable file
·162 lines (117 loc) · 4.38 KB
/
dropcFinalValveOK_purge.m
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
function finalValveOK = dropcFinalValveOK_purge(handles)
%Opens final valve, purge valve odor on and finds out whtehr the mouse stays in the
%odor sampling area
start_toc=toc;
noSamples=0;
noSamplesMouseOn=0;
if (handles.dropcProg.typeOfOdor==4)
%During begin fvtime increases monotonically as a function of trialIndex
group=floor(handles.dropcData.trialIndex/20)+1;
if (group<=6)
fvtime=(group-2)*handles.dropcProg.fvtime/5;
else
fvtime=handles.dropcProg.fvtime;
end
else
%Otherwise, fvtime falls randomly between 1 and 1.5
fvtime = 0.666666*handles.dropcProg.fvtime +0.333333*handles.dropcProg.fvtime*rand(1);
end
%Notify draq, turn final valve and odor on, etc...
%Turn on (or not) opto stimulus during FV
opto_on=0;
handles.dropcData.allTrialOptoOn(handles.dropcData.allTrialIndex+1)=0;
if (handles.dropcProg.whenOptoOn==1)
% if handles.dropcProg.odorValve==handles.dropcProg.splusOdorValve %for S+
%if handles.dropcProg.odorValve==handles.dropcProg.sminusOdorValve %for S-
%if you want to randomly send TTL opto uncomment this line
% if handles.dropcProg.randomOpto(handles.dropcData.fellowsNo)==1
dataValue=uint8(0);
putvalue(handles.dio.Line(9:12),dataValue);
opto_on=1;
handles.dropcData.allTrialOptoOn(handles.dropcData.allTrialIndex+1)=1;
% end
%end
end
%Notify draq
if opto_on==0
if (handles.dropcProg.typeOfOdor==handles.dropcProg.splusOdor)
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.final_valve+handles.dropcDraqOut.s_plus;
else
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.final_valve;
end
else
if (handles.dropcProg.typeOfOdor==handles.dropcProg.splusOdor)
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.final_valve+handles.dropcDraqOut.opto_on+handles.dropcDraqOut.s_plus;
else
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.final_valve+handles.dropcDraqOut.opto_on;
end
end
dropcUpdateDraqPort(handles);
%Divert final valve towards the exhaust
%Divert purge valve towards the port
dataValue = handles.dropcDioOut.final_valve+handles.dropcDioOut.purge_valve;
dataValue=bitcmp(dataValue);
putvalue(handles.dio.Line(17:24),dataValue);
%Turn on odor valve
dataValue=handles.dropcProg.odorValve;
dataValue=bitcmp(uint8(dataValue));
putvalue(handles.dio.Line(1:8),dataValue);
%if handles.dropcProg.skipIntervals==0
while (toc-start_toc<fvtime)
noSamples=noSamples+1;
if dropcNosePokeNow(handles)==1
noSamplesMouseOn=noSamplesMouseOn+1;
end
end
%end
%Turn on (or not) opto stimulus during odor delivery
opto_on=0;
%If this is not a short then give the light
if (noSamplesMouseOn/noSamples) > 0.2
if handles.dropcProg.whenOptoOn==2
if handles.dropcProg.odorValve==handles.dropcProg.splusOdorValve %for S+
%if handles.dropcProg.odorValve==handles.dropcProg.sminusOdorValve %for S-
%if you want to randomly send TTL opto uncomment this line
% if handles.dropcProg.randomOpto(handles.dropcData.fellowsNo)==1
dataValue=uint8(0);
putvalue(handles.dio.Line(9:12),dataValue);
opto_on=1;
handles.dropcData.allTrialOptoOn(handles.dropcData.allTrialIndex+1)=1;
% end
end
end
end
%Notify draq of odor onset
%Notify draq
if opto_on==0
if (handles.dropcProg.typeOfOdor==handles.dropcProg.splusOdor)
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.odor_onset+handles.dropcDraqOut.s_plus;
else
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.odor_onset;
end
else
if (handles.dropcProg.typeOfOdor==handles.dropcProg.splusOdor)
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.odor_onset+handles.dropcDraqOut.opto_on+handles.dropcDraqOut.s_plus;
else
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.odor_onset+handles.dropcDraqOut.opto_on;
end
end
dropcUpdateDraqPort(handles);
%Turn FinalValve towards the odor port: turn on odor...)
dataValue=bitcmp(uint8(0));
putvalue(handles.dio.Line(17:24),dataValue);
%Turn opto TTL off
if (handles.dropcProg.whenOptoOn==1)
dataValue=uint8(15);
putvalue(handles.dio.Line(9:12),dataValue);
end
if (fvtime<0.3)
finalValveOK=1;
else
if (noSamplesMouseOn/noSamples) > 0.2
finalValveOK=1;
else
finalValveOK=0;
end
end
end