-
Notifications
You must be signed in to change notification settings - Fork 0
/
stm_mv.m
66 lines (52 loc) · 2.13 KB
/
stm_mv.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
classdef stm_mv < movie
%STM_MV common methods for making movie stimuli class (drift_grating
%and drift_mask.
% Detailed explanation goes here
properties
stm_duration = 3; % seconds
pre_blank_duration = 0;
pos_blank_duration = 0;
blank_color = 'gray'; % string: gray, black, white
end
properties (Dependent = true, SetAccess = private, Hidden = true)
num_frames
pre_blank_frames
pos_blank_frames
end
properties (Dependent = true, SetAccess = protected, Hidden = true)
tex % tex includes pre and post iti.
end
properties (Dependent = true, SetAccess = protected, Hidden = true, Abstract = true)
stm_tex % stm_tex only contain tex of stimulus, without pre- and post- iti.
end
methods
function MV = stm_mv(stmdur, predur, posdur)
if nargin >=1 && ~isempty(stmdur); MV.stm_duration = stmdur; end
if nargin >=2 && ~isempty(predur); MV.pre_blank_duration = predur; end
if nargin >=3 && ~isempty(posdur); MV.pos_blank_duration = posdur; end
end
function self = set.pos_blank_duration(self, pos_dur)
if ~isscalar(pos_dur)
error('only scalar input is allowed')
end
self.pos_blank_duration = pos_dur;
end
function out = get.num_frames(obj)
out = round(obj.stm_duration * obj.fps);
end
function out = get.pre_blank_frames(self)
out = round(self.fps * self.pre_blank_duration);
end
function out = get.pos_blank_frames(self)
out = round(self.fps * self.pos_blank_duration);
end
function out = get.tex(self)
c = self.color;
color=c.(self.blank_color);
single_blank_tex = ones(self.siz(2),self.siz(1))*color(1);
pre_tex = repmat(single_blank_tex,[1,1,self.pre_blank_frames]);
pos_tex = repmat(single_blank_tex,[1,1,self.pos_blank_frames]);
out = cat(3, pre_tex, self.stm_tex, pos_tex);
end
end
end