Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify abnormally elevated T waves as R waves #108

Open
Ginsakura opened this issue Sep 4, 2023 · 1 comment
Open

Identify abnormally elevated T waves as R waves #108

Ginsakura opened this issue Sep 4, 2023 · 1 comment

Comments

@Ginsakura
Copy link

Ginsakura commented Sep 4, 2023

心电合法性检测
局部放大
RR-Time散点图
庞加莱散点图

figure 1 is hp.process() function
图1是hp.process()函数处理后的图表

wd, m = hp.process(self.healthMapList, self.sampleRate,clean_rr=True,clean_rr_method='z-score')
pfig = hp.plotter(wd, m,figsize=(20, 4),show=False)
pfig.subplots_adjust(**{"left":0.026,"bottom":0.07,"right":1,"top":1})
pfig.legend(prop={'family':'LXGW WenKai Mono','weight':'normal','size':12},framealpha=0.5)
plt.xlim(0,rrtime/1000+rrtime/1000000)

figure 2 is partial enlarged figure1
图2是局部放大的图1

figure 3 is Distribution of R-R interval (ibi) in time
图3是R-R间期(心跳间隔 Inter-Beat Interval IBI)在时间上的分布

wd, m = hp.process(self.healthMapList, self.sampleRate,clean_rr=True,clean_rr_method='z-score')
# rrwd = hp.clean_rr_intervals(working_data=wd)
rrfig = plt.figure('R-R与时间散点图',figsize=(20, 4))
rrfig.subplots_adjust(**{"left":0.026,"bottom":0.07,"right":1,"top":1})
rrlist,rrtimelist,rrtime = list(),list(),0
for ids in range(len(wd['RR_list'])):
	rrtime += wd['RR_list'][ids]
	if not wd['RR_masklist'][ids]:
		rrlist.append(wd['RR_list'][ids])
		rrtimelist.append(rrtime/1000)
print("正在绘制R-R与时间散点图中...")
plt.scatter(rrtimelist,rrlist,alpha=0.7,color='#8a68d0',s=5)
plt.plot(range(len(rrlist)),[sum(rrlist)/len(rrlist)]*len(rrlist),label=f"Avg R-R: {sum(rrlist)/len(rrlist)} ms",linestyle='--',alpha=0.5,linewidth=1,color='#CC0000')
plt.ylabel("ms")
plt.xlim(0,rrtime/1000+rrtime/1000000)
plt.legend(prop={'family':'LXGW WenKai Mono','weight':'normal','size':12},framealpha=0.5)

figure 4 is hp.plot_poincare() function.
图4是hp.plot_poincare()函数直接生成

with open(f'./{self.filename}/庞加莱散点图.txt','w') as f:
	f.write("%s\n%s"%(str(wd).replace(', ',',\n'),str(m).replace(', ',',\n')))
ppfig = hp.plot_poincare(wd, m,figsize=(10,10),show=False)
ppfig.subplots_adjust(**{"left":0.06,"bottom":0.045,"right":1,"top":0.97})
ppfig.savefig(f'./{self.filename}/庞加莱散点图.png')

Can abnormal T waves be filtered?
能否过滤异常T波?

@Ginsakura
Copy link
Author

Ginsakura commented Sep 4, 2023

20230825_211455.zip
This is ECG Record File
It's a .rcd file ,not the .zip file.
but,this file is read in binary mode, No need to pay attention to the extension
这是ECG记录文件
它并非zip文件,而是rcd文件
但是,这个文件是以二进制方式读取,无需在意扩展名是什么

The following is the file reading function
Sampling Rate = 500
下面的是文件读取函数
采样率为500次/秒

healthMap = open(self.healthFilePath, 'rb')
healthMap.read(68)
healthMap.read(6)
healthMap.read(2)
self.SN = healthMap.read(18).decode()
print(f"设备序列号:{self.SN}")
healthMap.read(102)
self.Ver = healthMap.read(11).decode()
print(f"设备版本号:{self.Ver}")
healthMap.read(49)
self.startTime = int.from_bytes(healthMap.read(4), byteorder='little', signed=False)
self.endTime = int.from_bytes(healthMap.read(4), byteorder='little', signed=False)
print(f"start time:{self.startTime}\nend time:{self.endTime}")
healthMap.read(236)
while True:
	# 每个数据点2字节
	# 2 byte == 1 data point
	data = healthMap.read(2)
	if data == b'':break
	# 复位电压零点 12位AD值最大4096
	# 2048 == 0mV
	data = int.from_bytes(data, byteorder='little', signed=False)-2048
	data *= 0.00125 # Estimate sampling points and voltage values 估算的采样点与电压值
	self.healthMapList.append(data)
self.healthMapLenth = len(self.healthMapList)
print(f"数据点数目: {len(self.healthMapList)} 个")
print(f"数据持续时间: {len(self.healthMapList)/500} s")

healthMapList is sampling points list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant