diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m')
| -rw-r--r-- | sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m new file mode 100644 index 00000000..9790221c --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m @@ -0,0 +1,70 @@ +% Let the user draw a square with the mouse, +% and then click on the corners to do a manual segmentation + +ss = 6; +Q1 = 1; Q2 = 2; Q3 = 3; obsvel = 6; +CLOCKWISE = 1; ANTICLOCK = 2; +LR = 1; UD = 2; RL = 3; DU = 4; + +% repeat this block manually incrementing the sequence number +% and setting ori. +% (since I don't know how to call getmouse as a call-return function). +seq = 4; +%ori = CLOCKWISE +ori = ANTICLOCK; +clear xpos ypos +getmouse +% end block + +% manual segmentation with the mouse +startseg(1) = 1; +for i=2:4 + fprintf('click on start of segment %d\n', i); + [x,y] = ginput(1); + plot(x,y,'ro') + d = dist2([xpos; ypos]', [x y]); + startseg(i) = argmin(d); +end + +% plot corners in green +%ti = first point in (i+1)st segment +t1 = startseg(1); t2 = startseg(2); t3 = startseg(3); t4 = startseg(4); +plot(xpos(t2), ypos(t2), 'g*') +plot(xpos(t3), ypos(t3), 'g*') +plot(xpos(t4), ypos(t4), 'g*') + + +xvel = xpos(2:end) - xpos(1:end-1); +yvel = ypos(2:end) - ypos(1:end-1); +speed = [xvel(:)'; yvel(:)']; +pos_data{seq} = [xpos(:)'; ypos(:)']; +vel_data{seq} = [xvel(:)'; yvel(:)']; +T = length(xvel); +Q1label{seq} = num2cell(repmat(ori, 1, T)); +Q2label{seq} = zeros(1, T); +if ori == CLOCKWISE + Q2label{seq}(t1:t2) = LR; + Q2label{seq}(t2+1:t3) = UD; + Q2label{seq}(t3+1:t4) = RL; + Q2label{seq}(t4+1:T) = DU; +else + Q2label{seq}(t1:t2) = RL; + Q2label{seq}(t2+1:t3) = UD; + Q2label{seq}(t3+1:t4) = LR; + Q2label{seq}(t4+1:T) = DU; +end + +% pos_data{seq}(:,t), vel_data{seq}(:,t) Q1label{seq}(t) Q2label{seq}(t) +save 'square4' pos_data vel_data Q1label Q2label + +nseq = 4; +cases = cell(1,nseq); +for seq=1:nseq + T = size(vel_data{seq},2); + ev = cell(ss,T); + ev(obsvel,:) = num2cell(vel_data{seq},1); + ev(Q1,:) = Q1label{seq}; + ev(Q2,:) = num2cell(Q2label{seq}); + cases{seq} = ev; +end +save 'square4_cases' cases |
