今回は、データ部分の話を少しまとめておく。
PhysioNetには生理学的な信号情報に関するPhysioBankデータベースがある。
https://physionet.org
解析用にPhysioToolkitが用意されている。WFDB Software PackageはMac用は、PowerPC用でIntelPCには対応していないので、今回は、WFDB Python Packageを用いる。
以下のGItHubからダウンロードして、
https://github.com/MIT-LCP/wfdb-python
Jupiter NotebookでPython 3で動かすことにする。
サンプルデータであるが、MIMIC−III Waveform Database
https://physionet.org/physiobank/database/mimic3wdb/
から取得したいが、
PhysioBankのAutomated Teller Machine
https://physionet.org/cgi-bin/atm/ATM
を利用して各データをzipファイル化して取得もできる。
JupiterでPythonを動かして、MIMICIIIのデータを解析してみる。
1 2 3 4 5 6 7 8 9 |
from IPython.display import display import matplotlib.pyplot as plt %matplotlib inline import numpy as np import os import shutil import wfdb |
例題として、MIMICIIIの39の3900006の0006データを以下のように指定して、
1 2 3 |
record = wfdb.rdrecord('sample-data/3900006/3900006_0006', channels=[0, 1, 2, 3], sampfrom=0, sampto=400) wfdb.plot_wfdb(record=record, title='Record 3900006_0006 from Physionet MIMICIII') display(record.__dict__) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
{'adc_gain': [127.0, 1.28, 128.0, 255.0], 'adc_res': [8, 8, 8, 8], 'adc_zero': [0, 0, 0, 0], 'base_counter': None, 'base_date': None, 'base_time': datetime.time(9, 17, 20), 'baseline': [-64, -109, -65, -128], 'block_size': [0, 0, 0, 0], 'byte_offset': [None, None, None, None], 'checksum': [59043, 5459, 39974, 64305], 'comments': [], 'counter_freq': None, 'd_signal': None, 'e_d_signal': None, 'e_p_signal': None, 'file_name': ['3900006_0006.dat', '3900006_0006.dat', '3900006_0006.dat', '3900006_0006.dat'], 'fmt': ['80', '80', '80', '80'], 'fs': 125, 'init_value': [-8, 112, 127, 127], 'n_sig': 4, 'p_signal': array([[ 0.44094488, 172.65625 , 1.5 , 1. ], [ 0.42519685, 168.75 , 1.46875 , 1. ], [ 0.45669291, 164.84375 , 1.40625 , 1. ], ..., [ 0.4488189 , 105.46875 , -0.46875 , 0.69019608], [ 0.48031496, 99.21875 , -0.46875 , 0.69411765], [ 0.45669291, 92.96875 , -0.484375 , 0.70196078]]), 'record_name': '3900006_0006', 'samps_per_frame': [1, 1, 1, 1], 'sig_len': 400, 'sig_name': ['II', 'ABP', 'V', 'RESP'], 'skew': [None, None, None, None], 'units': ['mV', 'mmHg', 'mV', 'NU']} |
チャンネル2の血圧情報だけにすると、
1 2 3 |
record = wfdb.rdrecord('sample-data/3900006/3900006_0006', channels=[1], sampfrom=0, sampto=400) wfdb.plot_wfdb(record=record, title='Record 3900006_0008 from Physionet Challenge 2018') display(record.__dict__) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
{'adc_gain': [1.28], 'adc_res': [8], 'adc_zero': [0], 'base_counter': None, 'base_date': None, 'base_time': datetime.time(9, 17, 20), 'baseline': [-109], 'block_size': [0], 'byte_offset': [None], 'checksum': [5459], 'comments': [], 'counter_freq': None, 'd_signal': None, 'e_d_signal': None, 'e_p_signal': None, 'file_name': ['3900006_0006.dat'], 'fmt': ['80'], 'fs': 125, 'init_value': [112], 'n_sig': 1, 'p_signal': array([[ 172.65625], [ 168.75 ], [ 164.84375], [ 160.9375 ], [ 158.59375], [ 157.03125], [ 155.46875], ....... ....... [ 111.71875], [ 105.46875], [ 99.21875], [ 92.96875]]), 'record_name': '3900006_0006', 'samps_per_frame': [1], 'sig_len': 400, 'sig_name': ['ABP'], 'skew': [None], 'units': ['mmHg']} |
血圧の数字情報だけを取得するために、
1 2 3 |
for i in record.p_signal[:]: print(i[0]) <pre> |
172.65625
168.75
164.84375
160.9375
158.59375
157.03125
155.46875
154.6875
153.90625
153.125
…….
Physiologic waveform records in this database contain up to eight simultaneously recorded signals digitized at 125 Hz with 8-, 10-, or (occasionally) 12-bit resolution. Numerics records typically contain 10 or more time series of vital signs sampled once per second or once per minute.
1秒125サンプル
1 2 3 |
record = wfdb.rdrecord('sample-data/3900006/3900006_0006', channels=[1], sampfrom=0, sampto=125) wfdb.plot_wfdb(record=record, title='ABP Record 3900006_0006 from Physionet MIMICIII') display(record.__dict__) |
1 2 |
for i in record.p_signal[:]: print(i[0]) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
172.65625 168.75 164.84375 160.9375 158.59375 157.03125 155.46875 154.6875 153.90625 153.125 150.78125 149.21875 146.09375 142.96875 139.84375 136.71875 132.8125 128.90625 124.21875 118.75 113.28125 107.8125 101.5625 95.3125 89.84375 83.59375 78.90625 74.21875 70.3125 67.1875 64.84375 63.28125 61.71875 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 60.9375 61.71875 61.71875 61.71875 61.71875 60.9375 60.9375 60.9375 60.15625 60.15625 59.375 58.59375 58.59375 57.8125 57.8125 57.03125 57.03125 56.25 56.25 55.46875 55.46875 54.6875 54.6875 53.90625 53.90625 53.125 53.125 52.34375 52.34375 51.5625 51.5625 50.78125 50.0 50.0 49.21875 49.21875 49.21875 49.21875 51.5625 56.25 64.84375 78.90625 97.65625 118.75 139.84375 157.8125 170.3125 178.125 181.25 181.25 178.90625 174.21875 170.3125 167.1875 164.0625 162.5 161.71875 160.9375 160.15625 159.375 157.8125 155.46875 153.125 150.0 146.09375 142.96875 138.28125 133.59375 128.90625 123.4375 117.96875 112.5 106.25 100.0 94.53125 89.0625 84.375 79.6875 76.5625 73.4375 |