Programmer Guide/Command Reference/EVAL/mapmind: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
This function implements a non-linear alignment algorithm for two parameter sets (each defined by a vector or matrix). The method minimizes the accumulated Euclidean distance of the two sets. The result is a two column matrix containing the index map of the alignment. The function also implements a method to create a mapped-copy of the sets.
This function implements a non-linear alignment algorithm for two parameter sets (each defined by a vector or matrix). The method minimizes the accumulated Euclidean distance of the two sets. The result is a two column matrix containing the index map of the alignment. The function also implements a method to create a mapped-copy of the sets.
----
;Usage 1:<code>mapmind(0, <var>a</var>, <var>b</var>)</code>
;Usage 1:<code>mapmind(0, <var>a</var>, <var>b</var>)</code>
:;<var>a, b</var>:Are vectors are matrices containing the two parameter sets;
:;<var>a, b</var>:Are vectors are matrices containing the two parameter sets;
:::<code>nrow(''a'')>2, nrow(''b'')>2, ncol(''a'') = ncol(''b'')</code>
:::<code>nrow(''a'')>2, nrow(''b'')>2, ncol(''a'') = ncol(''b'')</code>
::Each row of ''a''/''b'' defines one parameter value or vector (e.g. for a frame).
::Each row of ''a''/''b'' defines one parameter value or vector (e.g. for a frame).
;Result:A matrix Nx2 defining the map of the row indices of ''a'' and ''b'' with the minimum accumulated distance. The first column contains the indices for ''a'' and the second column the indices for ''b''.
:Note:To minimize the distance, individual rows of ''a'' or ''b'' are duplicated. Therefore the number of rows of the result matrix N is greater than or equal to <code>max(nrow(''a''),nrow(''b''))</code>.
----
;Usage 2:<code>mapmind(1, <var>m</var>, <var>x</var>)</code>
:;<var>m</var>:A vector containing the index map for ''x'';
:;<var>x</var>:A vector or matrix containing the parameter set to remap.
;Result 2:A vector or matrix ''r'' containing the remapped parameter set ''x''. The number of rows of ''r'' is equal to <code>nrow(''m'')</code> and the number of columns equals <code>ncol(''x'')</code>. The content of the output row <code>''r''[i,*]</code> is a copy of the input row <code>''x''[''m''[i],*]</code>.
----
;See also: [[../dist|dist]]


=====Result:=====
[[../#Functions|<function list>]]


An index map for vectors a and b with the minimum distance matrix with 2 columns, 1st column is index(a), 2nd column = index(b).


The number of rows is the length of the aligned path
Example:
<pre>
// macro "alignAB": nonlinear time alignment of two signals,
//                  using the rms track as alignment parameter
// input:  #rmsA, #rmsB ... rms tracks of signal A and B
// result: #aMat .......... alignment matrix, #aMat[*,0] = index vector for signal A
//                                            #aMat[*,1] = index vector for signal B
//                                            #aMat[*,2] = aligned rms track of signal A
//                                            #aMat[*,3] = aligned rms track of signal B


=====Usage:=====
[macro alignAB arg: #rmsA #rmsB]
 
// compute index map with minimum accumulated distance
<code>map := mapmind(1, <var>map</var>, <var>x</var>)</code>
#map := eval mapmind(0,$#rmsA,$#rmsB)
 
// remap rms track of signal A
=====Parameters:=====
if $rc == 0 #rmsAA := eval mapmind(1, $#map[*,0], $#rmsA)
 
// remap rms track of signal B
;<var>map</var>
if $rc == 0 #rmsBB := eval mapmind(1, $#map[*,1], $#rmsB)
 
// create and return the result matrix
:A vector containing the index map.
if $rc == 0 exit 1 eval vmcol($#map[*,0], $#map[*,1], $#rmsAA, $#rmsBB)
 
// this point is reached if one of the above commands fails -> error -> return empty string
;<var>x</var>
exit 1 set ''
 
</pre>
:A vector or matrix to copy or remap.
 
=====Result:=====
 
mappedX[ rows(map), columns(x) ]

Latest revision as of 11:18, 21 April 2011

This function implements a non-linear alignment algorithm for two parameter sets (each defined by a vector or matrix). The method minimizes the accumulated Euclidean distance of the two sets. The result is a two column matrix containing the index map of the alignment. The function also implements a method to create a mapped-copy of the sets.


Usage 1
mapmind(0, a, b)
a, b
Are vectors are matrices containing the two parameter sets;
nrow(a)>2, nrow(b)>2, ncol(a) = ncol(b)
Each row of a/b defines one parameter value or vector (e.g. for a frame).
Result
A matrix Nx2 defining the map of the row indices of a and b with the minimum accumulated distance. The first column contains the indices for a and the second column the indices for b.
Note:To minimize the distance, individual rows of a or b are duplicated. Therefore the number of rows of the result matrix N is greater than or equal to max(nrow(a),nrow(b)).

Usage 2
mapmind(1, m, x)
m
A vector containing the index map for x;
x
A vector or matrix containing the parameter set to remap.
Result 2
A vector or matrix r containing the remapped parameter set x. The number of rows of r is equal to nrow(m) and the number of columns equals ncol(x). The content of the output row r[i,*] is a copy of the input row x[m[i],*].

See also
dist

<function list>


Example:

// macro "alignAB": nonlinear time alignment of two signals,
//                  using the rms track as alignment parameter
// input:  #rmsA, #rmsB ... rms tracks of signal A and B
// result: #aMat .......... alignment matrix, #aMat[*,0] = index vector for signal A
//                                            #aMat[*,1] = index vector for signal B
//                                            #aMat[*,2] = aligned rms track of signal A
//                                            #aMat[*,3] = aligned rms track of signal B

[macro alignAB arg: #rmsA #rmsB]
// compute index map with minimum accumulated distance 
#map := eval mapmind(0,$#rmsA,$#rmsB)
// remap rms track of signal A
if $rc == 0 #rmsAA := eval mapmind(1, $#map[*,0], $#rmsA)
// remap rms track of signal B
if $rc == 0 #rmsBB := eval mapmind(1, $#map[*,1], $#rmsB)
// create and return the result matrix
if $rc == 0 exit 1 eval vmcol($#map[*,0], $#map[*,1], $#rmsAA, $#rmsBB)
// this point is reached if one of the above commands fails -> error -> return empty string
exit 1 set ''

Navigation menu

Personal tools