-
Notifications
You must be signed in to change notification settings - Fork 14
/
eyeblink_correct_detect.m
64 lines (45 loc) · 1.11 KB
/
eyeblink_correct_detect.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
function blinkfname=eyeblink_correct(S)
disp('Loading data.')
fname = S.D;
Dorig = spm_eeg_load(fname);
%1.detect eyeblinks
disp('Detecting eyeblinks.');
S = [];
S.D = Dorig;
S.method = 'events';
S.doplots = 1;
S.sd_thr = 3;
S.fname=fname;
D = detect_eyeblinks(S);
%close all;
%2.epoch w.r.t. eyeblink
disp('Epoching w.r.t. eyeblinks.');
S = [];
S.D = D;
S.inputformat = [];
S.pretrig = -300;
S.posttrig = 300;
S.trialdef(1).conditionlabel = 'blink';
S.trialdef(1).eventtype = 'eyeblink';
S.trialdef(1).eventvalue = 1;
S.reviewtrials = 0;
S.save = 0;
S.epochinfo.padding = 0;
S.bc = 2;
S.prefix = 'blink_e'; % note this requires a modified version of spm_eeg_epochs that accepts this input argument... LH 280509
D = spm_eeg_epochs_v2(S);
blinkfname=fullfile(D.path,D.fname);
S = [];
S.D = D;
%D = spm_eeg_average(S);
%3.perform SVD
S = [];
S.D = D;
S.method = 'SVD';
S.timewin = [-300 300]/1000; %600 ms timewindow;
S.ncomp = 4;
[D,svdoutput] = spm_eeg_spatial_confounds_v2(S);
D.save;
mkdir([fname '_svdoutputs']);
svdfname = fullfile([fname '_svdoutputs'],'blink_svd.mat'];
save(svdfname,'svdoutput');