setData

Sets geometry and experimental set-up, simulates the scattered field and computes noisy data (or loads real-world data).

Contents

Syntax

seti = setData(seti)
seti = setData(seti,dispDepth)
seti = setData(seti,dispDepth,out)

Description

seti = setData(seti) essentially sets the grids (seti.grid and seti.gridROI) as well as the transmitters and receivers positions (seti.incPnts and seti.measPnts), simulates the scattered field (seti.FmeasExact) and computes noisy data (seti.FmeasDelta) (or loads real-world data).

seti = setData(seti,dispDepth) does the same as seti = setData(seti) but allows to control the depth of displayed messages by dispDepth.

seti = setData(seti,dispDepth,out) does the same as seti = setData(seti,dispDepth) in case of out = 0, but plots the figures in case of out = 1 and additionally saves them in case of out = 2.

Structure of the function

Example

Example 1

init;                    % initialization
seti = struct;           % create empty structural array
seti = setData(seti);    % compute but do not plot or store figures

Example 2

init;
seti = struct;
seti = setData(seti,4);  % display output messages

Example 3

init;
setInput;   % set input and make directories for output
seti = setData(seti,4,2);    % display output messages; plot and save files and figures

Input Arguments

For a description of the following input arguments see setInput.html.

Note that many of the output arguments can by set in the struct seti as input arguments. This fields are marked by "Can be set by user (otherwise default is set)".

We only mention explictly the input arguments to deal with experimentally measured data from Institute Fresnel.

The following parameters can be set by user only in case of seti.expData = 'fresnel'

For further details see loadData.html and matchIncField.html.

Optional Input Argument

Output Arguments

For the following output arguments see setGeomSim.html:

For the following output arguments see Subfunction setFigureSettings in setGeomSim.html:

Can be set by user (otherwise default is set):

For the following output arguments see setGrid.html:

Can be set by user (otherwise default is set):

Are set automatically:

For the following output arguments see setReshapeVecMat.html:

Are set automatically:

For the following output arguments see setGridScale.html:

Can be set by user (otherwise default is set):

Are set automatically:

For the following output arguments see setIdImagReal.html:

Are set automatically:

For the following output arguments see setKernel.html:

Can be set by user (otherwise default is set):

Are set automatically:

For the following output arguments see expSetup.html:

Can be set by user (otherwise default is set):

Are set automatically:

For the following output arguments see setContrast.html:

Can be set by user (otherwise default is set):

Are set automatically:

For the following output argument see setGeomSim.html:

Note that seti.mCD unequal 0 is not supported in public version.

Can be set by user (otherwise default is set):

For the following output arguments see addNoise.html:

Can be set by user (otherwise default is set):

The following output arguments are set in setData (this function):

Can be set by user (otherwise default is set):

Are set automatically:

References

See Also

Code: setData

function seti = setData(seti,varargin)
if nargin == 1
    dispDepth = 0;
    out = 0; % plot no figures
elseif nargin == 2
    dispDepth = varargin{1};
    out = 0;
elseif nargin == 3
    dispDepth = varargin{1};
    out = varargin{2}; % output: out = 1 plots figures, out = 2 additionally saves them
else
    error('nargin has to be between 1 and 3.');
end

if isfield(seti,'expData') % load real-world data
    if strcmp(seti.expData,'fresnel')

expData: Fresnel

        seti = checkConsisExpData(seti,dispDepth);
        if dispDepth >= 1
            disp('   Loading fresnel data from:')
            fprintf('      %s\n',seti.fresnelFile)
            fprintf('      for frequency %d GHz',seti.fresnelFreq/1E9)
        end
        seti = loadData(seti,dispDepth,out); % setGeomSim is called in loadData
        % seti.qROIexact exact contrast in ROI as a vector (or zeroes if no exact contrast available)
        % seti.FmeasDelta contains the Fresnel data
    elseif strcmp(seti.expData,'simonetti')

expData: Simonetti

