# factorizationGuide

This routine runs the factorization method, prepares the result to use it as a priori information in the variational reconstruction scheme (with invNo = 8) and finally starts the reconstruction process.

Warning: `factorizationGuide` clears variables and stores figures and files in the folder `output`. The routine `eval` or `feval` is used in `setInput` and `setContrast`.

## Contents

- Syntax
- Description
- Input "Arguments"
- Output "Arguments"
- More About
- References
- See Also
- Code: function: factorizationGuide

## Syntax

    init;
    factorizationGuide;

## Description

This routine works similar to `start` as it clears variables and stores figures and files in the folder `output`. However, in contrast to `start` the input of other parameters values (than default) are not set via the parameter `inseti` but in this file.

This routine was designed for 2D. However, in principle it can be extended to 3D.

## Input "Arguments"

There are no classical input arguments because start is not a function. It follows a list of parameters which are specific for the factorization method. If the following parameters are not set below, default values will be set.

- seti.facRegFac : facRegFac*delta is the regularization parameter for factorization method (default: 1). (Note that delta is the noise level of the data.)
- seti.facNeigFac : facNeigFac*measNb is the number of used eigenvalues (facNeigFac is between 0 and 1) (default: 1).
- seti.facSepFac : Separation factor for the mask (default: 1.25).
- seti.facMaskPer : Percentage of ROI to determine the number of pixels to increase the mask (default: 2)

## Output "Arguments"

There are no classical output arguments because `factorizationGuide` is not a function. Output is stored in a subfolder of `output` like in the routine `start`.

## More About

The factorization method for inverse problems delivers information about the obstacle's shape and position. This method is restricted to plane waves and far field data. The main idea is to use this a priori information to set the pixels to zero that are (most likely) outside this shape.

Note that the factorization method's result separates the obstacle from the background but does not distinguish whether the contrast is different from zero in the real or imaginary part. This is important for the interpretation of the result.

A detailed description is given in [1].

## References

- [1] Florian Bürgel. Effective and Efficient Reconstruction Schemes for the Inverse Medium Problem in Scattering. PhD thesis, Universität Bremen, 2019.

## See Also

- start.html
- factMeth.html
- setConSplitMerge.html

## Code: function: factorizationGuide

    init;

    setInput;

Set Parameters

    factMethExample; % load parameters in structure array seti

    % Alternative parameter settings:
    %
    % factMethExampleNoReg; % no regularization via sparsity and TV
    % factMethExampleNoRegNoBounds; % no regularization via sparsity and TV and physical bounds
    %
    % defaultFactMeth; % old default parameters from defaultFactMeth

Typical Workflow

    seti = setData(seti,4,2);

Set factorization method's specific parameters

    seti.facRegFac = 1;
    seti.facNeigFac = 1;
    seti.facSepFac = 1.25;
    seti.facMaskPer = 2;
    % Note that default values until 20181019 were 1, 1, 1.5, 2.

Factorization method's default values

    dispDepth = 0;
    seti = checkfield(seti,'facRegFac',1,dispDepth);
    seti = checkfield(seti,'facNeigFac',1,dispDepth);
    seti = checkfield(seti,'facSepFac',1.25,dispDepth);
    seti = checkfield(seti,'facMaskPer',2,dispDepth);

Factorization method and post processing

    % Plot exact contrasts for comparison:
    figure(101); imagesc(real(seti.G(seti.qROIexact))); % exact contrast: real
    colorbar; axis xy; axis square; plot2DstylePublish;
    savePngFig(101,0,seti);

    figure(102); imagesc(imag(seti.G(seti.qROIexact))); % exact contrast: imag
    colorbar; axis xy; axis square; plot2DstylePublish;
    savePngFig(102,0,seti);

    % Factorization method:
    ticFac = tic;
    z = factMeth(seti); % z is a real matrix.
    tocFac = toc(ticFac);
    fprintf('Factorization method: elapsed time: %g s.\n',tocFac); % default case: 0.16 s, so 0.2 s

    % Plot factorization method's result:
    figure(103); imagesc(z);
    colorbar; axis xy; axis square; plot2DstylePublish;
    savePngFig(103,0,seti);

    % Mask of factorization method:
    seti.obsMask = factMethMask(seti,z);

    % Plot mask of factorization method:
    figure(104); imagesc(seti.G(seti.obsMask));
    colorbar; axis xy; axis square; plot2DstylePublish;
    if seti.usecbarlim
        caxis(seti.cbarlim);
    end
    savePngFig(104,0,seti);

    % Increase the mask:
    seti.obsMask = factMethMaskInc(seti,seti.obsMask);

    % Plot increased mask:
    figure(105); imagesc(seti.G(seti.obsMask));
    colorbar; axis xy; axis square; plot2DstylePublish;
    if seti.usecbarlim
        caxis(seti.cbarlim);
    end
    savePngFig(105,0,seti);

    % Prepare reconstruction: splitting in obstacle and background:
    seti = setConSplitMerge(seti); % requires seti.obsMask.

Reconstruction

    % seti.invNo = 6; % just for comparison
    seti.invNo = 8; % choose inversion method number 8 to use the mask in physical bounds
    seti = setRecon(seti,4,2); % set required fields in structure array seti for reconstruction process
    seti = recon(seti,4,2); % reconstruction of the contrast