-
Notifications
You must be signed in to change notification settings - Fork 1
/
epoch_window.m
72 lines (57 loc) · 3.89 KB
/
epoch_window.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
67
68
69
70
71
72
function [ struct_window ] = epoch_window( session,Align_Event,timebEvent,timeaEvent,windowlength,overlap)
struct_window.Event_pos=session.event.position(session.event.name==Align_Event);
struct_window.sampleRate=512;
if (timeaEvent ~=0 )
struct_window.Event_pos=struct_window.Event_pos+windowlength/overlap; %we have to shift because "backward" has the 0 (i.e. the event) on the right
% if timebEvent==0
% samplesBeforeAlignEvents=abs(timebEvent)/overlap; % they should be both multiply by the sample frequences
% samplesAfterAlignEvents=abs((timeaEvent-windowlength))/overlap;
% %samplesAfterAlignEvents=abs(timeaEvent)/overlap;
% struct_window.labels=session.event.name(session.event.name==Align_Event);
%
% struct_window.samples=[];
%
% for i=1:size(struct_window.labels,1)
%
% A=session.data(1:16,:,(struct_window.Event_pos(i)-samplesBeforeAlignEvents):struct_window.Event_pos(i));
% C=session.data(1:16,:,((struct_window.Event_pos(i)+1):(struct_window.Event_pos(i)+samplesAfterAlignEvents)));
% %C=session.data(1:16,:,struct_window.Event_pos(i):(struct_window.Event_pos(i)+samplesAfterAlignEvents));
% struct_window.samples=cat(3,struct_window.samples,A,C);
% %struct_window.samples=cat(3,struct_window.samples,C);
% end
% struct_window.duration=samplesAfterAlignEvents+samplesBeforeAlignEvents+1;
% struct_window.labels=ones(size(session.event.name(session.event.name==Align_Event),1)*(samplesBeforeAlignEvents+samplesAfterAlignEvents+1),1)*Align_Event;
% end
% if timebEvent>0
%samplesAfterAlignEvents=abs((timeaEvent-timebEvent))/overlap;
struct_window.labels=session.event.name(session.event.name==Align_Event);
struct_window.samples=[];
for i=1:size(struct_window.labels,1)
% A=session.data(1:16,:,(struct_window.Event_pos(i)-samplesBeforeAlignEvents):struct_window.Event_pos(i));
C=session.data(1:16,:,((struct_window.Event_pos(i)+timebEvent/overlap):(struct_window.Event_pos(i)+(timeaEvent-windowlength)/overlap)));
%C=session.data(1:16,:,struct_window.Event_pos(i):(struct_window.Event_pos(i)+samplesAfterAlignEvents));
%struct_window.samples=cat(3,struct_window.samples,A,C);
struct_window.samples=cat(3,struct_window.samples,C);
end
struct_window.duration=(timeaEvent-timebEvent-windowlength)/overlap+1;
struct_window.labels=ones(size(session.event.name(session.event.name==Align_Event),1)*struct_window.duration,1)*Align_Event;
else
samplesBeforeAlignEvents=abs(timebEvent+windowlength)/overlap;
samplesAfterAlignEvents=abs((timeaEvent))/overlap;
struct_window.labels=session.event.name(session.event.name==Align_Event);
struct_window.samples=[];
for i=1:size(struct_window.labels,1)
A=session.data(1:16,:,(struct_window.Event_pos(i)-samplesBeforeAlignEvents):struct_window.Event_pos(i));
%C=session.data(1:16,:,((struct_window.Event_pos(i)+1):(struct_window.Event_pos(i)+samplesAfterAlignEvents)));
%C=session.data(1:16,:,struct_window.Event_pos(i):(struct_window.Event_pos(i)+samplesAfterAlignEvents));
%struct_window.samples=cat(3,struct_window.samples,A,C);
struct_window.samples=cat(3,struct_window.samples,A);
end
struct_window.duration=samplesAfterAlignEvents+samplesBeforeAlignEvents+1;
struct_window.labels=ones(size(session.event.name(session.event.name==Align_Event),1)*(samplesBeforeAlignEvents+samplesAfterAlignEvents+1),1)*Align_Event;
%
%struct_window.duration=samplesAfterAlignEvents+samplesBeforeAlignEvents+1;
%struct_window.duration=samplesAfterAlignEvents+1;
%struct_window.labels=ones(size(session.event.name(session.event.name==Align_Event),1)*(samplesBeforeAlignEvents+samplesAfterAlignEvents+1),1)*Align_Event;
%struct_window.labels=ones(size(session.event.name(session.event.name==Align_Event),1)*(samplesAfterAlignEvents+1),1)*Align_Event;
end