Package gov.nih.mipav.model.scripting
Class Parser
java.lang.Object
gov.nih.mipav.model.scripting.Parser
This is the main class used to parse and run scripts. It may also be used to retrieve the image placeholder variables
(e.g., $image1) used in a script and the number of VOIs required for a particular image placeholder.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final String[]getActionsForImagesUsedInScript(String scriptFile) Returns an array of the actions in which external images are used in a given script.static final String[]getImageLabelsUsedInScript(String scriptFile) Returns an array of image parameters labels used in a given script.static final String[]getImageVarsUsedInScript(String scriptFile) Returns an array of image placeholder variables used in a given script.static final intgetNumberOfVOIsRequiredForImageVar(String scriptFile, String imageVarName) Returns the number of VOIs which will be opened for a given image (imageVarName) when a particular script is run.private static StringgetVOIParentImage(ParsedActionLine parsedLine) Returns the image placeholder variable referenced by an 'OpenVOI' action.private static booleanhasExitAction(String scriptFile) Search the script file for an Exit action (required when running in hidden GUI mode from the command line).private static booleanisOpenVOIAction(String action) Returns whether a action string would result in the opening of a VOI.static final voidParses and runs the commands contained within a given script file.
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
getActionsForImagesUsedInScript
public static final String[] getActionsForImagesUsedInScript(String scriptFile) throws ParserException Returns an array of the actions in which external images are used in a given script.- Parameters:
scriptFile- The full path to the script file on disk which should be parsed.- Returns:
- An array of the names of script actions which use each external image parameter in the given script in the same order as getImageVarsUsedInScript().
- Throws:
ParserException- If a problem is encountered while parsing the script.
-
getImageLabelsUsedInScript
Returns an array of image parameters labels used in a given script.- Parameters:
scriptFile- The full path to the script file on disk which should be parsed.- Returns:
- An array of the image parameter labels (e.g., input_image_1 or reference_image) used in
scriptFilein the same order as getImageVarsUsedInScript(). - Throws:
ParserException- If a problem is encountered while parsing the script.
-
getImageVarsUsedInScript
Returns an array of image placeholder variables used in a given script.- Parameters:
scriptFile- The full path to the script file on disk which should be parsed.- Returns:
- An array of the image placeholder variables (e.g. $image1) used in
scriptFile. - Throws:
ParserException- If a problem is encountered while parsing the script.
-
getNumberOfVOIsRequiredForImageVar
public static final int getNumberOfVOIsRequiredForImageVar(String scriptFile, String imageVarName) throws ParserException Returns the number of VOIs which will be opened for a given image (imageVarName) when a particular script is run.- Parameters:
scriptFile- The full path to the script file on disk which should be parsed.imageVarName- The image placeholder variable (e.g. $image1) for which to count required VOIs.- Returns:
- The number of VOIs required for the given
imageVarName. - Throws:
ParserException- If a problem is encountered while parsing the script.
-
runScript
Parses and runs the commands contained within a given script file.- Parameters:
scriptFile- The full path to the script file on disk which should be parsed.- Throws:
ParserException- If a problem is encountered while parsing the script.
-
getVOIParentImage
Returns the image placeholder variable referenced by an 'OpenVOI' action.- Parameters:
parsedLine- A parsed line from a script (should be an 'OpenVOI' action).- Returns:
- The image placeholder variable for the image the VOI will be loaded into.
-
hasExitAction
Search the script file for an Exit action (required when running in hidden GUI mode from the command line).- Parameters:
scriptFile- The full path to the script file on disk which should be parsed.- Returns:
Trueif the script contains an Exit command,falseotherwise.- Throws:
ParserException- If a problem is encountered while parsing the script.
-
isOpenVOIAction
Returns whether a action string would result in the opening of a VOI.- Parameters:
action- The action string to check.- Returns:
- Whether the given action will open a VOI.
-