vitabel 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. vitabel-0.0.1/.github/workflows/release.yml +31 -0
  2. vitabel-0.0.1/.github/workflows/tests.yml +32 -0
  3. vitabel-0.0.1/.gitignore +13 -0
  4. vitabel-0.0.1/LICENSE +22 -0
  5. vitabel-0.0.1/PKG-INFO +116 -0
  6. vitabel-0.0.1/README.md +73 -0
  7. vitabel-0.0.1/assets/vitabel-demo.png +0 -0
  8. vitabel-0.0.1/examples/01_defibrillator.ipynb +259 -0
  9. vitabel-0.0.1/examples/02_animal_lab.ipynb +308 -0
  10. vitabel-0.0.1/examples/03_ICU.ipynb +176 -0
  11. vitabel-0.0.1/examples/backend_datastructures.ipynb +123 -0
  12. vitabel-0.0.1/examples/data/Lucas_file_CprEventLog.xml +2340 -0
  13. vitabel-0.0.1/examples/data/Lucas_file_Lucas.xml +788 -0
  14. vitabel-0.0.1/examples/data/ZOLL_test_case.json.bz2 +0 -0
  15. vitabel-0.0.1/examples/data/capno.csv.bz2 +0 -0
  16. vitabel-0.0.1/examples/data/flow.csv.bz2 +0 -0
  17. vitabel-0.0.1/examples/data/p1.csv.bz2 +0 -0
  18. vitabel-0.0.1/examples/data/usecase_3.json +1 -0
  19. vitabel-0.0.1/examples/data/vital_file.vit +0 -0
  20. vitabel-0.0.1/pyproject.toml +47 -0
  21. vitabel-0.0.1/src/vitabel/__init__.py +10 -0
  22. vitabel-0.0.1/src/vitabel/assets/circ-classification_model.joblib +0 -0
  23. vitabel-0.0.1/src/vitabel/assets/circ-classification_scaler.joblib +0 -0
  24. vitabel-0.0.1/src/vitabel/timeseries.py +2293 -0
  25. vitabel-0.0.1/src/vitabel/utils/__init__.py +4 -0
  26. vitabel-0.0.1/src/vitabel/utils/constants.py +297 -0
  27. vitabel-0.0.1/src/vitabel/utils/helpers.py +1093 -0
  28. vitabel-0.0.1/src/vitabel/utils/loading.py +2874 -0
  29. vitabel-0.0.1/src/vitabel/utils/stylesheet.py +206 -0
  30. vitabel-0.0.1/src/vitabel/vitals.py +1738 -0
  31. vitabel-0.0.1/tests/README.md +4 -0
  32. vitabel-0.0.1/tests/__init__.py +0 -0
  33. vitabel-0.0.1/tests/conftest.py +30 -0
  34. vitabel-0.0.1/tests/data/CC_Start_acc_test_data.json +1 -0
  35. vitabel-0.0.1/tests/data/CC_Start_test_data.json +1 -0
  36. vitabel-0.0.1/tests/data/CC_Stop_acc_test_data.json +1 -0
  37. vitabel-0.0.1/tests/data/CC_Stop_test_data.json +1 -0
  38. vitabel-0.0.1/tests/data/Lucas_file_CprEventLog.xml +2340 -0
  39. vitabel-0.0.1/tests/data/Lucas_file_Lucas.xml +788 -0
  40. vitabel-0.0.1/tests/data/empty_lucas_CprEventLog.xml +33 -0
  41. vitabel-0.0.1/tests/data/empty_lucas_Lucas.xml +170 -0
  42. vitabel-0.0.1/tests/data/incomplete_lucas_Lucas.xml +170 -0
  43. vitabel-0.0.1/tests/data/sample_signals/Accelerometer.csv.bz2 +0 -0
  44. vitabel-0.0.1/tests/data/sample_signals/Alg_CC-periods.csv.bz2 +0 -0
  45. vitabel-0.0.1/tests/data/sample_signals/Ann_CC-periods.csv.bz2 +0 -0
  46. vitabel-0.0.1/tests/data/sample_signals/Capnography.csv.bz2 +0 -0
  47. vitabel-0.0.1/tests/data/sample_signals/Defibrillations.csv.bz2 +0 -0
  48. vitabel-0.0.1/tests/data/sample_signals/PhysioStatus.csv.bz2 +0 -0
  49. vitabel-0.0.1/tests/data/sample_signals/ShockElectrodes.csv.bz2 +0 -0
  50. vitabel-0.0.1/tests/data/test_channel_plot_absolute_time.png +0 -0
  51. vitabel-0.0.1/tests/data/test_channel_plot_no_data.png +0 -0
  52. vitabel-0.0.1/tests/data/test_stylesheet_demo_plot.png +0 -0
  53. vitabel-0.0.1/tests/data/time_2ecg.npy +0 -0
  54. vitabel-0.0.1/tests/data/vital_file.vit +0 -0
  55. vitabel-0.0.1/tests/test_helpers.py +23 -0
  56. vitabel-0.0.1/tests/test_timeseries.py +994 -0
  57. vitabel-0.0.1/tests/test_vitals.py +889 -0
  58. vitabel-0.0.1/uv.lock +1686 -0
