From 1404b917403a29164cd07b2909f810b76a5ff804 Mon Sep 17 00:00:00 2001 From: Felix Mucha <3016498@stud.hs-mannheim.de> Date: Mon, 3 Jun 2024 21:08:46 +0200 Subject: [PATCH] first comments --- notebooks/features_bib_neurokit2.ipynb | 55 +++++++++++++++----------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/notebooks/features_bib_neurokit2.ipynb b/notebooks/features_bib_neurokit2.ipynb index 50948dd..3c10b0b 100644 --- a/notebooks/features_bib_neurokit2.ipynb +++ b/notebooks/features_bib_neurokit2.ipynb @@ -697,21 +697,9 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 44, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 lead R Axis: 56.83 degrees\n", - "2 lead T Axis: 30.78 degrees\n", - "\n", - "6 lead R Axis: 56.83 degrees\n", - "6 lead T Axis: 30.78 degrees\n" - ] - } - ], + "outputs": [], "source": [ "def calculate_axis(data, leads, sampling_rate=500, aVF=5, I=0):\n", " # warnining if leads not include 0 and 5 or one lead is over 5\n", @@ -743,6 +731,7 @@ " t_peaks = [ecg_signal[int(i)] for i in info['ECG_T_Peaks'] if not math.isnan(i)]\n", " net_t[lead] = np.mean(t_peaks) if t_peaks else 0\n", "\n", + " print(net_qrs.get(aVF, 0), net_qrs.get(I, 0))\n", " # Calculate the R axis (Convert to degrees)\n", " r_axis = np.arctan2(net_qrs.get(aVF, 0), net_qrs.get(I, 0)) * (180 / np.pi)\n", "\n", @@ -752,25 +741,47 @@ " return r_axis, t_axis\n", "\n", "\n", - "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate R and T Axis for one dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.8047692058411333 0.5260930603345693\n", + "2 lead R Axis: 56.83 degrees\n", + "2 lead T Axis: 30.78 degrees\n", + "\n" + ] + } + ], + "source": [ "# print(data_org['SB'][0].__dict__) 'sig_name': ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']\n", "\n", "i_sig = 0\n", "avf = 5\n", "sampling_rate = 500\n", "\n", - "ecg_signal_i = filtered_data.p_signal[:,i_sig]\n", + "example_data = data_org['SB'][0]\n", + "filtered_data = data_helper.filter_data(example_data, filter_params)\n", "\n", - "ecg_cleaned_i = nk.ecg_clean(ecg_signal_i, sampling_rate=sampling_rate)\n", "\n", "r_ax, t_ax = calculate_axis(filtered_data, [0, 5], sampling_rate=500)\n", "print(f\"2 lead R Axis: {r_ax:.2f} degrees\")\n", "print(f\"2 lead T Axis: {t_ax:.2f} degrees\")\n", - "print(\"\")\n", - "\n", - "r_ax, t_ax = calculate_axis(filtered_data, [0, 1, 2, 3, 4, 5], sampling_rate=500)\n", - "print(f\"6 lead R Axis: {r_ax:.2f} degrees\")\n", - "print(f\"6 lead T Axis: {t_ax:.2f} degrees\")" + "print(\"\")\n" ] } ],