rs_xform_apply(data_in, xforms, aux)
[data_out,aux_out]=rs_xform_apply(data_in,xforms,aux)
applies a transformation structure to the coordinates in a dataset structure
A transformation structure is a cell array of geometric transformations.
This module can apply several types of transformations: linear, linear with offset (affine), projective, piecewise affine, and piecewise projective.
Input arguments:
-
data_in(struct) –dataset structureto be aligned containing n records, with fieldsds(cell array) –coordinate structure, ds{k}{idim} is an array of [nstims idim] of coordinates for the kth recordsas(cell array) –stimulus metadata structure, sas{k} is the stimulus metadata for the kth recordsets(cell array) –set metadata structure, sets{k} is the response metadata for the kth record
-
xforms(struct) –specification of the transformations, typically an output structure from
rs_xform_specifyts(cell array) – ts{k}{idim} is the transformation to be applied to the coordinates of dimension idim in record k; see note below regarding transformationspipeline(struct) – a structure that becomes the starting point for the 'pipeline' field of aset metadata structurewhen the transformations are applied, may be omitted; default is omitted
-
aux(struct) –auxiliary options, may be omitted, with fields
opts_xform(struct) – specification of the transformation, with fieldsclass(char) – 'affine','mean','procrustes','projective','pwaffine','pwprojective'; default is 'affine'; seetransformation structuresand note below regarding transformationsif_warn(int) – 1 (default) to show warnings
opts_check(struct) – options for consistency checking, with fieldif_warn(int) – 1 to show warnings when datasets are checked for consistency, 0 to suppress; default is 1
Output arguments:
-
data_out(struct) –a
dataset structurewith the transformations applied, same format as asdata_in -
aux_out(struct) –auxiliary outputs and parameter values used, with fields
Note regarding transformations
-
xforms.ts{k}{idim} is the transformation to be applied to record k in
data_in, i.e., to the coordinates data_in.ds{k}{idim}.- If length(xforms.ts{k})<length(data_in), transformations are used in cyclic order.
- If any of xforms.ts{k}{idim} are missing, then the coordinates in data_in.ds{k}{idim} are passed to
data_outunchanged.
-
Several classes of transformations, specified by aux.opts_xforms.class, are supported (see
transformation structures). The parameters in xforms.ts{k}{idim} have the following meaning, where output and input both have size [nstims idim], and ts=ts{k}{idim}:- affine: [output(istim,:)]=ts.b * [input(istim,:)] * ts.T + ts.c;
where size(b)=1, size(T)=[idim,idim], and size(c)=[1 idim]. If these fields are not present and xform.class='affine', then
alternative parameter names are allowed: 'scaling' for b, 'orthog' for T, and 'translation' for c.
This allows for compatibility with the transformations produced by
procrustes_consensus. - procrustes: same as affine, but ts.b=1 and abs(det(T))=1. These are not checked.
- mean: same as affine, but ts.b=1, T=0. These are not checked.
- projective: affine parameters and also p, size [isim 1]. p=0
reduces to affine. See
transformation structuresfor further details. - pwaffine (piecewise affine): b as in affine. T has size [idim idim 2^ncuts] and c
has size [2^ncuts idim], specifying the affine transformation on
each cut. vcut has size [ncuts idim], each row is a unit vector,
orthogonal to the cutplanes. acut has size [1 2^ncuts], specifying the cutpoints.
See
transformation structuresfor further details. - pwprojective (piecewise projective): parameters as in pwaffine, and also p, of size [idim, 2^ncuts], used as in projective for each component
See
transformation structuresfor further details.
- affine: [output(istim,:)]=ts.b * [input(istim,:)] * ts.T + ts.c;
where size(b)=1, size(T)=[idim,idim], and size(c)=[1 idim]. If these fields are not present and xform.class='affine', then
alternative parameter names are allowed: 'scaling' for b, 'orthog' for T, and 'translation' for c.
This allows for compatibility with the transformations produced by
See also: rs_aux_customize, rs_check_coordsets, rs_xform_specify, RS_FORM_SPECIFY_APPLY_TEST, PSG_GEOMODELS_APPLY, procrustes_compat.
Source code in src/rs_xform_apply.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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |