> 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/biosensor-analysis/r-notebook-spo2-oxygen-saturation.md).

# R Notebook: SpO2 Oxygen Saturation

Run the SpO2 R notebook to compute blood oxygen saturation from the Biopac OXY100E sensor, after getting the calibration values for your amplifier.

*The SpO2 Oxygen Saturation R Notebook computes, for each stimulus/respondent pair, the oxygen saturation level in the blood based on the potential signal from the Biopac sensor.*

This article will walk you through:

1. [*Prerequisites*](#prerequisites)
2. [*How to obtain calibration values for your amplifier*](#how-to-obtain-calibration-values-for-your-amplifier)
3. [*How to Analyze in iMotions Desktop*](#how-to-analyze-in-imotions-desktop)
4. [*Algorithm Introduction*](#algorithm-introduction)
5. [*Outputs:*](#outputs) [*Desktop replay*](#desktop-replay)

## Prerequisites

Supported sensors: Biopac (OXY100E)

Calibration values for your amplifier (See below)

## How to obtain calibration values for your amplifier

The SpO2 amplifier collects raw SpO2 data in Volts. These values need to be transformed into oxygen saturation values by scaling the raw data with a calibration factor. Usually, the calibration only needs to be done once, and you can save the calibration values as default once this is done (see below). You need to collect these calibration values by going through a few manual steps outlined below.

1. Turn on your Biopac system and open iMotions. Make sure the amplifier shows up in iMotions.
2. Create a new study and add a screen recording stimulus to the study.
3. Create a new respondent and start recording data from the Biopac.
4. Cycle through the calibration steps as described in the Biopac manual:

On the OXY module, use a paperclip or pen tip to press and hold the recessed “Cal” button. “Press and hold” the “Cal” button for \~1.5 seconds to switch between modes, as indicated by the Status LED states.

“Normal” Status LEDs = GREEN OFF and YELLOW OFF (YELLOW may occasionally flicker due to background processing)

“Calibration Low” Status LEDs = CONSTANT GREEN ON and YELLOW OFF “Calibration High” Status LEDs = GREEN OFF and CONSTANT YELLOW ON Release the “Cal” button as soon as the mode switches—continuously holding the button in the depressed state will not lead to another mode change. Modes cycle from normal to low, then to high, then back to normal. ? “Press and hold” the “Cal” button for \~1.5 seconds to switch to “Calibration Low” mode ? “Press and hold” the “Cal” button again for \~1.5 seconds to switch to “Calibration High” mode ? “Press and hold” the “Cal” button again for \~1.5 seconds to return to “Normal” mode

5. Stop the recording in iMotions and open up the replay editor. The Biopac signal from the SpO2 sensor will look something like this:

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

You can use the red vertical cursor to place yourself at a given point in the recording. First place the cursor at a position where the lowest value was recorded. This value is close to 0V. The value is shown in the top right corner of the graph. Move the cursor to the place in the recording where the highest value was recorded. This value should be around 7.79V. Note down both values and enter them in the analysis flow described in the next section

## How to Analyze in iMotions Desktop

1\. Create a new analysis for the study for which you wish to run the 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" and "Segmentation Criteria" with your preferred selections until you reach the step titled "Signal Processing".

![](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)

3\. By clicking the "+" next to "Active flows", you can select the algorithms you want to use for signal processing. Select the sensor ("Biopac Mp160\_SpO2 Raw") for which you want to apply the SpO2 Oxygen Saturation R Notebook in the drop-down "Device" menu. Select the algorithms in the drop-down “Algorithm” menu.

![mceclip1.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-0b6d8eaaab8698ad09ef100d8b6d812364da81a7%2F3d2d07dd99_dxa6cpcr0yu3ratuccsbgmceclip1.webp?alt=media)

4\. Name the analysis in the "Flow name" menu, and enter the calibration values you collected during the dummy recording. Save the values as default to use them in future analyses.

5\. Select the stimulus to be included in the analysis. Then click the "Add" button to add the analysis and close the dialog.

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

## Algorithm Introduction

1\. Retrieval of the voltage levels (Volt, V) that reflect the SpO2 signal status from the sensor.

2\. Calibrate the signal using the linear regression created from the calibration values. Note that this calibration process does not change from subject to subject: Low calibration value = 0% SpO2, High calibration value = 100% SpO2.

## Outputs

### Desktop replay

In the individual replays of data, the calibrated SpO2 and the calibration factor used are displayed as follows:

![mceclip2.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-0e032602f354f4c04f2ccd52aee58f11da32c340%2Fd1ef5929f2_o2njljs3v0yejikb3byvsgmceclip2.webp?alt=media)

* **Calibrated SpO2**: The calibrated SpO2 (in %) of the displayed respondent/stimulus pair.
* **SpO2 calibration factor:** The calibration factor used.


---

# 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/biosensor-analysis/r-notebook-spo2-oxygen-saturation.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.
