Class AlgorithmParameters

  • Direct Known Subclasses:
    DataProvenanceParameters

    public class AlgorithmParameters
    extends java.lang.Object

    This class standardizes the parameter names given to many common parameters used in algorithms. It also provides helper methods to store/retrieve those common parameters.

    See Also:
    JDialogGaussianBlur
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int currentInputImageLabelNumber
      Counter used to track the number of input images stored (aka used) by an algorithm.
      static java.lang.String DO_OUTPUT_NEW_IMAGE
      Label used for the parameter indicating whether an algorithm should output a new image.
      static java.lang.String DO_PROCESS_3D_AS_25D
      Label used for the parameter indicating whether an algorithm should process a 3D image as a set of 2D slices instead of a 3D volume.
      static java.lang.String DO_PROCESS_RGB
      Label used for the parameter indicating whether to process the each channel of an RGB image (ignored for grayscale images).
      static java.lang.String DO_PROCESS_SEPARABLE
      Label used for the parameter indicating whether separable convolution kernels should be used in an algorithm.
      static java.lang.String DO_PROCESS_WHOLE_IMAGE
      Label used for the parameter indicating whether the whole image should be processed (true), or just areas within VOIs (false).
      static java.lang.String INPUT_IMAGE_LABEL_BASE
      The base of parameter labels used for an algorithm's input image(s).
      static java.lang.String NUM_ITERATIONS
      Label used for the parameter indicating the number of iterations to perform in a script action.
      protected ParameterTable params
      The list of parameters selected by the user in an algorithm's dialog, or the list of parameters to use to setup the dialog GUI.
      static java.lang.String RESULT_IMAGE
      Label used in ActionDiscovery system for main result image of an algorithm.
      static java.lang.String SIGMA_DO_Z_RES_CORRECTION
      Label used for the parameter indicating whether to correct the gaussian's standard deviation Z dimension using the ratio of the X and Z resolutions.
      static java.lang.String SIGMAS
      Label used for the parameter indicating the unnormalized/uncorrected gaussian standard deviation to be used.
      static java.lang.String USE_OPENCL
      Label used for boolean param indicating whether the algorithm should try to use OpenCL.
    • Constructor Summary

      Constructors 
      Constructor Description
      AlgorithmParameters()
      Creates a new AlgorithmParameters object to be used to record the current parameters entered into the algorithm's GUI by the user.
      AlgorithmParameters​(ParameterTable parsedParams)
      Creates a new AlgorithmParameters object to be used to set up the algorithm's GUI from stored parameters.
    • Field Detail

      • INPUT_IMAGE_LABEL_BASE

        public static final java.lang.String INPUT_IMAGE_LABEL_BASE
        The base of parameter labels used for an algorithm's input image(s). Append a '_1' to get the first image, for example.
        See Also:
        getInputImageLabel(int), Constant Field Values
      • DO_OUTPUT_NEW_IMAGE

        public static final java.lang.String DO_OUTPUT_NEW_IMAGE
        Label used for the parameter indicating whether an algorithm should output a new image.
        See Also:
        Constant Field Values
      • DO_PROCESS_WHOLE_IMAGE

        public static final java.lang.String DO_PROCESS_WHOLE_IMAGE
        Label used for the parameter indicating whether the whole image should be processed (true), or just areas within VOIs (false).
        See Also:
        Constant Field Values
      • DO_PROCESS_SEPARABLE

        public static final java.lang.String DO_PROCESS_SEPARABLE
        Label used for the parameter indicating whether separable convolution kernels should be used in an algorithm.
        See Also:
        Constant Field Values
      • DO_PROCESS_3D_AS_25D

        public static final java.lang.String DO_PROCESS_3D_AS_25D
        Label used for the parameter indicating whether an algorithm should process a 3D image as a set of 2D slices instead of a 3D volume.
        See Also:
        Constant Field Values
      • SIGMAS

        public static final java.lang.String SIGMAS
        Label used for the parameter indicating the unnormalized/uncorrected gaussian standard deviation to be used.
        See Also:
        Constant Field Values
      • SIGMA_DO_Z_RES_CORRECTION

        public static final java.lang.String SIGMA_DO_Z_RES_CORRECTION
        Label used for the parameter indicating whether to correct the gaussian's standard deviation Z dimension using the ratio of the X and Z resolutions.
        See Also:
        Constant Field Values
      • DO_PROCESS_RGB

        public static final java.lang.String DO_PROCESS_RGB
        Label used for the parameter indicating whether to process the each channel of an RGB image (ignored for grayscale images).
        See Also:
        Constant Field Values
      • NUM_ITERATIONS

        public static final java.lang.String NUM_ITERATIONS
        Label used for the parameter indicating the number of iterations to perform in a script action.
        See Also:
        Constant Field Values
      • RESULT_IMAGE

        public static final java.lang.String RESULT_IMAGE
        Label used in ActionDiscovery system for main result image of an algorithm.
        See Also:
        Constant Field Values
      • USE_OPENCL

        public static final java.lang.String USE_OPENCL
        Label used for boolean param indicating whether the algorithm should try to use OpenCL.
        See Also:
        Constant Field Values
      • currentInputImageLabelNumber

        protected int currentInputImageLabelNumber
        Counter used to track the number of input images stored (aka used) by an algorithm. This is only used while recording parameters from an algorithm's GUI.
      • params

        protected ParameterTable params
        The list of parameters selected by the user in an algorithm's dialog, or the list of parameters to use to setup the dialog GUI. This depends on whether this object is being used to store parameters or to make use of previously stored parameters.
    • Constructor Detail

      • AlgorithmParameters

        public AlgorithmParameters()
        Creates a new AlgorithmParameters object to be used to record the current parameters entered into the algorithm's GUI by the user.
      • AlgorithmParameters

        public AlgorithmParameters​(ParameterTable parsedParams)
        Creates a new AlgorithmParameters object to be used to set up the algorithm's GUI from stored parameters.
        Parameters:
        parsedParams - stored parameters which should be used to set up the algorithm's variables/GUI.
    • Method Detail

      • getInputImageLabel

        public static java.lang.String getInputImageLabel​(int inputImageNumber)
        Returns the label which should be used for an input image parameter.
        Parameters:
        inputImageNumber - Number indicating which input image this is.
        Returns:
        The label/name which should be used for this input image in the parameter table.
      • storeImageInRecorder

        public java.lang.String storeImageInRecorder​(ModelImage image)
        Store an image in the script recorder image variable table. Used to store input/output images while recording a script. Should not be used while running a script.
        Parameters:
        image - The image to store in the variable table.
        Returns:
        The image placeholder variable assigned to the image by the variable table.
      • storeImageInRunner

        public static java.lang.String storeImageInRunner​(ModelImage image)
        Store an image in the script runner image variable table. Used to store input/output images while running a script. Should not be used while recording a script.
        Parameters:
        image - The image to store in the variable table.
        Returns:
        The image placeholder variable assigned to the image by the variable table.
      • doOutputNewImage

        public boolean doOutputNewImage()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • doProcess3DAs25D

        public boolean doProcess3DAs25D()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • doProcessRGB

        public boolean[] doProcessRGB()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • doProcessSeparable

        public boolean doProcessSeparable()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • doProcessWholeImage

        public boolean doProcessWholeImage()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • doSigmaResolutionCorrection

        public boolean doSigmaResolutionCorrection()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • getNumIterations

        public int getNumIterations()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • getParams

        public ParameterTable getParams()
        Retrieves the list of parameters to either be used to run the script or store settings for future executions of the algorithm in a script.
        Returns:
        The table of parameters for this algorithm.
      • getUnnormalizedSigmas

        public float[] getUnnormalizedSigmas()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • retrieveImage

        public ModelImage retrieveImage​(java.lang.String imageParamLabel)
        Returns an image with a particular parameter name.
        Parameters:
        imageParamLabel - The parameter label of the image to retrieve.
        Returns:
        The requested image.
      • retrieveInputImage

        public ModelImage retrieveInputImage()
        Returns the first input image for the algorithm.
        Returns:
        The first input image.
        See Also:
        getInputImageLabel(int)
      • retrieveInputImage

        public ModelImage retrieveInputImage​(int inputImageNumber)
        Returns one of the algorithm's input images.
        Parameters:
        inputImageNumber - A number indicating which input image should be retrieved.
        Returns:
        The inputImageNumber-th input image.
      • setColorOptionsGUI

        public void setColorOptionsGUI​(JPanelColorChannels colorChannelPanel)
        Sets the color channel GUI panel, based on the script action's parameters. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        colorChannelPanel - The color channel panel to set the values of.
      • setOutputOptionsGUI

        public void setOutputOptionsGUI​(JPanelAlgorithmOutputOptions outputOptionsPanel)
        Sets up the algorithm output options panel components (whole image vs. VOI and new image vs. replace), based on the script action's parameters. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        outputOptionsPanel - The algorithm output options panel to set the values of.
      • setSigmasGUI

        public void setSigmasGUI​(JPanelSigmas sigmaPanel)
        Sets up the GUI containing the sigmas used in an algorithm (usually Gaussian sigmas), based on the script action's parameters. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        sigmaPanel - The sigmas panel to set up based on the parameters.
      • storeColorOptions

        public void storeColorOptions​(JPanelColorChannels colorChannelPanel)
                               throws ParserException
        Stores the values from the color channel panel in the parameter table. This function is used when recording a script. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        colorChannelPanel - The color channel panel to extract the options from.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeColorOptions

        public void storeColorOptions​(boolean processRed,
                                      boolean processGreen,
                                      boolean processBlue)
                               throws ParserException
        Stores the values of color channel processing options in the parameter table. This function is used when recording a script. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        processRed - Whether the red channel of a color image should be processed.
        processGreen - Whether the green channel of a color image should be processed.
        processBlue - Whether the blue channel of a color image should be processed.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeImage

        public java.lang.String storeImage​(ModelImage image,
                                           java.lang.String paramLabel)
                                    throws ParserException
        Stores an input image in the list of parameters for the algorithm.
        Parameters:
        image - The image to store.
        paramLabel - The label to give to the new image parameter.
        Returns:
        The image placeholder variable assigned to the image by the variable table.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeInputImage

        public java.lang.String storeInputImage​(ModelImage inputImage)
                                         throws ParserException
        Stores an input image in the list of parameters for the algorithm. This image is stored with a new parameter label incremented with each new call to this method.
        Parameters:
        inputImage - The input image to store.
        Returns:
        The image placeholder variable assigned to the image by the variable table.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeNumIterations

        public void storeNumIterations​(int numIters)
                                throws ParserException
        DOCUMENT ME!
        Parameters:
        numIters - DOCUMENT ME!
        Throws:
        ParserException - DOCUMENT ME!
      • storeOutputImageParams

        public java.lang.String storeOutputImageParams​(ModelImage outputImage,
                                                       boolean isNewImage)
                                                throws ParserException
        Stores information about the output of images for this algorithm in the parameter table. It first stores whether a new output image should be generated by the algorithm, and then (if a new image should be generated) stores the new output image in the variable table.
        Parameters:
        outputImage - The result image generated by the algorithm (may be null if isNewImage is false.
        isNewImage - Whether the algorithm should output a new image when it is executed.
        Returns:
        The new image placeholder variable assigned to the result image (or null if no output image should be generated).
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeProcessingOptions

        public void storeProcessingOptions​(boolean doWholeImage,
                                           boolean do25D)
                                    throws ParserException
        Stores options for how an algorithm should process images in the parameter table. This function is used when recording a script. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        doWholeImage - Whether to process the whole image or just VOI regions.
        do25D - Whether to process 3D images in 2.5D mode (slice by slice).
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeProcessSeparable

        public void storeProcessSeparable​(boolean doProcessSep)
                                   throws ParserException
        Stores options for an algorithm using a kernel that can process dimensions separately.
        Parameters:
        doProcessSep - Whether to use a separable filter kernel.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeProcessWholeImage

        public void storeProcessWholeImage​(boolean doWholeImage)
                                    throws ParserException
        Stores whether the whole image or just VOI regions should be processed in the parameter table. This function is used when recording a script. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        doWholeImage - Whether to process the whole image or just VOI regions.
        Throws:
        ParserException - If there is a problem creating one of the new parameter.
        See Also:
        storeProcessingOptions(boolean,boolean)
      • storeSigmas

        public void storeSigmas​(JPanelSigmas sigmaPanel)
                         throws ParserException
        Stores an algorithm's sigmas in the parameter table. This function is used when recording a script. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        sigmaPanel - The sigma GUI panel to extract the parameters from.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeSigmas

        public void storeSigmas​(float[] sigmas,
                                boolean isZCorrectionEnabled)
                         throws ParserException
        Stores an algorithm's sigmas in the parameter table. This function is used when recording a script. This is a helper function used to handle parameters common to many algorithms.
        Parameters:
        sigmas - The unnormalized sigmas (must be a 3D array).
        isZCorrectionEnabled - Whether adjustment of the Z sigma should be performed based on the ratio of x resolution to z resolution.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • storeWaterShed

        public void storeWaterShed​(float[] sigmas,
                                   boolean isZCorrectionEnabled)
                            throws ParserException
        Stores an algorithm's sigmas in the parameter table. This function is used when recording a script. This is a for the WaterShed algorithm.
        Parameters:
        sigmas - The unnormalized sigmas (must be a 3D array).
        isZCorrectionEnabled - Whether adjustment of the Z sigma should be performed based on the ratio of x resolution to z resolution.
        Throws:
        ParserException - If there is a problem creating one of the new parameters.
      • tryToStoreResultImageInRunner

        public void tryToStoreResultImageInRunner​(ModelImage resultImage)
                                           throws ParserException
        DOCUMENT ME!
        Parameters:
        resultImage - DOCUMENT ME!
        Throws:
        ParserException - DOCUMENT ME!
      • isImageStoredInRecorder

        protected static boolean isImageStoredInRecorder​(ModelImage image)
        Returns whether an image has been registered in the script recorder. If it has not been used, it must be specified externally when this script is run later.
        Parameters:
        image - The image to look for in the recorder's image table.
        Returns:
        True if the image has been stored in the recorder's image table, false otherwise.