首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于Matlab的心电实时监测/可视化+数据转换

基于Matlab的心电实时监测/可视化+数据转换
EN

Stack Overflow用户
提问于 2015-03-25 19:38:48
回答 1查看 1.5K关注 0票数 1

我正在从事的心电图生物识别项目:我使用Arduino + Olimex /EKG屏蔽,并将数据传输到MatLab。

我面临两个问题:

  1. 实时监测:X轴标度自动变化,长时间后对心电图进行压缩。我想要可视化一个特定的视图,以便QRS复合体将清楚地可视化。有通用代码吗?
  2. 获取实际电压值: Arduino上的Analog.read()将电压从0-5转换为0..1023,然后通过串行通信发送它们。在Matlab上,心电信号不具有特定的最小值和最大值来提取特征值。对如何做到这一点有任何想法。

提前谢谢你。等待你的回复。

你好,巴德雷丁

EN

回答 1

Stack Overflow用户

发布于 2015-03-25 21:11:59

编辑免责声明,我从内存中编写了这段代码,所以它可能是错误的,提前道歉。

1.假设您的数据存储在某个数组data_array中,并且每次我们得到一个示例时,我们都会这样做

代码语言:javascript
复制
data_array = [data_array, sample];

现在,假设在我们的查看器中,我们只想查看20个样本。我们可以做这样的事

代码语言:javascript
复制
num_visible_samples = 20; %define this somewhere outside your data aquisition loop

%gets new data somehow
data_array = [data_array, new_data_point];

%plots all data
plot(data_array);
length_data_array = length(data_array);

if (length_data_array >= num_visible_samples)
    %this makes the plot window only show the current data point and the
    %previous few data points, the Yaxis will automatically be scaled
    xlim([length_data_array -num_visible_samples, length_data_array ]);
end

你可以做的另一件事(这会更快)是只绘制你想要的样本数量。

代码语言:javascript
复制
num_visible_samples = 20; %define this somewhere outside your data aquisition loop

%gets new data somehow
data_array = [data_array, new_data_point];

%plots all data
plot(data_array);
length_data_array = length(data_array);

if (length_data_array >= num_visible_samples)
     %plots only the specific number of data points
     plot(data_array(end-num_visible_samples,end));

     %im not sure if you need to specify the axis, but i think you do
     xlim([length_data_array -num_visible_samples, length_data_array ]);
else
    plot(data_array);
end

2.来回转换值非常简单。这是jsut的一些psuedocode

代码语言:javascript
复制
maxV = 5.0;
minV = 0.0;
num_of_quantized_values = 1024;

%this says how much the lsb of the adc is, basically we just divide our
%input range (0-5 volts) by our output range (0-1023) => 4.88mV
adc_resolution =  (maxV - minV) / num_of_quantized_values;

为了将数字值转换回模拟电压,我们将分辨率乘以返回的值。

代码语言:javascript
复制
val_in_volts = adc_digital_reading * adc_resolution;

例如,假设adc读取256

256 * 4.88mV = 1.25

edit2,因为atmega芯片通常有10位adc,您可以得到两个字节的数据adc数据。下面的8,然后上的2。修复不是太糟糕,假设我们有两个变量。

lower_byte is uint8 upper_byte is uint8

所以我会这样做(根据实现有不同的方法)

代码语言:javascript
复制
adc_digital_reading = bitor(bitshift(uint16(upper_byte ),8), uint16(lower_byte));
%mirrors this c code
%adc_u16 = (upper_byte << 8) | lower_byte;

重要的部分是将uint8类型转换为uint16,否则就不能正常工作。

为了安全起见你可以这么做

代码语言:javascript
复制
adc_digital_reading = bitand(bitor(bitshift(uint16(upper_byte ),8), uint16(lower_byte)),1023);
%adc_u16 = ((upper_byte << 8) | lower_byte) & 0x03FF;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29264982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档