-
Notifications
You must be signed in to change notification settings - Fork 3
/
berlin_correct_eventdata.m
66 lines (55 loc) · 1.24 KB
/
berlin_correct_eventdata.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
64
65
66
function trig = berlin_correct_eventdata(trig,initials,task)
if nargin<2
initials = 'NOTUSED';
end
if nargin<3
task = 'NOTUSED';
end
ntrig = size(trig, 1);
% glitch in button electronics
if isequal(initials(1:6),'DYST04') && isequal(task(1:3),'MVL')
trig(2,:) = -1.0*trig(2,:);
end
trig = reshape(trig', 1, []);
trigall = trig;
control_plots = 0;
% control
% if control_plots
% figure
% plot( trig )
% end
% correct sign
[pdf, xout] = hist(trig);
if sum(pdf(1:2)) < sum(pdf(9:10))
trig = -1.0*trig;
end
% correct offset
[pdf, xout] = hist(trig);
if xout(1) > xout(2)-xout(1)
trig = trig-xout(1);
end
if control_plots
xout
figure
plot( trig )
end
% get levels in steps of 10
[pdf, xout] = hist(trig);
% dystonia
if isequal(initials(1:4),'DYST')
trig = fix(105*trig / 10) * 10;
ind = find(trig < 15);
trig(ind) = 0;
elseif isequal(task(1:4),'EMOT')
trig = fix(105*trig / 10) * 10;
ind = find(trig < 15);
trig(ind) = 0;
else
% stop paradigm normal case
% trig = fix(100*trig/xout(10) / 10) * 10;
trig = fix(105*trig / 10) * 10;
% comment out if motor events are needed
% ind = find(trig < 15);
% trig(ind) = 0;
end
trig = reshape(trig, [], ntrig)';