Package gov.nih.mipav.view.dialogs
Class AlgorithmParameters
- java.lang.Object
-
- gov.nih.mipav.view.dialogs.AlgorithmParameters
-
- Direct Known Subclasses:
DataProvenanceParameters
public class AlgorithmParameters extends java.lang.ObjectThis 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 intcurrentInputImageLabelNumberCounter used to track the number of input images stored (aka used) by an algorithm.static java.lang.StringDO_OUTPUT_NEW_IMAGELabel used for the parameter indicating whether an algorithm should output a new image.static java.lang.StringDO_PROCESS_3D_AS_25DLabel 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.StringDO_PROCESS_RGBLabel used for the parameter indicating whether to process the each channel of an RGB image (ignored for grayscale images).static java.lang.StringDO_PROCESS_SEPARABLELabel used for the parameter indicating whether separable convolution kernels should be used in an algorithm.static java.lang.StringDO_PROCESS_WHOLE_IMAGELabel used for the parameter indicating whether the whole image should be processed (true), or just areas within VOIs (false).static java.lang.StringINPUT_IMAGE_LABEL_BASEThe base of parameter labels used for an algorithm's input image(s).static java.lang.StringNUM_ITERATIONSLabel used for the parameter indicating the number of iterations to perform in a script action.protected ParameterTableparamsThe 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.StringRESULT_IMAGELabel used in ActionDiscovery system for main result image of an algorithm.static java.lang.StringSIGMA_DO_Z_RES_CORRECTIONLabel 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.StringSIGMASLabel used for the parameter indicating the unnormalized/uncorrected gaussian standard deviation to be used.static java.lang.StringUSE_OPENCLLabel 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandoOutputNewImage()DOCUMENT ME!booleandoProcess3DAs25D()DOCUMENT ME!boolean[]doProcessRGB()DOCUMENT ME!booleandoProcessSeparable()DOCUMENT ME!booleandoProcessWholeImage()DOCUMENT ME!booleandoSigmaResolutionCorrection()DOCUMENT ME!static java.lang.StringgetInputImageLabel(int inputImageNumber)Returns the label which should be used for an input image parameter.intgetNumIterations()DOCUMENT ME!ParameterTablegetParams()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.float[]getUnnormalizedSigmas()DOCUMENT ME!protected static booleanisImageStoredInRecorder(ModelImage image)Returns whether an image has been registered in the script recorder.ModelImageretrieveImage(java.lang.String imageParamLabel)Returns an image with a particular parameter name.ModelImageretrieveInputImage()Returns the first input image for the algorithm.ModelImageretrieveInputImage(int inputImageNumber)Returns one of the algorithm's input images.voidsetColorOptionsGUI(JPanelColorChannels colorChannelPanel)Sets the color channel GUI panel, based on the script action's parameters.voidsetOutputOptionsGUI(JPanelAlgorithmOutputOptions outputOptionsPanel)Sets up the algorithm output options panel components (whole image vs.voidsetSigmasGUI(JPanelSigmas sigmaPanel)Sets up the GUI containing the sigmas used in an algorithm (usually Gaussian sigmas), based on the script action's parameters.voidstoreColorOptions(boolean processRed, boolean processGreen, boolean processBlue)Stores the values of color channel processing options in the parameter table.voidstoreColorOptions(JPanelColorChannels colorChannelPanel)Stores the values from the color channel panel in the parameter table.java.lang.StringstoreImage(ModelImage image, java.lang.String paramLabel)Stores an input image in the list of parameters for the algorithm.java.lang.StringstoreImageInRecorder(ModelImage image)Store an image in the script recorder image variable table.static java.lang.StringstoreImageInRunner(ModelImage image)Store an image in the script runner image variable table.java.lang.StringstoreInputImage(ModelImage inputImage)Stores an input image in the list of parameters for the algorithm.voidstoreNumIterations(int numIters)DOCUMENT ME!java.lang.StringstoreOutputImageParams(ModelImage outputImage, boolean isNewImage)Stores information about the output of images for this algorithm in the parameter table.voidstoreProcess3DAs25D(boolean doProcess3DAs25D)voidstoreProcessingOptions(boolean doWholeImage, boolean do25D)Stores options for how an algorithm should process images in the parameter table.voidstoreProcessSeparable(boolean doProcessSep)Stores options for an algorithm using a kernel that can process dimensions separately.voidstoreProcessWholeImage(boolean doWholeImage)Stores whether the whole image or just VOI regions should be processed in the parameter table.voidstoreSigmas(float[] sigmas, boolean isZCorrectionEnabled)Stores an algorithm's sigmas in the parameter table.voidstoreSigmas(JPanelSigmas sigmaPanel)Stores an algorithm's sigmas in the parameter table.voidstoreWaterShed(float[] sigmas, boolean isZCorrectionEnabled)Stores an algorithm's sigmas in the parameter table.voidtryToStoreResultImageInRunner(ModelImage resultImage)DOCUMENT ME!
-
-
-
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 ParserExceptionStores 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 ParserExceptionDOCUMENT 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 benullifisNewImageisfalse.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
nullif no output image should be generated). - Throws:
ParserException- If there is a problem creating one of the new parameters.
-
storeProcess3DAs25D
public void storeProcess3DAs25D(boolean doProcess3DAs25D) throws ParserException- Parameters:
doProcess3DAs25D- 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.- See Also:
storeProcessingOptions(boolean,boolean)
-
storeProcessingOptions
public void storeProcessingOptions(boolean doWholeImage, boolean do25D) throws ParserExceptionStores 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 ParserExceptionStores 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 ParserExceptionStores 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 ParserExceptionStores 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 ParserExceptionStores 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:
Trueif the image has been stored in the recorder's image table,falseotherwise.
-
-