@@ -0,0 +1,31 @@
1
+ name: "Release"
2
+
3
+ on:
4
+ release:
5
+ types: ["published"]
6
+
7
+ jobs:
8
+ run:
9
+ name: "Publish release"
10
+ runs-on: ubuntu-latest
11
+ environment: pypi
12
+ permissions:
13
+ id-token: write
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - uses: astral-sh/setup-uv@v5
23
+
24
+ - name: Install dependencies and package
25
+ run: uv sync
26
+
27
+ - name: Build package for distribution
28
+ run: uv build
29
+
30
+ - name: Publish package
31
+ run: uv publish
@@ -0,0 +1,32 @@
1
+ # This workflow installs the package and runs all tests
2
+
3
+ name: Tests
4
+
5
+ on:
6
+ push:
7
+ branches: [ "main" ]
8
+ pull_request:
9
+ branches: [ "main" ]
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ matrix:
16
+ os: [ubuntu-latest, macos-latest, windows-latest]
17
+ python-version: ["3.10", "3.11", "3.12"]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ - name: Install uv
26
+ uses: astral-sh/setup-uv@v5
27
+ - name: Install dependencies and package
28
+ run: |
29
+ uv sync
30
+ - name: Run tests
31
+ run: |
32
+ uv run pytest
@@ -0,0 +1,13 @@
1
+ *.pyc
2
+ __pycache__
3
+
4
+ dist
5
+
6
+ .ipynb_checkpoints
7
+ .venv
8
+
9
+ .ruff_cache
10
+ .pytest_cache
11
+ .coverage
12
+
13
+ .vscode
vitabel-0.0.1/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Benjamin Hackl, Wolfgang Kern, Simon Orlob, and individual
4
+ contributors.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
vitabel-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: vitabel
3
+ Version: 0.0.1
4
+ Summary: A toolbox for plotting and interactively labeling vital data.
5
+ Project-URL: repository, https://github.com/UniGrazMath/vitabel
6
+ Author-email: "Wolfgang J. Kern" <wolfgangjohannkern@gmail.com>, Benjamin Hackl <benjamin.hackl@uni-graz.at>, Simon Orlob <science@orlob.md>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2024, Benjamin Hackl, Wolfgang Kern, Simon Orlob, and individual
10
+ contributors.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Requires-Python: >=3.10
31
+ Requires-Dist: antropy>=0.1.6
32
+ Requires-Dist: ipykernel>=6.29.5
33
+ Requires-Dist: ipympl>=0.9.5
34
+ Requires-Dist: ipython>=8.30.0
35
+ Requires-Dist: ipywidgets>=8.1.5
36
+ Requires-Dist: matplotlib<3.10
37
+ Requires-Dist: numpy<2.0.0
38
+ Requires-Dist: pandas>=2.2.3
39
+ Requires-Dist: pyedflib>=0.1.38
40
+ Requires-Dist: scipy>=1.14.1
41
+ Requires-Dist: vitaldb>=1.4.11
42
+ Description-Content-Type: text/markdown
43
+
44
+ # vitabel: a toolbox for interactively annotating and labeling vital data
45
+
46
+ In a nutshell, the `vitabel` package allows loading, processing, and annotating vital
47
+ data (e.g., medical time-series data e.g. from defibrillators, anesthesia charts or critical care) interactively in a Jupyter notebook.
48
+
49
+ ![vitabel annotation screenshot](assets/vitabel-demo.png)
50
+
51
+ ### Installation and Usage
52
+
53
+ The latest stable release of `vitabel` is distributed via PyPI and can be installed via
54
+ ```sh
55
+ $ pip install vitabel
56
+ ```
57
+
58
+ The latest development version can be installed [from the `main` branch on
59
+ GitHub](https://github.com/UniGrazMath/vitabel) by running
60
+ ```sh
61
+ $ pip install git+https://github.com/UniGrazMath/vitabel.git
62
+ ```
63
+
64
+ The main feature of `vitabel`, interactive plots that can be used to annotate data,
65
+ is designed to work in Jupyter notebooks. Start a new server by running `jupyter notebook`
66
+ (or create a new notebook in an existing server), then import the central `Vitals` class
67
+ that acts as a container for the vital data. A set of data can be added using, for example,
68
+ the `Vitals.add_defibrillator_recording` method, or `Vitals.add_vital_db_recording`; various output formats of defibrillators
69
+ and VitalDB are supported.
70
+
71
+ A typical use of this package reads as follows:
72
+
73
+ ```py
74
+ from vitabel import Vitals, Label
75
+
76
+ # create case and load data
77
+ case = Vitals()
78
+ case.add_defibrillator_recording("path/to/ZOLL_data_file.json")
79
+
80
+ # use in-built methods for processing available data, compute etco2
81
+ # and predict circulatory state
82
+ case.compute_etco2_and_ventilations()
83
+ case.predict_circulation()
84
+
85
+ # create a new label for ROSC events
86
+ ROSC_label = Label('ROSC', plotstyle={'marker': '$\u2665$', 'color': 'red', 'ms': 10, 'linestyle': ''})
87
+ case.add_global_label(ROSC_label)
88
+
89
+ # display an interactive plot that allows annotations and further data adjustments
90
+ case.plot_interactive(
91
+ channels=[['cpr_acceleration'], ['capnography'], ['ecg_pads'], []],
92
+ labels = [['ROSC'], ['etco2_from_capnography', 'ROSC'], ['ROSC'], ['ROSC', 'rosc_probability']],
93
+ channel_overviews=[['cpr_acceleration']],
94
+ time_unit='s',
95
+ subplots_kwargs={'figsize': (22, 9)}
96
+ )
97
+ ```
98
+
99
+ More detailed explicit examples (including the required test data) are
100
+ contained in the [examples directory](/examples/).
101
+
102
+ ### Development
103
+
104
+ Setup a development environment by using the Python project and environment [management
105
+ tool `uv`](https://docs.astral.sh/uv/). To setup the environment, simply run
106
+ ```sh
107
+ uv sync
108
+ ```
109
+
110
+ Package tests are contained in [the `tests` directory](/tests/); run them locally via
111
+ ```sh
112
+ uv run pytest
113
+ ```
114
+
115
+ We use [`ruff`](https://docs.astral.sh/ruff/) for linting and formatting the code base,
116
+ and [semantic versioning](https://semver.org/) for the release tags.
@@ -0,0 +1,73 @@
1
+ # vitabel: a toolbox for interactively annotating and labeling vital data
2
+
3
+ In a nutshell, the `vitabel` package allows loading, processing, and annotating vital
4
+ data (e.g., medical time-series data e.g. from defibrillators, anesthesia charts or critical care) interactively in a Jupyter notebook.
5
+
6
+ ![vitabel annotation screenshot](assets/vitabel-demo.png)
7
+
8
+ ### Installation and Usage
9
+
10
+ The latest stable release of `vitabel` is distributed via PyPI and can be installed via
11
+ ```sh
12
+ $ pip install vitabel
13
+ ```
14
+
15
+ The latest development version can be installed [from the `main` branch on
16
+ GitHub](https://github.com/UniGrazMath/vitabel) by running
17
+ ```sh
18
+ $ pip install git+https://github.com/UniGrazMath/vitabel.git
19
+ ```
20
+
21
+ The main feature of `vitabel`, interactive plots that can be used to annotate data,
22
+ is designed to work in Jupyter notebooks. Start a new server by running `jupyter notebook`
23
+ (or create a new notebook in an existing server), then import the central `Vitals` class
24
+ that acts as a container for the vital data. A set of data can be added using, for example,
25
+ the `Vitals.add_defibrillator_recording` method, or `Vitals.add_vital_db_recording`; various output formats of defibrillators
26
+ and VitalDB are supported.
27
+
28
+ A typical use of this package reads as follows:
29
+
30
+ ```py
31
+ from vitabel import Vitals, Label
32
+
33
+ # create case and load data
34
+ case = Vitals()
35
+ case.add_defibrillator_recording("path/to/ZOLL_data_file.json")
36
+
37
+ # use in-built methods for processing available data, compute etco2
38
+ # and predict circulatory state
39
+ case.compute_etco2_and_ventilations()
40
+ case.predict_circulation()
41
+
42
+ # create a new label for ROSC events
43
+ ROSC_label = Label('ROSC', plotstyle={'marker': '$\u2665$', 'color': 'red', 'ms': 10, 'linestyle': ''})
44
+ case.add_global_label(ROSC_label)
45
+
46
+ # display an interactive plot that allows annotations and further data adjustments
47
+ case.plot_interactive(
48
+ channels=[['cpr_acceleration'], ['capnography'], ['ecg_pads'], []],
49
+ labels = [['ROSC'], ['etco2_from_capnography', 'ROSC'], ['ROSC'], ['ROSC', 'rosc_probability']],
50
+ channel_overviews=[['cpr_acceleration']],
51
+ time_unit='s',
52
+ subplots_kwargs={'figsize': (22, 9)}
53
+ )
54
+ ```
55
+
56
+ More detailed explicit examples (including the required test data) are
57
+ contained in the [examples directory](/examples/).
58
+
59
+ ### Development
60
+
61
+ Setup a development environment by using the Python project and environment [management
62
+ tool `uv`](https://docs.astral.sh/uv/). To setup the environment, simply run
63
+ ```sh
64
+ uv sync
65
+ ```
66
+
67
+ Package tests are contained in [the `tests` directory](/tests/); run them locally via
68
+ ```sh
69
+ uv run pytest
70
+ ```
71
+
72
+ We use [`ruff`](https://docs.astral.sh/ruff/) for linting and formatting the code base,
73
+ and [semantic versioning](https://semver.org/) for the release tags.
Binary file
@@ -0,0 +1,259 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "9602592c-49af-4f2c-99bb-c13b8832d9bd",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Use Case 1: Defibrillator data from real-world out-of-hospital cardiac arrest cases\n",
9
+ "#### This notebook illustrates the usage of the pyvital class to visualize, annotate and process time-series data from the medical field.\n",
10
+ "#### In this case we analyze data recorded by a defibrillator during a real-world out-of-hospital cardiac arrest case.\n"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 4,
16
+ "id": "8865d157-3791-4855-a97f-54350306fd38",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "import bz2\n",
21
+ "import tempfile\n",
22
+ "import shutil\n",
23
+ "\n",
24
+ "from vitabel import Vitals, Label\n",
25
+ "from pathlib import Path"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "markdown",
30
+ "id": "71ab307b-df58-4187-ac0e-e92cfdc54834",
31
+ "metadata": {},
32
+ "source": [
33
+ "## 1) Load Data\n",
34
+ "\n",
35
+ "An empty pyvital object is initiated and all the channels from a defibrillator recording (in this case a ZOLL X-Series case, stored in a `bz2`-compressed file) are loaded."
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": null,
41
+ "id": "680a8cdb-9363-43e7-85fe-c887eaa4923c",
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "case = Vitals()\n",
46
+ "\n",
47
+ "compressed_defi_file = Path(\"data/ZOLL_test_case.json.bz2\")\n",
48
+ "with tempfile.TemporaryDirectory() as tmpdir:\n",
49
+ " defi_file = Path(tmpdir) / compressed_defi_file.stem\n",
50
+ " with bz2.open(compressed_defi_file, \"rb\") as source:\n",
51
+ " with open(defi_file, \"wb\") as dest:\n",
52
+ " shutil.copyfileobj(source, dest)\n",
53
+ "\n",
54
+ " case.add_defibrillator_recording(defi_file)"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "markdown",
59
+ "id": "61d0fe0a-0a5b-41bf-9cf5-eb9d6a7a97a8",
60
+ "metadata": {},
61
+ "source": [
62
+ " We get an overview over all loaded channels by calling case.info()"
63
+ ]
64
+ },
65
+ {
66
+ "cell_type": "code",
67
+ "execution_count": null,
68
+ "id": "02d8aad2",
69
+ "metadata": {},
70
+ "outputs": [],
71
+ "source": [
72
+ "case.metadata"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "execution_count": null,
78
+ "id": "e0f72738-92ab-46b8-ae5f-1b99e7de719f",
79
+ "metadata": {
80
+ "scrolled": true
81
+ },
82
+ "outputs": [],
83
+ "source": [
84
+ "case.info()"
85
+ ]
86
+ },
87
+ {
88
+ "cell_type": "markdown",
89
+ "id": "db1de316-0b7e-4889-a7df-387f612acb86",
90
+ "metadata": {},
91
+ "source": [
92
+ "## 2) Process Data"
93
+ ]
94
+ },
95
+ {
96
+ "cell_type": "markdown",
97
+ "id": "da69a8fb-2221-483b-bc7f-ed12075f3f5f",
98
+ "metadata": {},
99
+ "source": [
100
+ " We use the integrated methods to determine etco2 values from the capnography signal. \\\n",
101
+ "Furthermore we use the cpr_acceleration signal and the ecg from the defibrillation pads to determine predictions for the circulatory state"
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "code",
106
+ "execution_count": null,
107
+ "id": "f5b80780-8d7e-40b1-8b71-6737bccc1342",
108
+ "metadata": {},
109
+ "outputs": [],
110
+ "source": [
111
+ "case.compute_etco2_and_ventilations()\n",
112
+ "case.predict_circulation()"
113
+ ]
114
+ },
115
+ {
116
+ "cell_type": "markdown",
117
+ "id": "3ad19543-11e8-4fa1-b7e1-e497fd5696da",
118
+ "metadata": {},
119
+ "source": [
120
+ "We want to annotate occurances of Return of spontaneous circulation (ROSC), thus we create a label and add it to our case. \n"
121
+ ]
122
+ },
123
+ {
124
+ "cell_type": "code",
125
+ "execution_count": null,
126
+ "id": "d87a3a91-9ab5-4def-bab6-7ca0fd570c37",
127
+ "metadata": {},
128
+ "outputs": [],
129
+ "source": [
130
+ "ROSC_label = Label(\n",
131
+ " \"ROSC\", plotstyle={\"marker\": \"$\\u2665$\", \"color\": \"red\", \"ms\": 10, \"linestyle\": \"\"}\n",
132
+ ")\n",
133
+ "case.add_global_label(ROSC_label)"
134
+ ]
135
+ },
136
+ {
137
+ "cell_type": "markdown",
138
+ "id": "b8fbdd2a-5511-4338-a32f-be65f7cecac8",
139
+ "metadata": {},
140
+ "source": [
141
+ " We see the new labels if check out all labels present in our case"
142
+ ]
143
+ },
144
+ {
145
+ "cell_type": "code",
146
+ "execution_count": null,
147
+ "id": "fa41b2ae-4e84-4781-8981-4bdbcd58d6e0",
148
+ "metadata": {},
149
+ "outputs": [],
150
+ "source": [
151
+ "case.get_label_names()"
152
+ ]
153
+ },
154
+ {
155
+ "cell_type": "markdown",
156
+ "id": "28ea434a-9206-4315-8bbc-78d5d628dd65",
157
+ "metadata": {},
158
+ "source": [
159
+ "## 3) Interactively Plot Data\n"
160
+ ]
161
+ },
162
+ {
163
+ "cell_type": "markdown",
164
+ "id": "6dd0dc57-1945-41a9-a442-65b08394edde",
165
+ "metadata": {},
166
+ "source": [
167
+ "We provide a setup for the interactive plot. Then we check the validity of the etco2-values and additionally label the ROSCS which we think occured in this case. "
168
+ ]
169
+ },
170
+ {
171
+ "cell_type": "code",
172
+ "execution_count": null,
173
+ "id": "25784f03-9ca4-4572-95c2-79a34b155a81",
174
+ "metadata": {},
175
+ "outputs": [],
176
+ "source": [
177
+ "plot = case.plot_interactive(\n",
178
+ " channels=[[\"cpr_acceleration\"], [\"capnography\"], [\"ecg_pads\"], []],\n",
179
+ " labels=[\n",
180
+ " [\"ROSC\"],\n",
181
+ " [\"etco2_from_capnography\", \"ROSC\"],\n",
182
+ " [\"ROSC\"],\n",
183
+ " [\"ROSC\", \"rosc_probability\"],\n",
184
+ " ],\n",
185
+ " channel_overviews=[[\"cpr_acceleration\"]],\n",
186
+ " time_unit=\"s\",\n",
187
+ " subplots_kwargs={\"figsize\": (22, 9)},\n",
188
+ ")\n",
189
+ "plot"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "markdown",
194
+ "id": "bd25a8e6-0b93-4d8c-a042-f733f010aeb4",
195
+ "metadata": {},
196
+ "source": [
197
+ "Show annotated ROSC data"
198
+ ]
199
+ },
200
+ {
201
+ "cell_type": "code",
202
+ "execution_count": null,
203
+ "id": "b51bcde7-f24a-4f70-b8de-57547dd6cf5d",
204
+ "metadata": {},
205
+ "outputs": [],
206
+ "source": [
207
+ "ROSC_label.get_data()"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "markdown",
212
+ "id": "e6e66a6d-a70d-40a3-835e-dfa7998c6522",
213
+ "metadata": {},
214
+ "source": [
215
+ "## 4) Store Data\n"
216
+ ]
217
+ },
218
+ {
219
+ "cell_type": "code",
220
+ "execution_count": null,
221
+ "id": "1b70fdc2-9650-4630-8d7f-dda463fe5972",
222
+ "metadata": {},
223
+ "outputs": [],
224
+ "source": [
225
+ "case.save_data(\"case_1.json\")\n",
226
+ "case.get_label(\"ROSC\").to_csv()"
227
+ ]
228
+ },
229
+ {
230
+ "cell_type": "code",
231
+ "execution_count": null,
232
+ "id": "00fbafcb-e999-4ee0-b809-1c91fac38fc3",
233
+ "metadata": {},
234
+ "outputs": [],
235
+ "source": []
236
+ }
237
+ ],
238
+ "metadata": {
239
+ "kernelspec": {
240
+ "display_name": ".venv",
241
+ "language": "python",
242
+ "name": "python3"
243
+ },
244
+ "language_info": {
245
+ "codemirror_mode": {
246
+ "name": "ipython",
247
+ "version": 3
248
+ },
249
+ "file_extension": ".py",
250
+ "mimetype": "text/x-python",
251
+ "name": "python",
252
+ "nbconvert_exporter": "python",
253
+ "pygments_lexer": "ipython3",
254
+ "version": "3.12.0"
255
+ }
256
+ },
257
+ "nbformat": 4,
258
+ "nbformat_minor": 5
259
+ }