-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeEventNew.m
66 lines (50 loc) · 1.33 KB
/
makeEventNew.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
function [ loc wrong w val] = makeEventNew( EEG,Fs,type,location ,channel)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
count = length(type);
event_channel = [];
event_pos = [];
wrong = 1;
j =1;
w=0;
offset = 6;
loc = 1;
while j <= count;
i = location(j)-100;
while i <= location(j)+6000
%Check for single pulse
if (abs(EEG.data(channel,i))>2000)
val = EEG.data(channel,i);
event_pos(loc ,1) = i -offset;
event_pos(loc,2) = type(j);
break;
end
if i > location(j)+5000
loc = loc -1;
w(wrong) = j;
wrong = wrong+1;
% count = count+1;
break;
end
i = i+1;
end
loc = loc +1;
j = j+1;
end
ft_sampleinfo_var = zeros(2,size(event_pos,2));
for i = 1:size(event_pos,2)
ft_sampleinfo_var(1,i) = event_pos(i)-1000;
ft_sampleinfo_var(2,i) = event_pos(i)+1000;
end
ft_sampleinfo_var =ft_sampleinfo_var';
event_pos(:,1) = (event_pos(:,1)./Fs);
%make the event txt file
cd('C:\Users\jay\Desktop\Work\TMS-EEG');
fid = fopen('event.txt', 'wt');
fprintf(fid, 'latency type\n');
for i = 1:length(event_pos)
fprintf(fid, '%d S%d\n', event_pos(i,1), event_pos(i,2));
end
fclose(fid);
size(event_pos)
end