-
Notifications
You must be signed in to change notification settings - Fork 14
/
osl_rejectvisual.m
142 lines (112 loc) · 3.14 KB
/
osl_rejectvisual.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function D = osl_rejectvisual(D,time_range);
% D = osl_rejectvisual(S)
%
% Visual artefact rejection script
%
% Input
% - D : SPM MEEG object
% - time_range : Latency argument for spm_eeg_ft_artefact_visual
%
% RA 2017
% MWW and LH
%% spit out some info about what has already been rejected in this file
if ~isempty(D.badchannels)
disp('Following channels are already marked as bad:');
lab = chanlabels(D);
disp(lab(badchannels(D)));
else
disp('No bad channels currently marked.');
end
if length(D.badtrials)>0
disp([num2str(length(find(D.badtrials))) ' trials of ' num2str(D.ntrials) ' have already been marked as bad.']);
else
disp('No bad trials currently identified.');
end
%% first, look for EOG artefacts
if ~isempty(find(ismember(D.chantype,'EOG')))
disp('%%% 1. EOG %%%')
S = [];
S.D = D;
S.method = 'summary';
S.latency = time_range*1000;
S.channel = D.chanlabels(find(ismember(D.chantype,'EOG')));
S.metric = 'kurtosis';
S.save = false;
D = spm_eeg_ft_artefact_visual(S)
else
warning('No EOG channel found.');
end
close all;
%% next, magnetometer artefacts
if ~isempty(find(ismember(D.chantype,'MEGMAG')))
disp('%%% 2. MAGNETOMETERS %%%')
S = [];
S.D = D;
S.method = 'summary';
S.channel = D.chanlabels(find(ismember(D.chantype,'MEGMAG')));
S.latency = time_range*1000;
S.metric = 'var';
S.save = false;
D = spm_eeg_ft_artefact_visual(S)
else
warning('No magnetometers found.');
end
close all;
%% next, gradiometer artefacts
if ~isempty(find(ismember(D.chantype,'MEGPLANAR')))
disp('%%% 3. PLANAR GRADIOMETERS %%%')
S = [];
S.D = D;
S.method = 'summary';
S.channel = D.chanlabels(find(ismember(D.chantype,'MEGPLANAR')));
S.latency = time_range*1000;
S.metric = 'var';
S.save = false;
D = spm_eeg_ft_artefact_visual(S)
else
warning('No planar gradiometers found.');
end
close all;
%% next, gradiometer artefacts
if ~isempty(find(ismember(D.chantype,'MEGGRAD')))
disp('%%% 4. AXIAL GRADIOMETERS %%%')
S = [];
S.D = D;
S.method = 'summary';
S.channel = D.chanlabels(find(ismember(D.chantype,'MEGGRAD')));
S.latency = time_range*1000;
S.metric = 'var';
S.save = false;
D = spm_eeg_ft_artefact_visual(S)
else
warning('No axial gradiometers found.');
end
close all;
%% next, EEG artefacts
if ~isempty(find(ismember(D.chantype,'EEG')))
disp('%%% 5. EEG %%%')
S = [];
S.D = D;
S.method = 'summary';
S.channel = D.chanlabels(find(ismember(D.chantype,'EEG')));
S.latency = time_range*1000;
S.metric = 'var';
S.save = false;
D = spm_eeg_ft_artefact_visual(S);
else
warning('No EEG channels found.');
end
close all;
%% spit out some info about what has now been rejected in this file
if ~isempty(D.badchannels)
disp('Following channels are now marked as bad:');
lab = chanlabels(D);
disp(lab(badchannels(D)));
else
disp('No bad channels marked.');
end
if length(D.badtrials)>0
disp([num2str(length(D.badtrials)) ' trials of ' num2str(D.ntrials) ' are marked as bad.']);
else
disp('No bad trials identified.');
end