This case is not supported in public version.

        disp('loading Simonetti"s data') ;
        seti = loadSimonettiData(seti); % setGeomSim is called in loadData
        seti = setGeomSim(seti,dispDepth,out); % set geometry and simulation

        seti.FmeasDeltaSim = mimo(seti, seti.qROIexact, 'simo');

        seti.FmeasDelta = seti.FmeasDelta/norm(seti.FmeasDelta)*norm(seti.FmeasDeltaSim);
        seti.FmeasExact = seti.FmeasExact/norm(seti.FmeasExact)*norm(seti.FmeasDeltaSim);

        if ~isfield(seti,'gradMat')
            N = seti.nCD;
            N2 = ceil((seti.nCD-1)/2);
            seti.gradMat = circshift(diag((0:N-1)-N2), -N2*[1, 1]);
        end
    else
        error('seti.expData not found .. ?!?');
    end
else

Set data structures for geometry and simulation

    if dispDepth >= 1
        disp('-- setGeomSim --')
        disp(' ')
    end
    seti = setGeomSim(seti,dispDepth,out); % set geometry and simulation

    % Create gradient structures if seti.model='helmholtzHMode2D'
    % Note that ...HMode... is not supported in public version.
    if strcmp(seti.model,'helmholtzHMode2D')
        if ~isfield(seti,'gradMat')
            N = seti.nCD;
            N2 = ceil((seti.nCD-1)/2);
            seti.gradMat = circshift(diag((0:N-1)-N2), -N2*[1, 1]);
        end
    end

    seti = checkfield(seti,'loadFmeas','',dispDepth); % default: '', so no load...

    if ~isempty(seti.loadFmeas)
% -- load old: start --
% 		load(sprintf('%s',seti.loadFmeas)); % loads: FmeasExact and FmeasDelta
% 		seti.FmeasExact = FmeasExact; % exact data (just loaded)
% 		clear FmeasExact k directions;
% -- load old: end --
% -- load new start --
		sloaded = load(sprintf('%s',seti.loadFmeas)); % loads: FmeasExact and FmeasDelta (in struct sloaded)
		seti.FmeasExact = sloaded.FmeasExact; % exact data (just loaded)
% -- load new end --
        if dispDepth >= 1
            disp(' - FmeasExact and FmeasDelta loaded')
        end
    else
        if dispDepth >= 1
            disp(' - FmeasExact (exact data) computation')
        end
        % Note that mimo is expensive if qROI does not have many entries with 0.
        % Define qROI before operator FF and then compute FmeasExact = FF(q).
        % Be careful with mimo and wavelets because mimo is FF(q)-FmeasDelta(!).
        ticExact = tic;
		seti.FmeasExact = mimo(seti, seti.qROIexact, 'simo');
        tocExact = toc(ticExact);
        if dispDepth >= 1
            fprintf('   Elapsed time of computation of exact data is %05.1f min.\n',tocExact/60);
        end
    end

    seti = checkfield(seti,'useFmeasDelta',1,dispDepth);

    if ~isempty(seti.loadFmeas) && seti.useFmeasDelta == 1
        if dispDepth >= 1
            disp('- use FmeasDelta (use loaded data with noise)')
        end
        seti.FmeasDelta = sloaded.FmeasDelta; % noisy data was loaded
    else
        % -- add noise to data
        if dispDepth >= 1
            disp(' - add noise to data')
        end
        [seti, seti.FmeasDelta] = addNoise(seti,seti.FmeasExact,dispDepth);
    end
    % FmeasExact and FmeasDelta are saved in start.m (first construct seti.dirname)
end

Save FmeasExact and FmeasDelta

if ~isfield(seti,'expData') && out == 2
    saveDes = sprintf('%s/save_Fmeas.mat',seti.dirname);
    FmeasExact = seti.FmeasExact; %#ok (suppress MATLAB warning, because exact data will be saved)
    FmeasDelta = seti.FmeasDelta; %#ok (suppress MATLAB warning, because noisy data will be saved)
    save(saveDes,'FmeasExact','FmeasDelta');
    clear saveDes FmeasExact FmeasDelta;
end
end