first comments
parent
2a8916acdd
commit
1404b91740
|
@ -697,21 +697,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 42,
|
"execution_count": 44,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"def calculate_axis(data, leads, sampling_rate=500, aVF=5, I=0):\n",
|
"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",
|
" # 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",
|
" 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",
|
" net_t[lead] = np.mean(t_peaks) if t_peaks else 0\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
" print(net_qrs.get(aVF, 0), net_qrs.get(I, 0))\n",
|
||||||
" # Calculate the R axis (Convert to degrees)\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",
|
" r_axis = np.arctan2(net_qrs.get(aVF, 0), net_qrs.get(I, 0)) * (180 / np.pi)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -752,25 +741,47 @@
|
||||||
" return r_axis, t_axis\n",
|
" return r_axis, t_axis\n",
|
||||||
"\n",
|
"\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",
|
"# print(data_org['SB'][0].__dict__) 'sig_name': ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']\n",
|
||||||
"\n",
|
"\n",
|
||||||
"i_sig = 0\n",
|
"i_sig = 0\n",
|
||||||
"avf = 5\n",
|
"avf = 5\n",
|
||||||
"sampling_rate = 500\n",
|
"sampling_rate = 500\n",
|
||||||
"\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",
|
"\n",
|
||||||
"ecg_cleaned_i = nk.ecg_clean(ecg_signal_i, sampling_rate=sampling_rate)\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"r_ax, t_ax = calculate_axis(filtered_data, [0, 5], sampling_rate=500)\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 R Axis: {r_ax:.2f} degrees\")\n",
|
||||||
"print(f\"2 lead T Axis: {t_ax:.2f} degrees\")\n",
|
"print(f\"2 lead T Axis: {t_ax:.2f} degrees\")\n",
|
||||||
"print(\"\")\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\")"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue