{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "7440a5b3", "metadata": {}, "outputs": [], "source": [ "import h5py\n", "import os\n", "import warnings\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from pathlib import Path" ] }, { "cell_type": "code", "execution_count": null, "id": "2401aaef", "metadata": {}, "outputs": [], "source": [ "file_path = \"adabase-public-0001-v_0_0_2.h5py\"" ] }, { "cell_type": "code", "execution_count": null, "id": "46280999", "metadata": {}, "outputs": [], "source": [ "SKT_SR = 100\n", "ECG_SR = 500\n", "RSP_SR = 250\n", "EMG_SR = 1000\n", "EDA_SR = 500\n", "EYE_SR = 250" ] }, { "cell_type": "code", "execution_count": null, "id": "e23eb552", "metadata": {}, "outputs": [], "source": [ "df_signals = pd.read_hdf(file_path, \"SIGNALS\", mode=\"r\")\n" ] }, { "cell_type": "code", "execution_count": null, "id": "f30b8814", "metadata": {}, "outputs": [], "source": [ "# df_signals_ecg = pd.read_hdf(file_path, \"SIGNALS\", mode=\"r\", columns=[\"STUDY\",\"LEVEL\", \"PHASE\", 'RAW_ECG_I'])\n", "df_signals_ecg = df_signals[[\"STUDY\",\"LEVEL\", \"PHASE\", 'RAW_ECG_I']]\n", "df_signals_ecg.shape" ] }, { "cell_type": "code", "execution_count": null, "id": "ee80fd79", "metadata": {}, "outputs": [], "source": [ "study_filter = df_signals[\"STUDY\"] == \"n-back\"" ] }, { "cell_type": "code", "execution_count": null, "id": "3ef29446", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(16, 2))\n", "# Set the number of seconds to plot\n", "seconds = 20\n", "# Get the ECG signal data\n", "ecg_signal = df_signals.loc[study_filter, \"RAW_ECG_I\"].dropna()\n", "# Set the x-axis limits to the number of samples in the specified time range\n", "num_samples = ECG_SR * seconds\n", "# Plot the ECG signal\n", "ax.plot(ecg_signal.index[:num_samples]/1000, ecg_signal[:num_samples]);\n", "ax.set_title(\"ECG I\");\n", "ax.set_xlabel('Seconds');\n", "# Set figure size with a 16:6 aspect ratio\n", "fig, ax = plt.subplots(figsize=(16, 2))\n", "# Set the number of seconds to plot\n", "start_second = 0\n", "end_second = 60*30\n", "# Get the EYE signal data - we replace inf with nan to get the original signal.␣\n", "\n", "eye_left_signal = df_signals.loc[study_filter, \"LEFT_PUPIL_DIAMETER\"].dropna()\n", "eye_right_signal = df_signals.loc[study_filter, \"RIGHT_PUPIL_DIAMETER\"].dropna()\n", "#eye_left_signal = df_signals.loc[:, \"LEFT_PUPIL_DIAMETER\"].replace([np.inf],␣\n", "\n", "#eye_right_signal = df_signals.loc[:, \"RIGHT_PUPIL_DIAMETER\"].replace([np.inf],␣\n", "\n", "# Set the x-axis limits to the number of samples in the specified time range\n", "num_samples_start = EYE_SR * start_second\n", "num_samples_end = EYE_SR * end_second\n", "ax.plot(eye_left_signal.index[num_samples_start:num_samples_end]/1000,eye_left_signal[num_samples_start:num_samples_end], label=\"Left\")\n", "ax.plot(eye_right_signal.index[num_samples_start:num_samples_end]/1000,eye_right_signal[num_samples_start:num_samples_end], label=\"Right\")\n", "ax.set_title(\"Pupil Dilation\")\n", "ax.set_xlabel('Seconds')\n", "ax.legend()\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.12.10" } }, "nbformat": 4, "nbformat_minor": 5 }