forked from restrepd-zz/dropc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdropcFinalValveOK_WM1.m
executable file
·127 lines (90 loc) · 3.27 KB
/
dropcFinalValveOK_WM1.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
function finalValveOK = dropcFinalValveOK_WM1(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;
%Otherwise, fvtime falls randomly between 1 and 1.5
fvtime = 0.666666*handles.dropcProg.fvtime +0.333333*handles.dropcProg.fvtime*rand(1);
%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
%Notify draq
if opto_on==0
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.final_valve;
else
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.final_valve+handles.dropcDraqOut.opto_on;
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.odorValve1;
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 1
%Notify draq
if opto_on==0
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.odor1;
else
handles.dropcDigOut.draqPortStatus=handles.dropcDraqOut.odor1+handles.dropcDraqOut.opto_on;
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
finalValveOK=1;
% if (fvtime<0.3)
% finalValveOK=1;
% else
%
% if (noSamplesMouseOn/noSamples) > 0.2
% finalValveOK=1;
% else
% finalValveOK=0;
% end
% end