-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrigParameters.m
More file actions
304 lines (253 loc) · 10.6 KB
/
Copy pathrigParameters.m
File metadata and controls
304 lines (253 loc) · 10.6 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
function rigInfo = rigParameters(hostname)
if nargin==0
[~,hostname] = system('hostname');
hostname = upper(hostname(1:end-1));
end
% Default Settings:
rigInfo.computerName = hostname;
rigInfo.localFigurePosition = [4072 200];
rigInfo.screenNumber = 1;
rigInfo.screenDist = 10;
rigInfo.dialogueXYPosition = [3900 487];
rigInfo.NIdevID = '';
rigInfo.NIsessRate = [];
rigInfo.NIRotEnc = '';
rigInfo.NILicEnc = '';
rigInfo.NIRewVal = '';
rigInfo.photodiodePos = 'right';
rigInfo.photodiodeSize = [650 190]; % 650 190
rigInfo.rotEncPos = 'left';
rigInfo.rotEncSign = -1;
rigInfo.wheelToVR = 4000;
rigInfo.wheelRadius = 9.75;
rigInfo.minimumPosition = 0.01; % this helped with something, I forgot what, better to keep it positive but very small
rigInfo.maxSpeed = 200; % 200 cm / s is the max speed allowed without reporting to user
rigInfo.lickEncoderAvailable = true;
rigInfo.STOPvalveTime = 0.0;
rigInfo.BASEvalveTime = 0.02;
rigInfo.waterVolumeSTOP = 0.0;
rigInfo.waterVolumeBASE = 8;
rigInfo.useAnalogRewardValve = true;
rigInfo.rewardSizeByVolume = true;
rigInfo.PrefRefreshRate = 30; % hz
rigInfo.dirSave = 'C:\Behaviour';
rigInfo.dirScreenCalib = fileparts(mfilename('fullpath'));
rigInfo.filenameScreenCalib = 'defaultCalibration.mat';
rigInfo.doScreenTransform = true;
rigInfo.doScreenFlip = true;
rigInfo.expSettingsDir = fullfile(fileparts(mfilename('fullpath')),'settingsFolder'); % Part of the github repository...
rigInfo.numConnect = 0;
rigInfo.connectPCs = [];
rigInfo.activePorts = [];
rigInfo.sendTTL = 0;
rigInfo.TTLchannel = [];
rigInfo.ChannelMapping = [];
rigInfo.connectPortnr = [];
rigInfo.UseRange = [];
rigInfo.WaterCalibrationFile = [];
rigInfo.useKeyboard = 0;
rigInfo.initialiseUDPports = @initialiseUDPports;
rigInfo.sendUDPmessage = @sendUDPmessage;
rigInfo.updateTTL = @updateTTL;
rigInfo.closeUDPports = @closeUDPports;
calibFilePath = fullfile(rigInfo.dirScreenCalib, rigInfo.filenameScreenCalib);
if ~exist(calibFilePath, 'file')
defaultCalibration = fullfile(rigInfo.dirScreenCalib,'defaultCalibration.txt');
if ~exist(defaultCalibration, 'file')
error('No default calibration found. Check existing installation or github.');
end
createCalibrationFromDefault(defaultCalibration,calibFilePath);
end
if contains(upper(hostname), 'ANDREWS-MBP')
hostname = upper('Andrews-MacBook-Pro.local');
end
% Rig Specific Settings
switch upper(hostname)
case 'ZINKO'
% Local computer info (basic)
rigInfo.computerName = 'ZINKO';
rigInfo.localFigurePosition = [4000 200];
rigInfo.screenNumber = 1; %Checked
rigInfo.screenDist = 10;
rigInfo.dialogueXYPosition = [4000 200]; %to check (parameters for GUI)
%RigInfo.parameterscript = 'SetExperimentParametersB2_Blender';
rigInfo.NIdevID = 'Dev1';
rigInfo.NIsessRate = 5000;
rigInfo.NIRotEnc = 'ctr0';
rigInfo.NILicEnc = 'ctr1';
rigInfo.NIRewVal = 'ao0';
rigInfo.photodiodePos = 'right';
rigInfo.photodiodeSize = [500 150]; % [650 190] %% Enny: CHECK %[250 75];
rigInfo.rotEncPos = 'left';
rigInfo.rotEncSign = -1;
rigInfo.wheelToVR = 4000;
rigInfo.wheelRadius = 9.75;
rigInfo.lickEncoderAvailable = true;
rigInfo.STOPvalveTime = 0.0;
rigInfo.BASEvalveTime = 0.025;
rigInfo.waterVolumeSTOP = 0.0;
rigInfo.waterVolumeBASE = 6;
rigInfo.rewardSizeByVolume = true;
rigInfo.useAnalogRewardValve = false;
rigInfo.PrefRefreshRate = 30;
% Saving directories: remote
rigInfo.dirSave = 'C:\Users\Experiment\Documents\vrAndrew\animalData';
rigInfo.dirScreenCalib = 'C:\Users\Experiment\Documents\MATLAB\';
rigInfo.filenameScreenCalib = 'halfcyclindercalib_22102021.mat';
rigInfo.doScreenTransform = true;
rigInfo.doScreenFlip = true;
rigInfo.WaterCalibrationFile = 'Zinko_water_calibs'; %Change!!
% External computer connection info -- NEEDS CHECKING
% SCANIMAGE
rigInfo.connectPCs{1} = 'ZYLVIA';
rigInfo.connectPortnr{1} = 1001;
% Timeline
rigInfo.connectPCs{2} = 'ZODIAC';
rigInfo.connectPortnr{2} = 1001;
% EYE CAMERA
rigInfo.connectPCs{3} = 'ZEITGEIST';
rigInfo.connectPortnr{3} = 1001;
rigInfo.numConnect = length(rigInfo.connectPCs);
rigInfo.sendTTL = 0; % ttl not necessary here for timeline sync
rigInfo.TTLchannel = 'Port0/Line0'; %might be flipped.
case 'ZEELAND'
% Local computer info (basic)
rigInfo.computerName = 'ZEELAND';
rigInfo.localFigurePosition = [4000 100];
rigInfo.screenNumber = 2; % Checked
rigInfo.screenDist = 10;
rigInfo.dialogueXYPosition = [4000 100]; %to check (parameters for GUI)
rigInfo.NIdevID = 'Dev1';
rigInfo.NIsessRate = 5000;
rigInfo.NIRotEnc = 'ctr0';
rigInfo.NILicEnc = '';
rigInfo.NIRewVal = 'ao0';
rigInfo.photodiodePos = 'right';
rigInfo.photodiodeSize = [100 75]; % [650 190] %% Enny: CHECK %[250 75];
rigInfo.rotEncPos = 'left';
rigInfo.rotEncSign = -1;
rigInfo.wheelToVR = 4000;
rigInfo.wheelRadius = 10;
rigInfo.lickEncoderAvailable = false;
rigInfo.STOPvalveTime = 0.0;
rigInfo.BASEvalveTime = 0.025;
rigInfo.waterVolumeSTOP = 0.0;
rigInfo.waterVolumeBASE = 8;
rigInfo.rewardSizeByVolume = true;
rigInfo.useAnalogRewardValve = true;
rigInfo.PrefRefreshRate = 30;
% Saving directories: remote
rigInfo.dirSave = 'C:\Users\Experiment\Documents\animalData';
rigInfo.dirScreenCalib = 'C:\Users\Experiment\Documents\GitHub\vrControlGratings';
rigInfo.filenameScreenCalib = 'halfcyclindercalib_22102021.mat';
rigInfo.doScreenTransform = true;
rigInfo.doScreenFlip = true;
rigInfo.WaterCalibrationFile = 'Zeeland_water_calibs'; %Change!!
% Timeline
rigInfo.connectPCs{1} = 'ZEELAND';
rigInfo.connectPortnr{1} = 1004; % enny indicated that this changed recently (19/1/24)
% front CAMERA
rigInfo.connectPCs{2} = 'ZOOLAND';
rigInfo.connectPortnr{2} = 1002;
% Belly CAMERA
rigInfo.connectPCs{3} = 'ZOOLAND';
rigInfo.connectPortnr{3} = 1001;
rigInfo.numConnect = length(rigInfo.connectPCs);
rigInfo.sendTTL = 0; % ttl not necessary here for timeline sync
rigInfo.TTLchannel = 'Port0/Line0'; %might be flipped.
case 'ZAANLAND'
% Local computer info (basic)
rigInfo.computerName = 'ZAANLAND';
rigInfo.localFigurePosition = [4500 0];
rigInfo.screenNumber = 2; % Checked
rigInfo.screenDist = 10;
rigInfo.dialogueXYPosition = [4500 0]; %to check (parameters for GUI)
rigInfo.NIdevID = 'Dev1';
rigInfo.NIsessRate = 5000;
rigInfo.NIRotEnc = 'ctr0';
rigInfo.NILicEnc = '';
rigInfo.NIRewVal = 'ao0';
rigInfo.photodiodePos = 'right';
rigInfo.photodiodeSize = [100 75]; % [650 190] %% Enny: CHECK %[250 75];
rigInfo.rotEncPos = 'left';
rigInfo.rotEncSign = -1;
rigInfo.wheelToVR = 4000;
rigInfo.wheelRadius = 10;
rigInfo.lickEncoderAvailable = false;
rigInfo.STOPvalveTime = 0.0;
rigInfo.BASEvalveTime = 0.025;
rigInfo.waterVolumeSTOP = 0.0;
rigInfo.waterVolumeBASE = 8;
rigInfo.rewardSizeByVolume = true;
rigInfo.useAnalogRewardValve = true;
rigInfo.PrefRefreshRate = 30;
% Saving directories: remote
rigInfo.dirSave = 'C:\Users\Experiment\Documents\animalData';
rigInfo.dirScreenCalib = 'C:\Users\Experiment\Documents\GitHub\vrControlGratings';
rigInfo.filenameScreenCalib = 'halfcyclindercalib_22102021.mat';
rigInfo.doScreenTransform = true;
rigInfo.doScreenFlip = true;
rigInfo.WaterCalibrationFile = 'Zaanland_water_calibs'; %Change!!
% Timeline
rigInfo.connectPCs{1} = 'ZAANLAND';
rigInfo.connectPortnr{1} = 1004; % enny indicated that this changed recently (19/1/24)
% Front CAMERA
rigInfo.connectPCs{2} = 'ZOOLAND';
rigInfo.connectPortnr{2} = 1004;
% Belly camera
rigInfo.connectPCs{3} = 'ZOOLAND';
rigInfo.connectPortnr{3} = 1003;
rigInfo.numConnect = length(rigInfo.connectPCs);
rigInfo.sendTTL = 0; % ttl not necessary here for timeline sync
rigInfo.TTLchannel = 'Port0/Line0'; %might be flipped.
case 'DESKTOP-C0GU3US'
rigInfo.localFigurePosition = [680 500];
rigInfo.dirSave = 'C:\Users\andrew\Documents\GitHub\vrControl\settingsFolder';
rigInfo.useKeyboard = 1; % to control the linear track with the keyboard arrow keys
rigInfo.screenNumber = 2;
rigInfo.filenameScreenCalib = '';
rigInfo.lickEncoderAvailable = false;
case upper('Andrews-MacBook-Pro.local')
rigInfo.localFigurePosition = [680 500];
rigInfo.dirSave = '/Users/landauland/Documents/GitHub/vrControl/settingsFolder';
rigInfo.useKeyboard = 1; % to control the linear track with the keyboard arrow keys
rigInfo.filenameScreenCalib = '';
rigInfo.lickEncoderAvailable = false;
otherwise
warning('hostname not recognized!!');
end
end
function rigInfo = initialiseUDPports(rigInfo)
if rigInfo.numConnect>0
for iPC = 1:rigInfo.numConnect
rigInfo.activePorts{iPC} = pnet('udpsocket', 1001);
pnet(rigInfo.activePorts{iPC}, 'udpconnect', rigInfo.connectPCs{iPC}, rigInfo.connectPortnr{iPC});
fprintf('Sent message to %s\n',rigInfo.connectPCs{iPC});
end
end
end
function rigInfo = sendUDPmessage(rigInfo, message, sendIdx_iIP)
if rigInfo.numConnect>0
if nargin < 3
for iPC = 1:rigInfo.numConnect
pnet(rigInfo.activePorts{iPC},'write', message);
pnet(rigInfo.activePorts{iPC}, 'writePacket');
end
else
for iPC = sendIdx_iIP
pnet(rigInfo.activePorts{iPC},'write',message);
pnet(rigInfo.activePorts{iPC}, 'writePacket');
end
end
end
end
function rigInfo = updateTTL(rigInfo,state)
rigInfo.TTLchannel.outputSingleScan(state);
end
function rigInfo = closeUDPports(rigInfo)
if rigInfo.numConnect>0
for iPC = 1:rigInfo.numConnect
pnet(rigInfo.activePorts{iPC},'close');
end
end
end