-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetEOGMulti257.m
86 lines (79 loc) · 3.07 KB
/
getEOGMulti257.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
function [VEOG, HEOG] = getEOGMulti257(x257, VEOG1, VEOG2, HEOG1, HEOG2)
% [VEOG, HEOG] = getEOGMulti(x129, VEOG1, VEOG2, HEOG1, HEOG2)
% -----------------------------------------------------------------
% Blair - Nov 21, 2016
%
%
% Adapted from getEOG(x129, VEOGchannels, HEOGchannels)
% Blair - May 6, 2014
% Function takes in the 129 x N data matrix, channel numbers used to
% compute both VEOG and HEOG, and returns column vectors of VEOG
% and HEOG channels for artifact removal.
%
% Example usage
% - VEOG = 8 - 126
% - HEOG = (1 + 125)/2 - (32+128)/2
% - [v, h] = getEOGMulti(x129, 8, 126, [1 125], [32 128])
%
% Inputs
% - x129: Data frame with 129 channels
% - VEOG*, HEOG*: Numbers or vectors for EOG components such that we take
% the difference of *EOG1 and *EOG2
%
% See also getEOG computeEOG256
% This software is licensed under the 3-Clause BSD License (New BSD License),
% as follows:
% -------------------------------------------------------------------------
% Copyright 2016 Blair Kaneshiro
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright notice,
% this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright notice,
% this list of conditions and the following disclaimer in the documentation
% and/or other materials provided with the distribution.
%
% 3. Neither the name of the copyright holder nor the names of its
% contributors may be used to endorse or promote products derived from this
% software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ?AS IS?
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
if size(x257, 1) ~= 257
error('Data matrix for computing EOG must contain 257 rows.')
end
if nargin<5
error('Please provide the data matrix, as well as 2 arguments for each VEOG and HEOG component.')
end
v1 = VEOG1
v2 = VEOG2
h1 = HEOG1
h2 = HEOG2
% Compute VEOG and HEOG from x257
if isempty(v2)
VEOG = mean(x257(v1,:),1);
else
VEOG = mean(x257(v1,:),1) - mean(x257(v2,:),1);
end
if isempty(h1)
HEOG = mean(x257(h2,:),1);
elseif isempty(h2)
HEOG = mean(x257(h1,:), 1);
else
HEOG = mean(x257(h1,:),1) - mean(x257(h2,:),1);
end
% Make sure they are columns
VEOG = VEOG(:);
HEOG = HEOG(:);