-
Notifications
You must be signed in to change notification settings - Fork 0
/
wf_imaging.m
63 lines (47 loc) · 2.84 KB
/
wf_imaging.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
function wf_imaging
%%% Function to generate and load widefield camera, and excitation led vectors
%%% for single trial widefield imaging -- Pol Bech Aug 2023
global WF_S Stim_S_SR handles2give trial_duration trial_number wf_cam_vec LED1_vec LED2_vec WF_FileInfo
% Path to imaging computer to update ConfigFile
if getenv('COMPUTERNAME')=='SV-07-051'
WF_FileInfo.CameraPathConfig = '\\SV-07-091\Experiment\WideFieldImaging\config.txt';
WF_FileInfo.CameraPathTemplateConfig = '\\SV-07-091\Experiment\WideFieldImaging\Template\config.txt';
else
WF_FileInfo.CameraPathConfig = '\\SV-07-074\Experiment\WideFieldImaging\config.txt';
WF_FileInfo.CameraPathTemplateConfig = '\\SV-07-074\Experiment\WideFieldImaging\Template\config.txt';
end
WF_FileInfo.n_frames_to_grab = trial_duration*WF_FileInfo.CameraFrameRate/1000;
WF_FileInfo.file_name = [char(handles2give.mouse_name) '_' char(handles2give.date) '_' char(handles2give.session_time)];
WF_FileInfo.savedir = [WF_FileInfo.CameraRoot handles2give.mouse_name '\' WF_FileInfo.file_name '\'];
if trial_number == 1
FrameRate= WF_FileInfo.CameraFrameRate; % frame rate
t = 1/Stim_S_SR : 1/Stim_S_SR : ((trial_duration)/1000); % Time vector
w = WF_FileInfo.CameraExposure; % Pulse width (s)
d = w/2 : 1/FrameRate : (trial_duration/1000); % Delay vector
Cam_pulses = pulstran(t,d,'rectpuls',w);
wf_cam_vec = [zeros(1,2*Stim_S_SR/1000) 5*Cam_pulses(1:end-2*Stim_S_SR/1000)]; %TTL trigger pulses of 5V
if WF_FileInfo.LED488
t = 1/Stim_S_SR : 1/Stim_S_SR : ((trial_duration)/1000); % Time vector
w = 1/FrameRate-0.002; % Pulse width (s)
d = w/2 : 1/(FrameRate/2) : (trial_duration/1000); % Delay vector
LED1_pulses = pulstran(t,d,'rectpuls',w);
LED1_vec = [zeros(1,2*Stim_S_SR/1000) 5*LED1_pulses(1:end-2*Stim_S_SR/1000)];
else
LED1_vec = zeros(1, length(wf_cam_vec));
end
if WF_FileInfo.LED405
t = 1/Stim_S_SR : 1/Stim_S_SR : ((trial_duration-1000/WF_FileInfo.CameraFrameRate)/1000); % Time vector
w = 1/FrameRate-0.002; % Pulse width (s)
d = w/2 : 1/(FrameRate/2) : (trial_duration/1000); % Delay vector, shift LED2_vec by one frame
LED2_pulses = pulstran(t,d,'rectpuls',w);
LED2_vec = [zeros(1,(2+1000/FrameRate)*Stim_S_SR/1000)...
5*LED2_pulses(1:end-2*Stim_S_SR/1000)]; %TTL trigger pulses of 5V
else
LED2_vec = zeros(1, length(wf_cam_vec));
end
save_wf_config
end
WriteConfigCtxCam(WF_FileInfo);
% WF_S.start()
% WF_S.write([wf_cam_vec; LED1_vec; LED2_vec;]')
end