superdsm.preprocess

class superdsm.preprocess.Preprocessing

Bases: Stage

Implements the computation of the intensity offsets (see Convex energy minimization).

This stage requires g_raw for input (the input image) and produces y for output (the offset image intensities). Refer to Inputs and outputs for more information on the available inputs and outputs.

Hyperparameters

The following hyperparameters can be used to control this pipeline stage:

preprocess/sigma1

The scale of the Gaussian filter used for denoising. Defaults to \(\sqrt{2}\).

preprocess/sigma2

The scale of the Gaussian filter \(\mathcal G_\sigma\), which is used to determine the intensity offsets \(\tau_x\) (see Convex energy minimization). Defaults to \(40\), or to AF_sigma2 × scale if configured automatically (and AF_sigma2 defaults to 1).

preprocess/offset_clip

Corresponds to \(\tau_\text{max}\) in Supplemental Material 1. Defaults to \(3\).

preprocess/lower_clip_mean

If True, intensity offsets \(\tau_x\) smaller than the mean image intensity are set to the mean image intensity. Defaults to False.

configure(pipeline, input_id, *args, scale, **kwargs)

Returns the rules to adopt hyperparameters based on the input data.

Sometimes it can be necessary to automatically adopt hyperparameters based on the input data. For those cases where linear adoptation is suitable, this method can be overridden to return the rules which specify how to adopt the hyperparameters. The rules are then applied by the repype.pipeline.Pipeline.configure() method.

The rules must be specified by the following structure:

{
    'key': [
        factor,
        default_user_factor,
    ],
}

The rules are resolved by mapping the above structure to the arguments of the repype.pipeline.create_config_entry() function. In this example, two new hyperparameters are created:

  1. The hyperparameter AF_key is created and defaults to the value of default_user_factor.

  2. The hyperparameter key is created and defaults to the value of the hyperparameter AF_key times the value of factor.

In addition, a third element can be added to the list to further constrain the resulting values:

{
    'key': [
        factor,
        default_user_factor,
        {
            type: 'float',
            min: 0.0,
            max: 1.0,
        },
    ],
}
Parameters:
  • pipeline – The pipeline object that this stage is a part of.

  • input_id – The identifier of the input data to adopt the hyperparameters for.

  • *args – Sequential arguments passed to Pipeline.configure.

  • **kwargs – Keyword arguments passed to Pipeline.configure.

id: str = 'preprocess'

The stage identifier.

inputs: Collection[str] = ['g_raw']

List of fields read by this stage.

outputs: Collection[str] = ['y']

List of fields produced by this stage.

process(g_raw, pipeline, config, status=None)

Processes the input fields of this stage of the pipeline.

This method implements a stage of the pipeline with the provided inputs and configuration parameters. It then returns the outputs produced by the stage.

Parameters:
  • pipeline – The pipeline object that this stage is a part of.

  • config – The hyperparameters to be used for this stage.

  • status – A status object to report the progress of the computations.

  • **inputs – The fields of the pipeline read by this stage. Each key-value pair represents an input field and the corresponding value.

Returns:

A dictionary containing the outputs of this stage. Each key-value pair in the dictionary represents an output field and the corresponding value.

Raises:

NotImplementedError – If the method is not implemented by the subclass.