-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeh2Mini.m
More file actions
67 lines (51 loc) · 2.24 KB
/
beh2Mini.m
File metadata and controls
67 lines (51 loc) · 2.24 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
% beh2Mini: post-BehaviorDEPOT Script for FRLU Generation and Miniscope-Aligned Prep
function caBehavior = beh2Mini(Behavior, Metrics, frlu, total_ca_frames)
% Create a copy of data (for adjustment)
caBehavior = struct();
% Use lookup table to convert annotations in tempBehavior
behavs = fieldnames(Behavior);
% Find total frames with temporal downsample adjustment
% [ca_file, ca_path] = uigetfile('Select calcium file to match length to');
% load([ca_path ca_file], 'dff')
num_frames = total_ca_frames;
for i = 1:size(behavs, 1)
if ~strcmpi(behavs{i}, 'Temporal') % Skip temporal, is covered and more accurate in Cues
try
% Pull out OG bouts from each behavior
bouts = Behavior.(behavs{i}).Bouts;
% Scan through all bouts and convert
for ii = 1:size(bouts, 1)
strt = bouts(ii, 1);
stp = bouts(ii, 2);
% Find best matching frame
[~, strt_test] = min(abs(frlu(:,1) - strt));
[~, stp_test] = min(abs(frlu(:,1) - stp));
% Convert from behCam to Miniscope
bouts(ii, 1) = frlu(strt_test, 2);
bouts(ii, 2) = frlu(stp_test, 2);
end
caBehavior.(behavs{i}) = genBehStruct(bouts(:,1), bouts(:,2), num_frames);
catch
disp(['Skipping Behavior.' behavs{i}])
end
end
end
% Convert platform data from Behavior.Spatial, if applicable
try
platformVector = Behavior.Spatial.Platform.inROIvector;
[p_start, p_stop] = findStartStop(platformVector);
for ii = 1:size(p_start, 1)
strt = p_start(ii);
stp = p_stop(ii);
% Find best matching frame
[~, strt_test] = min(abs(frlu(:,1) - strt));
[~, stp_test] = min(abs(frlu(:,1) - stp));
% Convert from behCam to Miniscope
p_start(ii) = frlu(strt_test, 2);
p_stop(ii) = frlu(stp_test, 2);
end
caBehavior.Platform = genBehStruct(p_start, p_stop, num_frames);
end
% Save caBehavior struct
save('caBehavior.mat', 'caBehavior')
end