-
Notifications
You must be signed in to change notification settings - Fork 0
/
regParameters.m
143 lines (133 loc) · 5.97 KB
/
regParameters.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
classdef regParameters
%UNTITLED5 Summary of this class goes here
% Detailed explanation goes here
properties
target;
type;
mode;
maskMode;
temporalFilter;
referenceSize;
vout;
end
methods
function regParameters = regParameters(target,type,mode,maskMode,temporalFilter,referenceSize,vout)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
regParameters.target = target;
regParameters.type = type;
regParameters.mode = mode;
regParameters.maskMode = maskMode;
regParameters.temporalFilter = temporalFilter;
regParameters.referenceSize = referenceSize;
regParameters.vout = vout;
end
function regParameters = set.target(regParameters,target)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
if (strcmp(target,'retina') || strcmp(target,'pupil'))
regParameters.target = target;
else
error(strcat('Expected value within [''retina'' ''pupil''] not ',target));
end
end
function regParameters = set.type(regParameters,type)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
if (strcmp(type,'translation') || strcmp(type,'rotation') || strcmp(type,'scaling'))
regParameters.type = type;
else
error(strcat('Expected value within [''translation'' ''rotation'' ''scaling''] not ',type));
end
end
function regParameters = set.mode(regParameters,mode)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
switch regParameters.type
case 'translation'
if (strcmp(mode,'static') || strcmp(mode,'cumul') || strcmp(mode,'sliding'))
regParameters.mode = mode;
else
error(strcat('Expected value within [''static'' ''cumul'' ''sliding''] not ',mode));
end
case 'scaling'
if (strcmp(mode,'static'))
regParameters.mode = mode;
else
error(strcat('Expected value within [''static''] not ',mode));
end
case 'rotation'
if (strcmp(mode,'polar') || strcmp(mode,'cartesian'))
regParameters.mode = mode;
else
error(strcat('Expected value within [''cartesian'' ''polar''] not ',mode));
end
end
end
function regParameters = set.maskMode(regParameters,maskMode)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
if (strcmp(maskMode,'none') || strcmp(maskMode,'auto') || strcmp(maskMode,'manual'))
regParameters.maskMode = maskMode;
else
error(strcat('Expected value within [''none'' ''auto'' ''manual''] not ',maskMode));
end
end
function regParameters = set.temporalFilter(regParameters,temporalFilter)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
if temporalFilter == floor(temporalFilter)
regParameters.temporalFilter = temporalFilter;
else
error(strcat('Expected value within [1 VideoLength] not ',temporalFilter));
end
end
function regParameters = set.referenceSize(regParameters,referenceSize)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
if referenceSize == floor(referenceSize)
regParameters.referenceSize = referenceSize;
else
error(strcat('Expected value within [1 VideoLength] not ',referenceSize));
end
end
function regParameters = set.vout(regParameters,vout)
%UNTITLED5 Construct an instance of this class
% Detailed explanation goes here
if islogical(vout)
regParameters.vout = vout;
else
error(strcat('Expected value within [true false] not ',vout));
end
end
function mask = getMask(obj,movie)
hwin = 10;
imax = size(movie,3);
switch obj.maskMode
case 'auto'
FilteredOriginalMovie = zeros(size(movie));
for ii = 1:imax
FilteredOriginalMovie(:,:,ii) = imgaussfilt(movie(:,:,ii),45);
end
FilteredMeanFrame = mean(FilteredOriginalMovie,3);
%imshow(FilteredMeanFrame);
mask = autoMask(FilteredMeanFrame);
figure; imshow(mask.*movie(:,:,1));
case 'manual'
referenceFrame = mean(movie(:,:,1:hwin),3);
% imshow(referenceFrame);
r = getrect;
r = int16(r);
wx = hann(r(3));
wy = hann(r(4));
[wX,wY] = meshgrid(wx,wy);
w2d = wX.*wY;
mask = zeros(size(referenceFrame));
mask(int16(r(2)):int16(r(2)+r(4)-1),int16(r(1)):int16(r(1)+r(3)-1)) = w2d;
imshow(referenceFrame .* mask);
case 'none'
mask = ones(size(mean(movie(:,:,1:hwin),3)));
end
end
end
end