-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotDistribution.m~
56 lines (51 loc) · 1.86 KB
/
plotDistribution.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
function plotDistribution(in)
badTouch = {};
anyTouch = {};
sessionTick = zeros(1, numel(in));
for isess = 1:numel(in)
if isess == 1
sessionTick(isess) = 1;
else
sessionTick(isess) = numel(badTouch{isess - 1}) + sessionTick(isess - 1);
end
oneSession = in(isess);
allTrials = oneSession.trials;
touchStatus = {};
trialState = {};
%keyboard
for i = 1:numel(allTrials)
touchStatus{i} = allTrials(i).touchStatus;
trialState{i} = allTrials(i).state;
end
%keyboard
%%
badTouch{isess} = zeros(1, numel(trialState));
goodTouch{isess} = zeros(1, numel(trialState));
anyTouch{isess} = false(1, numel(trialState));
isGoodTouch{isess} = false(1, numel(trialState));
goodTouchTime{isess} = NaN(1, numel(trialState));
for x = 1:numel(trialState) %loops through each field, where each field is named 1,2,3,...
tick = 1;
% badTouch = 0;
if sum(touchStatus{x}) ~= 0
anyTouch{isess}(x) = true;
end
while tick <= length(trialState{x}) %loops through each row in the field
if tick > 1 && trialState{x}(tick) ~= 3 %if the object is not displayed
if touchStatus{x}(tick) == 1 && touchStatus{x}(tick - 1) == 0 %if it is the final tick of a touch
badTouch{isess}(x) = badTouch{isess}(x) + 1;
end
elseif trialState{x}(tick) == 3
if touchStatus{x}(tick) == 1 && touchStatus{x}(tick - 1) == 0
goodTouch{isess}(x) = goodTouch{isess}(x) + 1;
tmp = find(trialState{x} == 3);
goodTouchTime{isess}(x) = tick - tmp(1);
isGoodTouch{isess}(x) = true;
end
end
tick = tick + 1;
end
%plot(x,badTouch(x));
%hold on;
end
end