-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstimLandoltC.m
159 lines (107 loc) · 6.13 KB
/
stimLandoltC.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
classdef stimLandoltC
%STIMLANDOLTCSummary of this function goes here
% Detailed explanation goes here
% stimLandoltC(location_pt, orientation_wd, inColor)
% draw(winPtr)
% draw(winPtr, gapLoc)
% draw(winPtr, gapLoc, location)
properties
location_pt = [100 100];
orientation_wd = 'down';
gapSize_px = 10;
size_px = 30;
frameWidth_px = 6;
frameColor_wd = 'red';
xyMatrix;
end % properties
properties(Dependent = true)
frameColor_rgb;
end % dependent properties
methods
function obj = stimLandoltC(varargin)
% constructor function for STIMLANDOLTC
% DEFAULTS
switch nargin
case 0
% use defaults
case 2
obj.location_pt = varargin{1};
obj.orientation_wd = varargin{2};
case 3
obj.location_pt = varargin{1};
obj.orientation_wd = varargin{2};
obj.frameColor_wd = varargin{3};
case 4
obj.location_pt = varargin{1};
obj.orientation_wd = varargin{2};
obj.frameColor_wd = varargin{3};
% Cortical Scaling
sizeScale = varargin{4};
obj.size_px = obj.size_px * sizeScale;
obj.gapSize_px = obj.gapSize_px * sizeScale;
obj.frameWidth_px = obj.frameWidth_px * sizeScale;
otherwise
error('Wrong number of input arguments');
end
sizeC = obj.size_px;
sizeD = obj.size_px - obj.frameWidth_px;
gapsizeC = obj.gapSize_px;
gapLocation = obj.orientation_wd;
%Make the Landolt-C shape
switch gapLocation %boxes are always made top line(s), right line(s), bottom line(s), then left line(s)
case 'up'
obj.xyMatrix=[-.5*sizeC, -.5*gapsizeC, .5*gapsizeC, .5*sizeC, .5*sizeD, .5*sizeD, -.5*sizeC, .5*sizeC, -.5*sizeD, -.5*sizeD;... % x line-pts
-.5*sizeD, -.5*sizeD, -.5*sizeD, -.5*sizeD, -.5*sizeC, .5*sizeC, .5*sizeD, .5*sizeD, -.5*sizeC, .5*sizeC]; % y line-pts
case 'right'
obj.xyMatrix=[-.5*sizeC, .5*sizeC, .5*sizeD, .5*sizeD, .5*sizeD, .5*sizeD, -.5*sizeC, .5*sizeC, -.5*sizeD, -.5*sizeD;...
-.5*sizeD, -.5*sizeD, -.5*sizeC,-.5*gapsizeC,.5*gapsizeC,.5*sizeC, .5*sizeD, .5*sizeD, -.5*sizeC, .5*sizeC];
case 'down'
obj.xyMatrix=[-.5*sizeC, .5*sizeC, .5*sizeD, .5*sizeD, -.5*sizeC, -.5*gapsizeC,.5*gapsizeC, .5*sizeC, -.5*sizeD, -.5*sizeD;...
-.5*sizeD, -.5*sizeD, -.5*sizeC, .5*sizeC, .5*sizeD, .5*sizeD, .5*sizeD, .5*sizeD, -.5*sizeC, .5*sizeC];
case 'left'
obj.xyMatrix=[-.5*sizeC, .5*sizeC, .5*sizeD,.5*sizeD, -.5*sizeC,.5*sizeC, -.5*sizeD,-.5*sizeD, -.5*sizeD, -.5*sizeD;...
-.5*sizeD,-.5*sizeD, -.5*sizeC,.5*sizeC, .5*sizeD,.5*sizeD, -.5*sizeC,-.5*gapsizeC,.5*gapsizeC,.5*sizeC];
otherwise
error('Input ErrorWrong stimulus gap location number');
end
%Create the position correction positions for the stimuli, based on the position matrix input
X=1; % array index for x-coordinate
Y=2; % array index for y-coordinate
numLinePts = size(obj.xyMatrix,2);
positionMatrix = [ repmat(obj.location_pt(X), [1 numLinePts]) ; % x line-points
repmat(obj.location_pt(Y), [1 numLinePts])]; % y line-points
obj.xyMatrix = round(obj.xyMatrix+positionMatrix); % set landolt-c matrix in final position
end % constructor method
function obj = set.frameWidth_px(obj, width_px)
if(~mod(width_px, 2))
obj.frameWidth_px = width_px;
else
error('FRAMEWIDTH_PX: frame width must be even number of pixels');
end
end % set method
function value = get.frameColor_rgb(obj)
value = seColor2RGB(obj.frameColor_wd);
end % get method
function draw(obj, winPtr, location_pt)
Screen('DrawLines', winPtr, obj.xyMatrix, obj.frameWidth_px, seColor2RGB(obj.frameColor_wd), location_pt);
end % draw method
function show(obj)
try
bgColor = 'white';
[winPtr, ~, centerPt] = seSetupScreen(seColor2RGB(bgColor));
Priority(MaxPriority(winPtr));
% ---- INSERT DRAW COMMANDS ---- %
obj.draw(winPtr, centerPt);
% ------------------------------ %
Screen('Flip', winPtr); % flip/draw buffer to display monitor
KbWait;
Screen('CloseAll'); % close psychtoolbox screen
Priority(0);
catch matlab_err
ShowCursor;
Screen('CloseAll'); % close psychtoolbox screen
display(getReport(matlab_err));
end % try-catch
end % method
end % methods
end % class def