Wiki

Clone wiki

UFF / other_formats / USTB UFF Superclass

The uff superclass

Parameter Type Description
name char[] name of the dataset
reference char[] reference to the publication where the data was used/acquired
author char[] name and contact of the authors
version char[] version of the dataset
info char[] other information

The '''uff''' class defines some general methods of the UFF family, such as HDF5 read/write, copy method, as well as a unified parse input constructor.

The '''uff''' class is in turn a children of the handle class. That minimises the likekihood of overloading the memory with copies of the same data, but it can also pose some problems. Users must be aware of the fact that the symbol "=" does not make a copy of the object, but just pass a reference. To ease that problem a ''copy'' method is included in the '''uff''' class.

All UFF classes can be saved to disk. The only data structures in the '''uff''' class are those that identify the authorship of the dataset (see Table I above). In what follows we review some of the methods in the '''uff''' class.

Constructor

To unify the constructor definition all UFF classes call the constructor of the uff superclass. It is the uff constructor that handles the construction of all the classes in the UFF family.

For instance the constructor of uff.probe is

#!matlab
%% constructor
    methods (Access = public)
        function h=probe(varargin)
            h = h@uff(varargin{:});
        end
    end

The uff constructor is simplified using a parser input scheme where all arguments come in pairs of parameter name - value. For instance a uff.linear_probe can be defined as follows:

#!matlab

my_probe=uff.linear_array('N',128,'pitch',300e-6);

This removes the need to remember the parameter order. All parameters that are not in the UFF class will be ignored and a warning will be displayed. The parser input scheme is implemented by dynamically cheking the members of the UFF class. No need to change the constructor after including a new parameter in a children or granchildren UFF class.

Alternatively, if only one parameter is passed to the constructor and that parameter is of the same class that the summoned uff class, the constructor will copy the contents of the provided class into the new constructed class.

The constructor implementation can be found below.

#!matlab

 function h=uff(varargin)
            %UFF   Constructor of UFF class
            %
            %   Syntax:
            %   h = uff(varaguin)
            %
            %   See also UFF.CHANNEL_DATA, UFF.BEAMFORMED_DATA

            if nargin==1 && ~isempty(varargin) 
                % copy
                h.copy(varargin{1});
            elseif nargin>1
                eval(['mco = ?' class(h) ';']);
                plist = mco.PropertyList;
                % varagin 
                for n=1:2:(2*floor(nargin/2))
                    found=false;
                    for m=1:length(plist)
                        if strcmp(plist(m).Name,varargin{n})
                            h.(plist(m).Name)=varargin{n+1};
                            found=true;
                            continue;
                        end
                    end
                    if ~found warning(sprintf('Parameter %s not in %s',varargin{n},class(h))); end
                end                
            end
        end

Copying

As mentioned earlier the uff class is child of the handle class, and hence also the whole family is. That means that by using the operator "=" we do not produce a copy the object, but pass a reference to it. For instance, in the code below

#!matlab

my_128_probe=uff.linear_array('N',128,'pitch',300e-6);
    my_64_probe=my_128_probe;
    my_64_probe.N=64;

both probes end up having 64 elements,

#!matlab

> my_128_probe.N
ans =
    64

To avoid this, the method copy can be used instead:

#!matlab

    my_128_probe=uff.linear_array('N',128,'pitch',300e-6);
    my_64_probe=uff.linear_array();
    my_64_probe.copy(my_128_probe);
    my_64_probe.N=64;

or just using the copy option of the uff constructor

#!matlab

    my_128_probe=uff.linear_array('N',128,'pitch',300e-6);
    my_64_probe=uff.linear_array(my_128_probe); 
    my_64_probe.N=64;

The copy method can be found below.

#!matlab

 methods (Access = public)
        function copy(h,object)
            %COPY    Copy the values from another channel_data
            %
            %   Syntax:
            %   COPY(object)
            %       object       Instance of a channel_data class
            %
            %   See also SCAN, WAVE, SOURCE

            assert(isa(object,class(h)),'Class of the input object is not identical');

            % we copy all non-dependent & public properties
            list_properties=properties(object);
            for n=1:numel(list_properties)
                property_name=list_properties{n};
                mp = findprop(h,property_name);
                if strcmp(mp.GetAccess,'public')&&~mp.Dependent
                    eval(sprintf('h.%s = object.%s;',property_name,property_name));
                end
            end
        end
    end

Updated