# Filter Variables

The filter grammar includes variables that are defined for views. You use these simply by including them in an expression that evaluates to a Boolean result, such as the following:

width > 1500// This filter returns views with a width greater than 1500.

View-level variables can be one of the following:

- Generic, available in all views.
- Tool-specific, only available for specific tool types.

For example, the trained variable is available for any view A view of an image is a region of pixels in an image. Tool processing is limited to the pixels within the view. You can manually specify a view, or you can use the results of an upstream tool to generate a view., while the precision variable is only available for Red Analyze or Blue Locate tool views.

In addition to view-level variables, the grammar also supports tool-specific, axis-level variables that you can use to filter views based on the presence, absence, or values of individual markings, labels, and other view elements. You use axis variables by including them in square brackets, following the name of the axis.

For example, the Blue Locate tool has two axes: feature A feature is a visually distinguishable area in an image. Features typically represent something of interest for the application (a defect, an object, a particular component of an object). (for found features) and match (for matched models). If you want to filter views that contain specific features, include feature, followed by square brackets containing the axis filter:

feature[x > 10 and x < 900]// This filter returns views containing a feature with an x-position between 10 and 900.

In this case, feature is the axis, and x and y are the axis-level variables.

Note:

For the region and filter axis in the Blue Locate tool, append an exclamation mark ('!') to the axis name to match labels instead of features:

feature![x > 10 and x < 900]// This filter returns views containing a label with an x-position between 10 and 900.

You can combine view-level and axis-level variables in a single expression:

trained and feature[x > 10 and x < 900]// This filter returns trained views containing a feature with an x-position between 10 and 900.

You can also use a path-delimiter ('/') to refer to axis variables in an expression.

feature/x > 10 and feature/y < 900// This filter returns trained views containing at least one feature with an x-position greater than 10, and at least one feature with a y-position less than 900.

## Generic View-Level Variables

These variables are used with any view, regardless of the Deep Learning tool.

View-level Variable | Data Type | Description
--- | --- | ---
new | Boolean | Returns all views that were added since the last training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network..
anomalous | Boolean | Returns samples where the image plane characteristics do not match the tool configuration.
all | Boolean | Returns all the views in the database.
processed | Boolean | Returns views with markings that were generated since the last training.
masked | Boolean | Returns all views that contain a mask.
invalid | Boolean | Returns all views containing invalid labels, such as empty Blue Locate tool features, or overlapping regions in a Red Analyze tool.
trained | Boolean | Returns all views that were included in the training set.
labeled | Boolean | Returns all views that contain a label.
sample_name | String | The name of sample, which may be different if multi-channel samples are being used.
filename | String | Returns the view with that filename.
added | String | Returns the date when the image was added to the workspace.
duration | Floating Point | Returns the last processing time for the view.
index | Floating Point | Returns an index of views in the enumeration of all views, from 0 to N-1. This is useful when you want to select a specific range of views.
view_index | Floating Point |
random | Floating Point | Returns a random value. This is useful to shuffle views (when used to sort views) or to select a random set of views. For example, 'random < 0.5' would select half of the views.
width | Floating Point | Returns views that match the specified width value.
height | Floating Point | Returns views that match the specified height value.
sets | String [ ] | Returns all of the views that are included in the specified set. This variable is unique, in that a vector of strings are specified in order to return a result. The following grammar summarizes the semantics of the equality, inequality, and contains operators ('~') when applied to the sets variable: sets = '<set_name>'// This returns true and the associated views if at least one element of a sets is identical to set_name. sets != '<set_name>'// This returns true and the associated views if none of the elements of sets is identical to set_name. sets ~ '<set_name>'// Returns true and the associated views if at least one element of a sets contains the string set_name. Note: You can use the contains operator ('~') to perform partial matching. For example, this syntax can be used: sets ~ "Plant17"// This returns true for views that are members of Plant17, such as "Plant17-LineA" or "Plant17-LineB", but not "Plant18-LineA".

## Tool-Specific View-Level Variables

These variables are tied to specific VisionPro Deep Learning tools, along with specific components of those tools. The variables below can be used to filter the result of processing.

Blue Locate and Blue Read Tool View Variables | Data Type | Notes
--- | --- | ---
mismatch | Boolean |
recall | Floating Point |
precision |
f_score |
best_match_string | String |
Blue Locate and Blue Read Tool - Feature Axis Variables | Data Type | Notes
covered | Boolean |
matched |
score | Floating Point |
angle |
size |
aspect_ratio |
width |
height |
x |
y |
angle_dist |
size_dist |
aspect_ratio_dist |
dist |
x_dist |
y_dist |
id | String |
covered_id |
Blue Locate and Blue Read Tool - Match Axis Variables | Data Type | Notes
covered | Boolean |
score | Floating Point |
angle |
scale |
aspect_ratio |
shear |
x |
y |
features |
name | String |
feature_string |

Green Classify Tool View Variables | Data Type | Notes
--- | --- | ---
threshold | Floating Point |
score |  |
unknown |  | Denotes an image that is labeled as an unknown (in other words, untrained) class.
mismatch |  |
best_tag | String |
validated |  | Returns only the views that are included in the validation set The validation set is a set of images reserved for validation. The validation set is separate from the training set and test set. Since the validation set is separate, it allows you to evaluate how well the tool performs when using unseen images. The VisionPro Deep Learning application calculates a special metric, the Loss. The Loss is based on the performance of the tool on the validation set. of Green Classify Standard.
not validated |  | Returns only the views that are not included in the validation Validation refers to a process during the training of a tool that helps to evaluate performance. Validation is like a mock exam that the tool takes during the training phase, separate from the final test. For example, validation helps you to recognize overfitting and avoid wasting time when training a tool. If you recognize that the tool is overfitting, you can stop the training early. set of Green Classify Standard.
outlier_score |  |
Green Classify Tool - Tag Axis Variables | Data Type | Notes
score | Floating Point |
name | String |

Red Analyze Tool View Variables | Data Type | Notes
--- | --- | ---
good | Boolean | Returns views that are labeled as good. Example: "good and score<=0.2"
negative | Returns the same results as good.
bad | Returns views that are labeled as bad. Example: "bad and score>=0.8"
positive | Returns the same results as bad.
mismatch |
recall | Floating Point | Returns the recall as the processing result. Example: "recall >= 0.7"
precision | Returns the precision as the processing result. Example: "precision>= 0.7"
f_score | Returns the f-score as the processing result. Example: "f-score>= 0.75"
th | Returns the threshold value. Example: "th>= 0.4"
score | Returns the highest defect probability. Example: "score>= 0.5"
deviation | Returns the same results as score.
validated |  | Returns only the views that are included in the validation set of Red Analyze Standard.
not validated |  | Returns only the views that are not included in the validation set of Red Analyze Standard.