-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherror_trial_counter_OLD.m
39 lines (32 loc) · 1.59 KB
/
error_trial_counter_OLD.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
sm = SessManager;
progressbar('Usable sessions...');
[excursions, found_trials, fraction_found_trials] = deal(zeros(1,sm.num_usable));
for i = 1:sm.num_usable
data_file = sm.data_path(i, 'Usable');
load(data_file, 'tracesEvents');
opt = DecodeTensor.default_opt;
track_coord = tracesEvents.position(:,1);
track_begin = prctile(track_coord, opt.cutoff_p);
track_end = prctile(track_coord, 100 - opt.cutoff_p);
right_quarter = track_begin + 0.25 * (track_end - track_begin);
left_quarter = track_begin + 0.75 * (track_end - track_begin);
crossed_right_quarter = diff(track_coord > right_quarter) == 1;
crossed_left_quarter = diff(track_coord < left_quarter) == 1;
excursions(i) = sum(crossed_right_quarter) + sum(crossed_left_quarter);
found_trials(i) = numel(sm.cons_usable(i).tr_dir);
fraction_found_trials(i) = found_trials(i) ./ excursions(i);
fprintf('Usable session #%d\tExcursions R:%d L:%d total:%d found_tr:%d ratio:%f\n',...
i, sum(crossed_right_quarter), sum(crossed_left_quarter), excursions(i),...
found_trials(i), fraction_found_trials(i));
if false
figure;
plot(track_coord, '-ok');
ylim([track_begin track_end]);
hold on;
plot(track_begin + crossed_right_quarter .* (track_end - track_begin), 'r');
plot(track_begin + crossed_left_quarter .* (track_end - track_begin), 'b');
end
progressbar(i/sm.num_usable);
end
message = 'Generated by error_trial_counter.m for 110 usable sessions';
save excursions.mat excursions found_trials fraction_found_trials message