> For the complete documentation index, see [llms.txt](https://help.imotions.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.imotions.com/lab/analysis/signal-processing-r-notebooks/r-notebook-raw-data-aggregation.md).

# R Notebook: Raw Data Aggregation

Run the Raw Data Aggregation R notebook to aggregate raw signal data from any sensor by stimulus across respondents, and understand the aggregation method.

*The **Raw Data Aggregation** R-Notebook aggregates the raw signal data by stimulus across respondents. This article describes how you can run this R-Notebook in iMotions and the aggregation algorithm behind.*

## 1. Prerequisites

Supported stimulus types: all

Supported sensors: all

## 2. How to Analyze in iMotions Desktop

#### As for Raw Data Aggregation R-Notebook, the following steps need to be followed:

1. Create a new analysis for the study for which you wish to run the aggregation R-Notebook.

   ![The Add Analysis button on a study in the Library](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-0b352d688758cd75a0a20712355835132fb525d1%2Flab_library_add-analysis-button.png?alt=media)
2. Advance through the steps "Segmentation settings" with your preferred selections and "Segmentation criteria" to choose respondents you want to do aggregation on until you reach the step "Signal processing".

   ![22.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-64e970cd42490f0b1fd7302a162f3a77b90adc0f%2Fb729e619ef_22-1-.webp?alt=media)

   ***Note:** the aggregation **R-Notebook will not be executed if there is only one respondent or no respondents available for aggregation.***
3. By clicking "+" next to "Active flows" you can select the algorithms you want to use for signal processing. Select the sensor for which you want to apply the aggregation R-Notebook in the drop-down "Device" menu. Select the algorithms in the drop-down “Algorithm” menu.

   ***Note:*** *it is possible now (from version 8.1 and onwards), to run the notebook on multiple sensors of the same kind. E.g., you can run the notebook on the second Shimmer device here by adding an additional Active flow with the device you would like to analyze on.*

   ![Create\_analysis.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-1242a22fdbdc8edfc4dc7cbae8462e8761edb13d%2F6eb5c4fdba_create_analysis-1-.webp?alt=media)
4. Name the analysis in the "Flow name" menu.
5. Select the stimulus to be included in the analysis. Then click the "Add" button to add the analysis and close the dialog.

   ![Add\_stimulus.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-9f832540b338e69bb1f540adbb033b83fb67eaac%2F56b681fa40_add_stimulus.webp?alt=media)

## 3. Aggregation Algorithm Introduction

1\. The R-Notebook will not be executed if there is only one respondent or no respondents available for aggregation.

2\. First, the data of all available respondents of the specified sensor and stimulus are retrieved. The raw data aggregation algorithm will be run for each signal channel of the selected sensor.

3\. Within each signal channel, the mean signal across all respondents of the specified stimulus is calculated and stored. The generated time-series mean signal is the aggregated signal.

## 4. Outputs

By clicking 'Aggregate' button at the bottom and then 'Edit Result', you can enter the aggregate replay:

![Aggregate\_button.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-8be837633c12884d8a6e51619fe8ec89449d4342%2Fe0737455c7_aggregate_button.webp?alt=media)

You can also switch to aggregate replay in the replay window by clicking 'AGGREGATE' at the top of the replay window:

![Aggregate\_button\_in\_replay\_window.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-84d5482fcf1ab012ad00feb4c157cb6113fe040f%2F5a3ddbb4ea_aggregate_button_in_replay_window.webp?alt=media)

Here in the replay window, you will see the aggregated signals of the specified stimulus and sensor. The **Falloff curve** shows how many respondents are available for aggregation over time.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.imotions.com/lab/analysis/signal-processing-r-notebooks/r-notebook-raw-data-aggregation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
