# Trim windowing

A windowing policy of type *trim* trims the temporal interval of a trial, both from the start and from the end of a specified temporal amount (e.g., 3 seconds).

The trim windowing has the following structure:

| Filed  | Type             | Value restrictions                                                                                                                                                                                                  | Is required | Default value   | Description                                                                                                                                                                                                                                                                                                                                                                 |
| ------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type` | string           | {trim}                                                                                                                                                                                                              | TRUE        | <p><br><br></p> | the type of windowing strategy                                                                                                                                                                                                                                                                                                                                              |
| `trim` | array of strings | <p>The length of the array should be two.</p><p>Valid values should have the form of a whole number followed by either "s", "m", or "h". Additional suffix "@start" or "@end" can be added to reverse the logic</p> | TRUE        | <p><br><br></p> | <p>How to trim the temporal interval of a trial to get the window. <em>\["0s", "10m"]</em> means trim 0 seconds from the start of the interval, 10 minutes from the end. <em>\["0s", "1h"]</em> means trim 0 seconds from the start, 1 hour from the end<br>\["1m", "4m\@start"] means trim 1 minute from the start to 4m after the start (a window of 3 exact minutes)</p> |
| `task` | string           | The name of a task of the workflow associated with the study                                                                                                                                                        | FALSE       | <p><br><br></p> | If the field is specified, the trim offset calculation for the window will be applied from the start time of the assigned task. Otherwise, it will be calculated from the start time of the trial.                                                                                                                                                                          |

In case a windowing policy is not specified, the default windowing corresponding to `trim[0s,0s]` is considered.

### Examples

The following fragment shows a windowing strategy of type **"trim"**, where the time window starts **10 seconds after** the beginning of the trial and ends **immediately before** the end of the trial:

```yaml
windowing: # the temporal window in which to compute the score of a trial
  type: "trim" # type of windowing is trim
  trim: [10s, 0s]
```

The following fragment shows a **trim windowing** where the time window starts **1 minute after** the beginning of the trial and ends **4 minutes from the start** of the trial. In other words, this defines a **fixed interval** with a length of **3 minutes**:

```yaml
windowing:
  type: "trim"
  trim: [1m, 4m@start]
```

The following fragment shows a **trim windowing** where the time window starts **5 minutes before the end** of the trial and ends **1 minute before the end**. In other words, this defines a **fixed interval** with a length of **4 minutes**:

```yaml
windowing:
  type: "trim"
  trim: [5m@end, 1m@end]
```

The following fragment shows a **trim windowing** where the time window starts **5 minutes before the end** of the trial and ends **10 minutes from the start**.

> **Note:** If the trial duration is shorter than 5 minutes, no windowing will take effect, and the entire trial duration will be used.

```yaml
windowing:
  type: "trim"
  trim: [5m@end, 10m@start]
```

#### **Implicit Behavior of `@start` and `@end`**

Using the `@start` suffix for the **left boundary** and the `@end` suffix for the **right boundary** is supported but optional, as they are implicitly assumed.

For example, assuming a trial duration of **10 minutes**, the following time windows yield the same result, selecting a window that starts **1 minute after the start** and ends **1 minute before the end**:

```
trim: [1m, 1m]
trim: [1m@start, 1m@end]
trim: [1m, 9m@start]
trim: [1m@start, 9m@start]
trim: [9m@end, 9m@start]
trim: [9m@end, 1m]
trim: [9m@end, 1m@end]
```

However, if the trial duration is different (e.g., **15 minutes**), the expressions **\[1m, 1m]** and **\[1m, 9m\@start]** will yield different results:

* `[1m, 1m]` → Produces a **13-minute** central interval.
* `[1m, 9m@start]` → Still produces an **8-minute** interval, as before.


---

# 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.akamas.io/akamas-docs/reference/construct-templates/study-template/windowing-strategy/trim-windowing.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.
