Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,675 changes: 9,675 additions & 0 deletions developing _vitaldb_reader.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/ROSC.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,time
6 changes: 6 additions & 0 deletions examples/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 6 additions & 0 deletions examples/Untitled1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
398 changes: 398 additions & 0 deletions examples/adapt_case_3.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/case_1.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/case_2.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/case_3_reviewed.json

Large diffs are not rendered by default.

329 changes: 329 additions & 0 deletions improve_zoll.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "4736c6e4-2278-4e1a-9ff7-1f6bd6f10e0b",
"metadata": {},
"source": [
"# Improving Reading of ZOLL JSON\n",
"Notebook to examine issues of vitabel to read zoll files (as seen in vreaquence)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "41b9e3ea-2835-4b6c-b322-1c3bfb702b62",
"metadata": {},
"outputs": [],
"source": [
"from vitabel import Vitals\n",
"from pathlib import Path"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "636e17eb-6627-4515-a44a-436d22db8407",
"metadata": {},
"outputs": [],
"source": [
"filepath = Path(\"/home/gpfs/anesthesiology/vreaquence/data/processed/reareg/2024/ZOLL/48159025000007S/20090303075448_AA07B005078_ecg.txt\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "d06eeaf1-4e9f-49f9-ba60-558071ca05e1",
"metadata": {},
"outputs": [],
"source": [
"case = Vitals()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "5f0d0202-e18c-4990-b78e-0fbfc06d8e0d",
"metadata": {},
"outputs": [],
"source": [
"case.add_defibrillator_recording(filepath)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "623811f8-ea8b-4e11-b251-676f598ada61",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Length</th>\n",
" <th>First Entry</th>\n",
" <th>Last Entry</th>\n",
" <th>Offset</th>\n",
" <th>Attached Labels</th>\n",
" <th>File ID</th>\n",
" <th>Serial Nr</th>\n",
" <th>Model</th>\n",
" <th>source</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ecg2Val</td>\n",
" <td>46570</td>\n",
" <td>2009-03-03 07:54:48</td>\n",
" <td>2009-03-03 07:57:56.676000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Ecg3Val</td>\n",
" <td>46570</td>\n",
" <td>2009-03-03 07:54:48</td>\n",
" <td>2009-03-03 07:57:56.676000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Ecg4Val</td>\n",
" <td>46570</td>\n",
" <td>2009-03-03 07:54:48</td>\n",
" <td>2009-03-03 07:57:56.676000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>cc_depth_cont</td>\n",
" <td>45846</td>\n",
" <td>2009-03-03 07:54:53.300000</td>\n",
" <td>2009-03-03 07:57:56.680000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>ecg_pads</td>\n",
" <td>45845</td>\n",
" <td>2009-03-03 07:54:53.300000</td>\n",
" <td>2009-03-03 07:57:56.676000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>cc_depth</td>\n",
" <td>244</td>\n",
" <td>2009-03-03 07:54:53.604000</td>\n",
" <td>2009-03-03 07:57:56.684000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>cc_rate</td>\n",
" <td>244</td>\n",
" <td>2009-03-03 07:54:53.604000</td>\n",
" <td>2009-03-03 07:57:56.684000</td>\n",
" <td>0 days 00:00:00</td>\n",
" <td></td>\n",
" <td>20090303075448_AA07B005078_ecg.txt</td>\n",
" <td>AA07B005078</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" <td>ZOLL - AED Pro</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Length First Entry \\\n",
"0 Ecg2Val 46570 2009-03-03 07:54:48 \n",
"1 Ecg3Val 46570 2009-03-03 07:54:48 \n",
"2 Ecg4Val 46570 2009-03-03 07:54:48 \n",
"3 cc_depth_cont 45846 2009-03-03 07:54:53.300000 \n",
"4 ecg_pads 45845 2009-03-03 07:54:53.300000 \n",
"5 cc_depth 244 2009-03-03 07:54:53.604000 \n",
"6 cc_rate 244 2009-03-03 07:54:53.604000 \n",
"\n",
" Last Entry Offset Attached Labels \\\n",
"0 2009-03-03 07:57:56.676000 0 days 00:00:00 \n",
"1 2009-03-03 07:57:56.676000 0 days 00:00:00 \n",
"2 2009-03-03 07:57:56.676000 0 days 00:00:00 \n",
"3 2009-03-03 07:57:56.680000 0 days 00:00:00 \n",
"4 2009-03-03 07:57:56.676000 0 days 00:00:00 \n",
"5 2009-03-03 07:57:56.684000 0 days 00:00:00 \n",
"6 2009-03-03 07:57:56.684000 0 days 00:00:00 \n",
"\n",
" File ID Serial Nr Model \\\n",
"0 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"1 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"2 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"3 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"4 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"5 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"6 20090303075448_AA07B005078_ecg.txt AA07B005078 ZOLL - AED Pro \n",
"\n",
" source \n",
"0 ZOLL - AED Pro \n",
"1 ZOLL - AED Pro \n",
"2 ZOLL - AED Pro \n",
"3 ZOLL - AED Pro \n",
"4 ZOLL - AED Pro \n",
"5 ZOLL - AED Pro \n",
"6 ZOLL - AED Pro "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Length</th>\n",
" <th>First Entry</th>\n",
" <th>Last Entry</th>\n",
" <th>Offset</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [Name, Length, First Entry, Last Entry, Offset]\n",
"Index: []"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"case.info()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "9573b71c-7d71-4fac-a533-01f876e1ba79",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Time_of_construction': '2025-06-24 14:17:25.746164',\n",
" 'Recording_files_added': ['/home/gpfs/anesthesiology/vreaquence/data/processed/reareg/2024/ZOLL/4815902510002Y0/AR15I014960-20230204-005213-7957.json'],\n",
" 'Saving_to_json_time': ''}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a35a88ef-18f0-4fa6-b8ec-28889c3bcfd1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.13 (recto)",
"language": "python",
"name": "recto"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
12 changes: 10 additions & 2 deletions src/vitabel/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,8 @@ def plot(
)

if self.is_time_absolute():
reference_time = reference_time or self.time_start
if reference_time is None:
reference_time = self.time_start
time_index = time_index - reference_time

if time_unit is None:
Expand Down Expand Up @@ -3029,6 +3030,7 @@ def plot(

start = self._get_time_extremum(start, channel_lists, minimum=True)
stop = self._get_time_extremum(stop, channel_lists, minimum=False)

if start is None and stop is None:
logger.warning(
"Specified channels contain no data, setting start "
Expand Down Expand Up @@ -3058,10 +3060,16 @@ def plot(
stop=stop,
resolution=resolution,
time_unit=time_unit,
reference_time=start,
)

for label in label_list:
label.plot(plot_axes=subax, start=start, stop=stop, time_unit=time_unit)
label.plot(
plot_axes=subax,
start=start,
stop=stop,
time_unit=time_unit,
reference_time=start)

plot_duration = (stop - start) / pd.to_timedelta(1, unit=time_unit)
subax.set_xlim((0, plot_duration))
Expand Down
Loading