-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_eye.m
85 lines (83 loc) · 1.87 KB
/
pspm_eye.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
function Y = pspm_eye(X, feature)
% ● Description
% pspm_eye converts legacy use of eye markers into the current version
% ● Format
% Y = pspm_eye(X)
% ● Arguments
% X:
% Y:
% ● History
% Introduced in PsPM 6.0
% Written in 2015 by Teddy Chao (UCL)
global settings
if isempty(settings)
pspm_init;
end
switch feature
case 'lr2c'
% Examples
% 'l' → 'l'
% 'R' → 'r'
% 'lr' → 'c'
% 'rL' → 'c'
% {'L','r','Lr','rl'} → {'l','r','c','c'}
Y = lower(X);
switch class(Y)
case 'char'
switch Y
case {'lr', 'rl'}
Y = settings.lateral.char.c;
case 'l'
Y = settings.lateral.char.l;
case 'r'
Y = settings.lateral.char.r;
end
case 'cell'
Y{Y=='l'} = settings.lateral.char.l;
Y{Y=='r'} = settings.lateral.char.r;
Y{Y=='lr'} = settings.lateral.char.c;
Y{Y=='rl'} = settings.lateral.char.c;
end
case 'char2cell'
% Examples
% 'l' → {'l'}
% 'R' → {'r'}
% 'C' → {'l','r'}
% 'lR' → {'l','r'}
Y = lower(X);
switch Y
case {'l','r'}
Y = {Y};
case {'c','lr','rl'}
Y = {'l','r'};
end
case 'channel2lateral'
% Examples
% 'pupil_l' → {'l'}
% 'gaze_x_r' → {'r'}
Y = lower(X);
switch class(Y)
case 'char'
Y = pspm_single_channel_lateral(Y);
case 'cell'
for i = 1:numel(Y)
Y{i} = pspm_single_channel_lateral(Y{i});
end
end
end
return
function Y = pspm_single_channel_lateral(X)
if ~isempty(regexpi(X, '_lr', 'once'))
Y = 'c';
elseif ~isempty(regexpi(X, '_rl', 'once'))
Y = 'c';
elseif ~isempty(regexpi(X, '_c', 'once'))
Y = 'c';
elseif ~isempty(regexpi(X, '_l', 'once'))
Y = 'l';
elseif ~isempty(regexpi(X, '_r', 'once'))
Y = 'r';
else
Y = {};
end
return