forked from landoskape/vrControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvrControlRawHabituationModule.m
More file actions
82 lines (70 loc) · 2.5 KB
/
vrControlRawHabituationModule.m
File metadata and controls
82 lines (70 loc) · 2.5 KB
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
function habMod = vrControlRawHabituationModule()
% Get RigInfo
rigInfo = vrControlRigParameters();
rigInfo.wheelCircumference = 2*pi*rigInfo.wheelRadius; % ATTENTION TO MINUTE DETAIL
% Set up rotary encoder
habMod.BALLPort = 9999;
% Setup wheel hardware info
habMod.session = daq.createSession('ni');
habMod.session.Rate = rigInfo.NIsessRate;
habMod.rotEnc = DaqRotaryEncoder;
habMod.rotEnc.DaqSession = habMod.session;
habMod.rotEnc.DaqId = rigInfo.NIdevID;
habMod.rotEnc.DaqChannelId = rigInfo.NIRotEnc;
habMod.rotEnc.createDaqChannel;
habMod.rotEnc.zero();
% Set up reward valve
habMod.sessionVal = daq.createSession('ni');
habMod.sessionVal.Rate = rigInfo.NIsessRate;
habMod.rewVal = DaqRewardValve;
load(rigInfo.WaterCalibrationFile);
habMod.rewVal.DaqSession = habMod.sessionVal;
habMod.rewVal.DaqId = rigInfo.NIdevID;
habMod.rewVal.DaqChannelId = rigInfo.NIRewVal;
habMod.rewVal.createDaqChannel;
habMod.rewVal.MeasuredDeliveries = Water_calibs(end).measuredDeliveries;
habMod.rewVal.OpenValue = 10;
habMod.rewVal.ClosedValue = 0;
habMod.rewVal.close;
habMod.rewTime = 0.200; % s
habMod.changeRewardTime = @(habMod, rewTime) changeRewardTime(habMod, rewTime);
habMod.deliverReward = @(habMod) deliverReward(habMod);
habMod.printRotaryPosition = @(habMod) printRotaryPosition(habMod);
habMod.changeRewardTime(habMod, habMod.rewTime);
end
function deliverReward(habMod)
habMod.rewVal.activateDigitalDelivery()
end
function habMod = changeRewardTime(habMod, rewTime)
habMod.rewTime = rewTime;
habMod.rewVal.prepareRewardDelivery(rewTime, 's')
end
function printRotaryPosition(habMod)
rotPos = habMod.rotEnc.readPositionAndZero;
display(rotPos);
end
function checkUserReward()
keyPressed = checkKeyboard;
if keyPressed == 2
habMod.rewVal.TriggerSession.outputSingleScan(1);
habMod.rewVal.TriggerSession.outputSingleScan(0);
end
end
function printUpdates(timeDelays)
end
function checkUserAb()
if keyPressed == 1
runInfo.abort = 1;
if runInfo.rewardAvailable
% Mouse didn't receive a reward
trialInfo.outcome(runInfo.currTrial) = 0;
end
VRmessage = sprintf('Manual Abort for animal %s, on date %s, session %s, trialNum %d.',...
expInfo.animalName, expInfo.dateStr, expInfo.sessionName, runInfo.currTrial);
rigInfo = rigInfo.sendUDPmessage(rigInfo, VRmessage);
VRLogMessage(expInfo, VRmessage);
if rigInfo.sendTTL
hwInfo.session.outputSingleScan(false);
end
end
end