# Logic

The Logic stage directs tasks to different outputs according to logical rules you set.

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FthZjOlBR5jYrUnkqUsuB%2Fimage.png?alt=media&#x26;token=95e41149-16ac-4641-a966-91d0a03758ce" alt="" width="240"><figcaption></figcaption></figure>

## Settings

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FM1bUe4n8H9iSbeacu2Cm%2Fimage.png?alt=media&#x26;token=b1daed1c-6f8a-46a0-a545-0f436a28b18a" alt=""><figcaption></figcaption></figure>

From the Logic stage's settings panel, you can pick one or more logical functions (rules) with which to direct tasks.

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FAYOBcyn5C8dpPVuP0UjQ%2Fimage.png?alt=media&#x26;token=67897eca-cd84-40e5-9b66-b1fd76c4234f" alt=""><figcaption></figcaption></figure>

Rules will be run top to bottom. When a task is sent to the logic stage, the first rule will be run on the task. If the task matches the rule, then it will be sent out from that rule's output. If not, the second rule will be run on the task, and so on. If, after running all rules, none match, the task is sent out from the 'Else' output.

The Settings panel will start you off with a single rule. To add more rules, click on the <img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FOfaRTyjVZ1x0gXgqP1Wy%2Fimage.png?alt=media&#x26;token=c6fe97bd-3188-4026-a483-2848634e8a97" alt="" data-size="line"> button. To remove a rule, click on the <img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FNzZFg4Io0XL7xfW9NK7k%2Fimage.png?alt=media&#x26;token=94b41bea-3257-486c-8434-71c9983476b1" alt="" data-size="line"> button to the rule's number:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FKQhFL5ksuFex4Wll88ZQ%2Fimage.png?alt=media&#x26;token=08404345-c6ad-474b-89d8-c20449e5063c" alt=""><figcaption></figcaption></figure>

## Rule Options

### Annotation Type

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FyGiBctgLab7KzccMPrdq%2Fimage.png?alt=media&#x26;token=eb37187b-7beb-4897-8e6f-864b94f6a5d3" alt=""><figcaption></figcaption></figure>

Returns as output tasks which contain a specific annotation type, such as an object or a classification answer. All conditions must be true for the logic stage to send the task from the `true` output.

In the example above, for a task to be sent from `true`, it must have a Vehicle-class object, and it must not have a Person-class object. If any of those is false (e.g. it does not have a vehicle, or it has a person) then the task will be sent out from the `False` output. (in short, assume there is an "AND" operator between all conditions.

### Annotator

Returns as output tasks which were annotated by one or more annotators you specify.

### Random Sample

![](https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FhUe19xUkMIN3nDT6ANQr%2Fimage.png?alt=media\&token=02e5946d-4863-4178-bebe-f93805b40844)

Returns as output a random percentage of tasks. For example, if you enter 55%, a randomly selected \~55% of tasks will be sent from the True output and a \~45% of tasks from the False output.

{% hint style="warning" %}
The percentage you set in the *Random Sample* logic gate is the likelihood a task passed in is passed out from the True output.

For example, if you set the percentage to 50%, each asset passed in has a 50% chance of being passed out from the True output. This calculation is repeated for each asset passed in and is independent from the number of tasks passed to the outputs before.

As a result of this, asset numbers passed out might be slightly different from what you expect. For example, setting up a 20% / 80% ratio and then sending through 100 items might result in a 83/17 split. Similarly, setting the percentage to 50% on a batch of 10'000 assets may lead to a 4998/5002 split instead of a precise 5000/5000 one.

Because of the way the random sample logic stage works, the more assets are passed to it, the smaller the divergence from your intended percentage. Passing only 4 assets with a 50/50 split may cause a 0/4 or a 1/3 split, while larger datasets will tend towards the average, causing a lower divergence from the intended ratio.
{% endhint %}

### Task Duration

Returns as output tasks based on how long it has taken to annotate them.

### Batch

Returns as output tasks belonging to one or more batches you specify.

### Issue Error Code

Returns as output tasks having at least one issue with an error code you specify.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imerit.net/core-concepts/workflow/logic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
