-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_custom_event_files.m
80 lines (49 loc) · 1.66 KB
/
create_custom_event_files.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
73
74
75
76
77
78
79
80
clear all
clc
close all
cfg.protocol='aw';
%Data Directory
cfg.data_rootdir=('/autofs/space/taito_005/users/awmrc/');
fid=fopen('/autofs/space/taito_005/users/fahimeh/doc/txt/aw_list_proj.txt');
C=textscan(fid,'%s%s%s%s%s');
subject=C{1,1};
visitNo=C{1,2};
runs=C{1,3};
k=1;
for isubj=1:8
subj=subject{isubj};
run=runs{isubj};
eventfile=[cfg.data_rootdir subj '/' visitNo{isubj} '/' subj '_' ,cfg.protocol, '_' num2str(run) '_decim_sss-eve.fif'];
try
events=mne_read_events(eventfile);
sound1=find(events(:,3)==21 | events(:,3)==22)-4;
sound2=find(events(:,3)==21 | events(:,3)==22)-2;
probe=find(events(:,3)==21 | events(:,3)==22)+2;
L=size(events,1);
newevents=events;
for ievent=1:length(sound1)
newevents(L+ievent,1)=events(sound1(ievent),1);
newevents(L+ievent,2)=0;
newevents(L+ievent,3)=600;
end
clear L
L=size(newevents,1);
for ievent=1:length(sound2)
newevents(L+ievent,1)=events(sound2(ievent),1);
newevents(L+ievent,2)=0;
newevents(L+ievent,3)=700;
end
clear L
L=size(newevents,1);
for ievent=1:length(probe)
newevents(L+ievent,1)=events(probe(ievent),1);
newevents(L+ievent,2)=0;
newevents(L+ievent,3)=800;
end
filename=[cfg.data_rootdir subj '/' visitNo{isubj} '/' subj '_' ,cfg.protocol, '_' num2str(run) '_decim_sss_new-eve.fif'];
mne_write_events(filename,newevents)
catch
failed_subjec{k,1}=eventfile;
k=k+1;
end
end