-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenCueStruct.m
More file actions
45 lines (31 loc) · 1.52 KB
/
genCueStruct.m
File metadata and controls
45 lines (31 loc) · 1.52 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
%% genCueStruct
function Cues = genCueStruct(cues, total_ca_frames, ca_downsample, csp_ID, us_ID)
% OLD VERSION
% load(cue_file, 'cueframes', 'exp_ID');
% cues = fieldnames(cueframes);
cue_fields = fieldnames(cues);
ca_fps = 15;
for i = 1:length(cue_fields)
if strcmpi(cue_fields(i), 'csp')
struct_csp_ID = [upper(csp_ID(1)), csp_ID(2:end)];
csp_ts = round(cues.csp ./ ca_downsample);
Cues.(struct_csp_ID) = genBehStruct(csp_ts(:,1), csp_ts(:,2), total_ca_frames);
csp_on = [csp_ts(:,1)-ca_fps, csp_ts(:,1)+ca_fps];
csp_off = [csp_ts(:,2)-ca_fps, csp_ts(:,2)+ca_fps];
Cues.ToneOn = genBehStruct(csp_on(:,1), csp_on(:,2), total_ca_frames);
Cues.ToneOff = genBehStruct(csp_off(:,1), csp_off(:,2), total_ca_frames);
iti_bouts = findStartStop(double(~Cues.(struct_csp_ID).Vector));
Cues.ITI = genBehStruct(iti_bouts(:,1), iti_bouts(:,2), total_ca_frames);
iti30_bouts = [iti_bouts(:,1), iti_bouts(:,1)+ca_fps * 30];
Cues.ITI30 = genBehStruct(iti30_bouts(:,1), iti30_bouts(:,2), total_ca_frames);
elseif strcmpi(cue_fields(i), 'us')
Cues.(us_ID) = round(cues.us ./ ca_downsample);
if strcmpi(us_ID(end), 's')
Cues.([us_ID(1:end-1), 'Vector']) = makeVector(Cues.shocks, total_ca_frames);
else
Cues.([us_ID, 'Vector']) = makeVector(Cues.shocks, total_ca_frames);
end
end
end
save('Cues', 'Cues')
end