HOME Datafile definition Datafiles Datafile download: prdatafilesDatafile overload

Datafile overload

Operations and operators

All operations applied to datafiles are just stored and only executed when the content of a datafile is needed or when it is converted to a dataset by dataset(A) or A*datasetm. See the datafile definition.

Datafiles inherit many operations from datasets. A number had to be especially programmed for datafiles due to a different data structure. Some operations, however, are not possible as datafiles have no well defined dimensionality and cannot be interpreted as points in a vector space. In the below table examples are presented. In these examples A, B and C are datafiles, unless otherwise specified. The resulting datafiles always have, as far as applicable, the same fields as the original datafile. Where needed they are adapted (e.g. sizes and labels) to assure that the result is a consistent datafile.

> Examples of standard Matlab operations applied to datafiles
B = A([3 6 7],:) Construct a new datafile with just the objects 3, 6 and 7 of A.
C = [A;B] Add the objects of datafile B to those of A. A and B should be subsets of the same original datafile.
B = A+7 Add 7 to all elements of all objects of A
C = ((A>0.5).* A*7) + (A<=0.5).*A Multiply all elements of A that are larger than 0.5 by 7
mean(A,2) Returns a column vector of object averages.
std(A,[],2) Returns a column vector of object standard deviations.

The following Matlab operators are defined for datafiles:

    +, -, *, .*, .^ , /, \, ./, |, &, ~, xor, abs

Dyadic operations like C = A+B have severe restrictions. They are only implemented for datafiles A and B that refer to the same original datafile. So A and B should both be the result of, most likely different, operations on the same underlying original datafile. For instance, (C==1) & (im_unif(C)<0.9), which finds the inner contour pixels, is a valid operation as the two inputs C==1 and im_gauss(C)<0.9 refer to the same datafile C.

For dyadic operations the field settings of the first datafile are copied. Dyadic operations of datafiles and arrays of doubles are supported, provided that the dimensions fit. So all objects should have the same size for operations like this.

The logic operations

     >, >=, <, <=, =, ~=

applied to datafiles return logicals as in other, non-PRTools constructs.

Indexing

The datafile fields might be accessed by structural indexing. Indexing by B = A(I,:) results in a datafile of just the objects I. In contrast to what the notation suggests, the second dimension of the datafile variable A cannot be accessed as it has a different size for different objects in I. For this reason objects in a datafile may also be accessed by just B = A(I). This might be handy on the command line. Please, do not use it in programs as it is confusing.

The dataset routines handling the selection of objects apply to datafiles as well. For instance, if after B= A(I,:) Some classes may now have zero elements. They can be removed by the setlablist command: B = setlablist(B).

Overloaded Matlab commands

Matlab commands that are overloaded for datafiles are: abs, double, sum, min, max, mean, median, log, exp, find, hist, isempty, isfinite, isnan, size, length, plot, real, sqrt.

Matlab commands without a datafile overload may be applied to the data by the filtm command, e.g. B = filtm(A,'log10').


R.P.W. Duin, January 28, 2013


HOME Datafile definition Datafiles Datafile download: prdatafilesDatafile overload