Newer
Older
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
" <!-- positive example -->\n",
" <defs>\n",
" <path d=\"M 54.890625 54.6875 \n",
"L 35.109375 28.078125 \n",
"L 55.90625 0 \n",
"L 45.3125 0 \n",
"L 29.390625 21.484375 \n",
"L 13.484375 0 \n",
"L 2.875 0 \n",
"L 24.125 28.609375 \n",
"L 4.6875 54.6875 \n",
"L 15.28125 54.6875 \n",
"L 29.78125 35.203125 \n",
"L 44.28125 54.6875 \n",
"z\n",
"\" id=\"DejaVuSans-120\"/>\n",
" <path d=\"M 52 44.1875 \n",
"Q 55.375 50.25 60.0625 53.125 \n",
"Q 64.75 56 71.09375 56 \n",
"Q 79.640625 56 84.28125 50.015625 \n",
"Q 88.921875 44.046875 88.921875 33.015625 \n",
"L 88.921875 0 \n",
"L 79.890625 0 \n",
"L 79.890625 32.71875 \n",
"Q 79.890625 40.578125 77.09375 44.375 \n",
"Q 74.3125 48.1875 68.609375 48.1875 \n",
"Q 61.625 48.1875 57.5625 43.546875 \n",
"Q 53.515625 38.921875 53.515625 30.90625 \n",
"L 53.515625 0 \n",
"L 44.484375 0 \n",
"L 44.484375 32.71875 \n",
"Q 44.484375 40.625 41.703125 44.40625 \n",
"Q 38.921875 48.1875 33.109375 48.1875 \n",
"Q 26.21875 48.1875 22.15625 43.53125 \n",
"Q 18.109375 38.875 18.109375 30.90625 \n",
"L 18.109375 0 \n",
"L 9.078125 0 \n",
"L 9.078125 54.6875 \n",
"L 18.109375 54.6875 \n",
"L 18.109375 46.1875 \n",
"Q 21.1875 51.21875 25.484375 53.609375 \n",
"Q 29.78125 56 35.6875 56 \n",
"Q 41.65625 56 45.828125 52.96875 \n",
"Q 50 49.953125 52 44.1875 \n",
"z\n",
"\" id=\"DejaVuSans-109\"/>\n",
" </defs>\n",
" <g transform=\"translate(83.965625 198.882187)scale(0.1 -0.1)\">\n",
" <use xlink:href=\"#DejaVuSans-112\"/>\n",
" <use x=\"63.476562\" xlink:href=\"#DejaVuSans-111\"/>\n",
" <use x=\"124.658203\" xlink:href=\"#DejaVuSans-115\"/>\n",
" <use x=\"176.757812\" xlink:href=\"#DejaVuSans-105\"/>\n",
" <use x=\"204.541016\" xlink:href=\"#DejaVuSans-116\"/>\n",
" <use x=\"243.75\" xlink:href=\"#DejaVuSans-105\"/>\n",
" <use x=\"271.533203\" xlink:href=\"#DejaVuSans-118\"/>\n",
" <use x=\"330.712891\" xlink:href=\"#DejaVuSans-101\"/>\n",
" <use x=\"392.236328\" xlink:href=\"#DejaVuSans-32\"/>\n",
" <use x=\"424.023438\" xlink:href=\"#DejaVuSans-101\"/>\n",
" <use x=\"485.53125\" xlink:href=\"#DejaVuSans-120\"/>\n",
" <use x=\"544.710938\" xlink:href=\"#DejaVuSans-97\"/>\n",
" <use x=\"605.990234\" xlink:href=\"#DejaVuSans-109\"/>\n",
" <use x=\"703.402344\" xlink:href=\"#DejaVuSans-112\"/>\n",
" <use x=\"766.878906\" xlink:href=\"#DejaVuSans-108\"/>\n",
" <use x=\"794.662109\" xlink:href=\"#DejaVuSans-101\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_19\">\n",
" <path d=\"M 55.965625 210.060312 \n",
"L 75.965625 210.060312 \n",
"\" style=\"fill:none;stroke:#ff7f0e;stroke-dasharray:2.775,1.2;stroke-dashoffset:0;stroke-width:0.75;\"/>\n",
" </g>\n",
" <g id=\"line2d_20\"/>\n",
" <g id=\"text_18\">\n",
" <!-- negative example -->\n",
" <defs>\n",
" <path d=\"M 45.40625 27.984375 \n",
"Q 45.40625 37.75 41.375 43.109375 \n",
"Q 37.359375 48.484375 30.078125 48.484375 \n",
"Q 22.859375 48.484375 18.828125 43.109375 \n",
"Q 14.796875 37.75 14.796875 27.984375 \n",
"Q 14.796875 18.265625 18.828125 12.890625 \n",
"Q 22.859375 7.515625 30.078125 7.515625 \n",
"Q 37.359375 7.515625 41.375 12.890625 \n",
"Q 45.40625 18.265625 45.40625 27.984375 \n",
"z\n",
"M 54.390625 6.78125 \n",
"Q 54.390625 -7.171875 48.1875 -13.984375 \n",
"Q 42 -20.796875 29.203125 -20.796875 \n",
"Q 24.46875 -20.796875 20.265625 -20.09375 \n",
"Q 16.0625 -19.390625 12.109375 -17.921875 \n",
"L 12.109375 -9.1875 \n",
"Q 16.0625 -11.328125 19.921875 -12.34375 \n",
"Q 23.78125 -13.375 27.78125 -13.375 \n",
"Q 36.625 -13.375 41.015625 -8.765625 \n",
"Q 45.40625 -4.15625 45.40625 5.171875 \n",
"L 45.40625 9.625 \n",
"Q 42.625 4.78125 38.28125 2.390625 \n",
"Q 33.9375 0 27.875 0 \n",
"Q 17.828125 0 11.671875 7.65625 \n",
"Q 5.515625 15.328125 5.515625 27.984375 \n",
"Q 5.515625 40.671875 11.671875 48.328125 \n",
"Q 17.828125 56 27.875 56 \n",
"Q 33.9375 56 38.28125 53.609375 \n",
"Q 42.625 51.21875 45.40625 46.390625 \n",
"L 45.40625 54.6875 \n",
"L 54.390625 54.6875 \n",
"z\n",
"\" id=\"DejaVuSans-103\"/>\n",
" </defs>\n",
" <g transform=\"translate(83.965625 213.560312)scale(0.1 -0.1)\">\n",
" <use xlink:href=\"#DejaVuSans-110\"/>\n",
" <use x=\"63.378906\" xlink:href=\"#DejaVuSans-101\"/>\n",
" <use x=\"124.902344\" xlink:href=\"#DejaVuSans-103\"/>\n",
" <use x=\"188.378906\" xlink:href=\"#DejaVuSans-97\"/>\n",
" <use x=\"249.658203\" xlink:href=\"#DejaVuSans-116\"/>\n",
" <use x=\"288.867188\" xlink:href=\"#DejaVuSans-105\"/>\n",
" <use x=\"316.650391\" xlink:href=\"#DejaVuSans-118\"/>\n",
" <use x=\"375.830078\" xlink:href=\"#DejaVuSans-101\"/>\n",
" <use x=\"437.353516\" xlink:href=\"#DejaVuSans-32\"/>\n",
" <use x=\"469.140625\" xlink:href=\"#DejaVuSans-101\"/>\n",
" <use x=\"530.648438\" xlink:href=\"#DejaVuSans-120\"/>\n",
" <use x=\"589.828125\" xlink:href=\"#DejaVuSans-97\"/>\n",
" <use x=\"651.107422\" xlink:href=\"#DejaVuSans-109\"/>\n",
" <use x=\"748.519531\" xlink:href=\"#DejaVuSans-112\"/>\n",
" <use x=\"811.996094\" xlink:href=\"#DejaVuSans-108\"/>\n",
" <use x=\"839.779297\" xlink:href=\"#DejaVuSans-101\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"pba2174c2e6\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"46.965625\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Smoothed version\n",
"ts_plot = ts_imax[(ts_imax['t'] >= -10) & (ts_imax['t'] < 15)][['t', 'SpO2']].dropna()\n",
"ts_plot = ts_plot.set_index('t')\n",
"ts_plot['SpO2_MA'] = np.nan\n",
"wsize = 0.1\n",
"for t in ts_plot.index:\n",
" ts_plot.loc[t, 'SpO2_MA'] = np.mean(ts_plot.loc[\n",
" (t-wsize < ts_plot.index) & (ts_plot.index < t+wsize), 'SpO2'\n",
" ])\n",
"ts_plot = ts_plot.reset_index()\n",
"ts_plot = ts_plot.sort_values(by=['t'])\n",
"ts_plot = ts_plot.drop_duplicates(subset=['t'])\n",
"x = ts_plot['t']\n",
"y = ts_plot['SpO2_MA']\n",
"x_new = np.linspace(x.min(), x.max(), 1000)\n",
"f = interp1d(x, y, kind='quadratic')\n",
"y_smooth = f(x_new)\n",
"plt.plot(x_new, y_smooth, '--', lw=0.75, label='positive example')\n",
"# plt.plot(ts_plot['t'], ts_plot['SpO2_MA'], '-', lw=1, label='positive example')\n",
"plt.scatter(ts_plot['t'], ts_plot['SpO2_MA'], s=5)\n",
"\n",
"ts_plot = ts_imin[(ts_imin['t'] >= -10) & (ts_imin['t'] < 15)][['t', 'SpO2']].dropna()\n",
"ts_plot = ts_plot.set_index('t')\n",
"ts_plot['SpO2_MA'] = np.nan\n",
"wsize = 0.1\n",
"for t in ts_plot.index:\n",
" ts_plot.loc[t, 'SpO2_MA'] = np.mean(ts_plot.loc[\n",
" (t-wsize < ts_plot.index) & (ts_plot.index < t+wsize), 'SpO2'\n",
" ])\n",
"ts_plot = ts_plot.reset_index()\n",
"ts_plot = ts_plot.sort_values(by=['t'])\n",
"ts_plot = ts_plot.drop_duplicates(subset=['t'])\n",
"x = ts_plot['t']\n",
"y = ts_plot['SpO2_MA']\n",
"x_new = np.linspace(x.min(), x.max(), 1000)\n",
"f = interp1d(x, y, kind='quadratic')\n",
"y_smooth = f(x_new)\n",
"plt.plot(x_new, y_smooth, '--', lw=0.75, label='negative example')\n",
"# plt.plot(ts_plot['t'], ts_plot['SpO2_MA'], '-', lw=1, label='negative example')\n",
"plt.scatter(ts_plot['t'], ts_plot['SpO2_MA'], s=5)\n",
"\n",
"plt.xlim(-10, 15)\n",
"plt.ylim(85, 101)\n",
"plt.xlabel('Days relative to transplant')\n",
"plt.ylabel('SpO2 (%)')\n",
"plt.legend()\n",
"plt.savefig('fig/timeseries_SpO2.svg')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}