forked from restrepd-zz/dropc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdropcFinalValveOKBegin_hf.m
executable file
·133 lines (97 loc) · 3.53 KB
/
dropcFinalValveOKBegin_hf.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
function dropcFinalValveOKBegin_hf(handles)
%Opens final valve and odor on and finds out whtehr the mouse stays in the
%odor sampling area
start_toc=toc;
noSamples=0;
noSamplesMouseOn=0;
%During begin fvtime increases monotonically as a function of trialIndex
group=floor(handles.dropcData.trialIndex/20)+1;
if (group<=6)
fvtime=(group-1)*handles.dropcProg.fvtime/5;
else
fvtime=handles.dropcProg.fvtime;
end
%Notify draq, turn final valve and odor on, etc...
%Turn on (or not) opto stimulus
opto_on=0;
if handles.dropcProg.whenOptoOn==1
if handles.dropcProg.randomOpto(handles.dropcData.fellowsNo)==1
dataValue=uint8(0);
putvalue(handles.dio.Line(9:12),dataValue);
opto_on=1;
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);
%Notify FV
handles.dropcData.eventIndex=handles.dropcData.eventIndex+1;
handles.dropcData.eventTime(handles.dropcData.eventIndex)=toc;
handles.dropcData.event(handles.dropcData.eventIndex)=1;
%Divert final valve towards the exhaust and the purge valve towars the port
dataValue = handles.dropcDioOut.final_valve+handles.dropcDioOut.purge_valve;
if handles.dropcProg.makeNoise==1
dataValue = dataValue+handles.dropcDioOut.noise;
end
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
opto_on=0;
if handles.dropcProg.whenOptoOn==2
if handles.dropcProg.randomOpto(handles.dropcData.fellowsNo)==1
dataValue=bitcmp(uint8(8));
putvalue(handles.dio.Line(9:12),dataValue);
opto_on=1;
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);
%Notify odor on
handles.dropcData.eventIndex=handles.dropcData.eventIndex+1;
handles.dropcData.eventTime(handles.dropcData.eventIndex)=toc;
handles.dropcData.event(handles.dropcData.eventIndex)=2;
%Turn opto TTL off
dataValue=uint8(15);
putvalue(handles.dio.Line(9:12),dataValue);
end