谷动谷力

 找回密码
 立即注册
查看: 4112|回复: 1
打印 上一主题 下一主题
收起左侧

最近爆火的电子血氧仪是什么原理?测的准吗?

[复制链接]
跳转到指定楼层
楼主
发表于 2023-1-8 22:40:16 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
最近爆火的电子血氧仪是什么原理?测的准吗?


继口罩、抗原、药品之后,最近电子血氧仪的价格也开始水涨船高。从一个多月前的100多元,暴涨到了300多元。
那么,这类家用的电子血氧仪是如何工作的呢?测量数据到底准不准?今天就带大家来分析一下。

一、血氧仪工作原理血氧仪是一种监测脉搏、血氧饱和度等指标的医疗器械,常见的家用型血氧仪,主要有指夹式、腕表式等形式。一般大家最关注的是血氧饱和度(oxygen saturation简写为SpO2),它是指在全部血容量中被结合O2容量占全部可结合的O2容量的百分比,是人体携带氧气能力的重要参考值。人体正常的SpO2应该不小于95%,长期低于93%时需要就医。SpO2 一般由以下公式计算:
其中CHbO2是氧合血红蛋白浓度,CHb是还原血红蛋白浓度。一方面,这两种血红蛋白对不同波长的光有不同的吸收度;另一方面,当动脉跳动时,动脉中的血液量会发生变化,可以区分出皮肤、肌肉、静脉血等对光的吸收影响(这些组织对光的吸收可以认为固定不变)。因此,利用两种不同波长的光,经透射或反射后,采集数据综合处理,就能计算出血氧饱和度。现在市面上最常见的,都是光电式的血氧仪,如下图所示,有透射式和反射式两种实现方法。常见的指夹式血氧仪就是透射式,智能手环或手表就是反射式,原理是差不多的。

而LED光源的选择,与血红蛋白对不同光波长的吸收率有关,下图是两种血红蛋白对不同波长的光的消光系数图:

可以看到,两种血红蛋白对波长为660nm左右光的吸收差别最大,而对波长为800nm左右光的吸收基本相等。从理论上说,使用660nm和800nm波长的光作为光源是最合适的,但由于在800nm左右时,二者的消光系数斜率相差较大,光波长偏差一点就会引起较大的吸收率变化,这对LED的制造工艺要求太高。所以,工程实现时,一般不用800nm波长的LED,而选择波长为860nm~920nm的LED作为另一个光源,这个区间的消光系数斜率基本一样,而且变化平缓。至此,硬件部分的实现我们已经了解大概了,其实核心就是要使用两个LED作为光源,一个660nm波长的红外光,一个900nm左右波长的红光。两束光分别通过透射(或反射)皮肤后,到达光电接收管,再采集光电接收管的值。那么,采集到两个光源的值后,又该如何处理呢?这里由于有比较多的公式推导,我们直接略过,给出下面的公式: 这里的实现需要三步:第一步,我们采集的两个LED光源的值,需要分离出直流分量和交流分量,也就是:红光的交流分量ACred、红光的直流分量DCred、红外光的交流分量ACired、红外光的直流分量DCired;第二步,用采集到的四个值,计算出R;第三步,用R计算SpO2,这个计算公式中a、b、c是三个需要校准的参数。需要大量的试验数据去拟合出来。二、血氧仪的制作有了以上的理论基础,我们可以自己动手DIY一个血氧仪。Maxim公司有一款集成芯片,可以实现大部分的硬件功能,就是MAX30100、MAX30102系列芯片。MAX30100已停产,新设计中不推荐使用,MAX30102是新一代产品。目前价格还没有太离谱:

MAX30102集成了一个660nm红光LED、880nm红外光LED、光电检测器,以及带环境光抑制的低噪声电子电路。芯片内部含18bit ADC采集电路。对外是I2C接口。基本上单芯片就能实现光源信号的采集。要注意,MAX30102的输出值,只是两个LED光源的采集值。后续还需要软件去实现交流、直流分离,R的求解、SpO2的求解。顺带也可以求解出脉搏数据。使用max30102很简单,用I2C接口访问,初始化代码如下:
max30102_Bus_Write(REG_INTR_ENABLE_1,0xc0);  // INTR setting
max30102_Bus_Write(REG_INTR_ENABLE_2,0x00);
max30102_Bus_Write(REG_FIFO_WR_PTR,0x00);    //FIFO_WR_PTR[4:0]
max30102_Bus_Write(REG_OVF_COUNTER,0x00);    //OVF_COUNTER[4:0]
max30102_Bus_Write(REG_FIFO_RD_PTR,0x00);    //FIFO_RD_PTR[4:0]
max30102_Bus_Write(REG_FIFO_CONFIG,0x0f);    //sample avg = 1, fifo rollover=false, fifo almost full = 17
max30102_Bus_Write(REG_MODE_CONFIG,0x03);    //0x02 for Red only, 0x03 for SpO2 mode 0x07 multimode LED
max30102_Bus_Write(REG_SPO2_CONFIG,0x27);    // SPO2_ADC range = 4096nA, SPO2 sample rate (100 Hz), LED pulseWidth (400uS)  
max30102_Bus_Write(REG_LED1_PA,0x24);     //Choose value for ~ 7mA for LED1
max30102_Bus_Write(REG_LED2_PA,0x24);     // Choose value for ~ 7mA for LED2
max30102_Bus_Write(REG_PILOT_PA,0x7f);     // Choose value for ~ 25mA for Pilot LED

主函数中循环调用fifo读取函数,用于获取LED光源的采集值:
void maxim_max30102_read_fifo(uint32_t *pun_red_led, uint32_t *pun_ir_led)
{
  uint32_t un_temp;
  unsigned char uch_temp;
  char ach_i2c_data[6];
  *pun_red_led=0;
  *pun_ir_led=0;

  //read and clear status register
  maxim_max30102_read_reg(REG_INTR_STATUS_1, &uch_temp);
  maxim_max30102_read_reg(REG_INTR_STATUS_2, &uch_temp);

  IIC_ReadBytes(I2C_WRITE_ADDR,REG_FIFO_DATA,(u8 *)ach_i2c_data,6);

  un_temp=(unsigned char) ach_i2c_data[0];
  un_temp<<=16;
  *pun_red_led+=un_temp;
  un_temp=(unsigned char) ach_i2c_data[1];
  un_temp<<=8;
  *pun_red_led+=un_temp;
  un_temp=(unsigned char) ach_i2c_data[2];
  *pun_red_led+=un_temp;

  un_temp=(unsigned char) ach_i2c_data[3];
  un_temp<<=16;
  *pun_ir_led+=un_temp;
  un_temp=(unsigned char) ach_i2c_data[4];
  un_temp<<=8;
  *pun_ir_led+=un_temp;
  un_temp=(unsigned char) ach_i2c_data[5];
  *pun_ir_led+=un_temp;
  *pun_red_led&=0x03FFFF;  //Mask MSB [23:18]
  *pun_ir_led&=0x03FFFF;  //Mask MSB [23:18]
}

采集值最好经过滤波,以减少噪声的干扰。
之后,再分离出交流、直流分量,求出R和SpO2即可,核心是这个函数:
void maxim_heart_rate_and_oxygen_saturation(uint32_t *pun_ir_buffer,  int32_t n_ir_buffer_length, uint32_t *pun_red_buffer, int32_t *pn_spo2, int8_t *pch_spo2_valid,
                              int32_t *pn_heart_rate, int8_t  *pch_hr_valid)
{
    uint32_t un_ir_mean ,un_only_once ;
    int32_t k ,n_i_ratio_count;
    int32_t i, s, m, n_exact_ir_valley_locs_count ,n_middle_idx;
    int32_t n_th1, n_npks,n_c_min;      
    int32_t an_ir_valley_locs[15] ;
    int32_t an_exact_ir_valley_locs[15] ;
    int32_t an_dx_peak_locs[15] ;
    int32_t n_peak_interval_sum;

    int32_t n_y_ac, n_x_ac;
    int32_t n_spo2_calc;
    int32_t n_y_dc_max, n_x_dc_max;
    int32_t n_y_dc_max_idx, n_x_dc_max_idx;
    int32_t an_ratio[5],n_ratio_average;
    int32_t n_nume,  n_denom ;
    // remove DC of ir signal   
    un_ir_mean =0;
    for (k=0 ; k<n_ir_buffer_length ; k++ ) un_ir_mean += pun_ir_buffer[k] ;
    un_ir_mean =un_ir_mean/n_ir_buffer_length ;
    for (k=0 ; k<n_ir_buffer_length ; k++ )  an_x[k] =  pun_ir_buffer[k] - un_ir_mean ;

    // 4 pt Moving Average
    for(k=0; k< BUFFER_SIZE-MA4_SIZE; k++){
        n_denom= ( an_x[k]+an_x[k+1]+ an_x[k+2]+ an_x[k+3]);
        an_x[k]=  n_denom/(int32_t)4;
    }

    // get difference of smoothed IR signal   
    for( k=0; k<BUFFER_SIZE-MA4_SIZE-1;  k++)
        an_dx[k]= (an_x[k+1]- an_x[k]);

    // 2-pt Moving Average to an_dx
    for(k=0; k< BUFFER_SIZE-MA4_SIZE-2; k++){
        an_dx[k] =  ( an_dx[k]+an_dx[k+1])/2 ;
    }

    // hamming window
    // flip wave form so that we can detect valley with peak detector
    for ( i=0 ; i<BUFFER_SIZE-HAMMING_SIZE-MA4_SIZE-2 ;i++){
        s= 0;
        for( k=i; k<i+ HAMMING_SIZE ;k++){
            s -= an_dx[k] *auw_hamm[k-i] ;
                     }
        an_dx= s/ (int32_t)1146; // divide by sum of auw_hamm
    }

    n_th1=0; // threshold calculation
    for ( k=0 ; k<BUFFER_SIZE-HAMMING_SIZE ;k++){
        n_th1 += ((an_dx[k]>0)? an_dx[k] : ((int32_t)0-an_dx[k])) ;
    }
    n_th1= n_th1/ ( BUFFER_SIZE-HAMMING_SIZE);
    // peak location is acutally index for sharpest location of raw signal since we flipped the signal         
    maxim_find_peaks( an_dx_peak_locs, &n_npks, an_dx, BUFFER_SIZE-HAMMING_SIZE, n_th1, 8, 5 );//peak_height, peak_distance, max_num_peaks

    n_peak_interval_sum =0;
    if (n_npks>=2){
        for (k=1; k<n_npks; k++)
            n_peak_interval_sum += (an_dx_peak_locs[k]-an_dx_peak_locs[k -1]);
        n_peak_interval_sum=n_peak_interval_sum/(n_npks-1);
        *pn_heart_rate=(int32_t)(6000/n_peak_interval_sum);// beats per minutes
        *pch_hr_valid  = 1;
    }
    else  {
        *pn_heart_rate = -999;
        *pch_hr_valid  = 0;
    }

    for ( k=0 ; k<n_npks ;k++)
        an_ir_valley_locs[k]=an_dx_peak_locs[k]+HAMMING_SIZE/2;

    // raw value : RED(=y) and IR(=X)
    // we need to assess DC and AC value of ir and red PPG.
    for (k=0 ; k<n_ir_buffer_length ; k++ )  {
        an_x[k] =  pun_ir_buffer[k] ;
        an_y[k] =  pun_red_buffer[k] ;
    }

    // find precise min near an_ir_valley_locs
    n_exact_ir_valley_locs_count =0;
    for(k=0 ; k<n_npks ;k++){
        un_only_once =1;
        m=an_ir_valley_locs[k];
        n_c_min= 16777216;//2^24;
        if (m+5 <  BUFFER_SIZE-HAMMING_SIZE  && m-5 >0){
            for(i= m-5;i<m+5; i++)
                if (an_x<n_c_min){
                    if (un_only_once >0){
                       un_only_once =0;
                   }
                   n_c_min= an_x ;
                   an_exact_ir_valley_locs[k]=i;
                }
            if (un_only_once ==0)
                n_exact_ir_valley_locs_count ++ ;
        }
    }
    if (n_exact_ir_valley_locs_count <2 ){
       *pn_spo2 =  -999 ; // do not use SPO2 since signal ratio is out of range
       *pch_spo2_valid  = 0;
       return;
    }
    // 4 pt MA
    for(k=0; k< BUFFER_SIZE-MA4_SIZE; k++){
        an_x[k]=( an_x[k]+an_x[k+1]+ an_x[k+2]+ an_x[k+3])/(int32_t)4;
        an_y[k]=( an_y[k]+an_y[k+1]+ an_y[k+2]+ an_y[k+3])/(int32_t)4;
    }

    //using an_exact_ir_valley_locs , find ir-red DC andir-red AC for SPO2 calibration ratio
    //finding AC/DC maximum of raw ir * red between two valley locations
    n_ratio_average =0;
    n_i_ratio_count =0;

    for(k=0; k< 5; k++) an_ratio[k]=0;
    for (k=0; k< n_exact_ir_valley_locs_count; k++){
        if (an_exact_ir_valley_locs[k] > BUFFER_SIZE ){            
            *pn_spo2 =  -999 ; // do not use SPO2 since valley loc is out of range
            *pch_spo2_valid  = 0;
            return;
        }
    }
    // find max between two valley locations
    // and use ratio betwen AC compoent of Ir & Red and DC compoent of Ir & Red for SPO2

    for (k=0; k< n_exact_ir_valley_locs_count-1; k++){
        n_y_dc_max= -16777216 ;
        n_x_dc_max= - 16777216;
        if (an_exact_ir_valley_locs[k+1]-an_exact_ir_valley_locs[k] >10){
            for (i=an_exact_ir_valley_locs[k]; i< an_exact_ir_valley_locs[k+1]; i++){
                if (an_x> n_x_dc_max) {n_x_dc_max =an_x;n_x_dc_max_idx =i; }
                if (an_y> n_y_dc_max) {n_y_dc_max =an_y;n_y_dc_max_idx=i;}
            }
            n_y_ac= (an_y[an_exact_ir_valley_locs[k+1]] - an_y[an_exact_ir_valley_locs[k] ] )*(n_y_dc_max_idx -an_exact_ir_valley_locs[k]); //red
            n_y_ac=  an_y[an_exact_ir_valley_locs[k]] + n_y_ac/ (an_exact_ir_valley_locs[k+1] - an_exact_ir_valley_locs[k])  ;


            n_y_ac=  an_y[n_y_dc_max_idx] - n_y_ac;    // subracting linear DC compoenents from raw
            n_x_ac= (an_x[an_exact_ir_valley_locs[k+1]] - an_x[an_exact_ir_valley_locs[k] ] )*(n_x_dc_max_idx -an_exact_ir_valley_locs[k]); // ir
            n_x_ac=  an_x[an_exact_ir_valley_locs[k]] + n_x_ac/ (an_exact_ir_valley_locs[k+1] - an_exact_ir_valley_locs[k]);
            n_x_ac=  an_x[n_y_dc_max_idx] - n_x_ac;      // subracting linear DC compoenents from raw
            n_nume=( n_y_ac *n_x_dc_max)>>7 ; //prepare X100 to preserve floating value
            n_denom= ( n_x_ac *n_y_dc_max)>>7;
            if (n_denom>0  && n_i_ratio_count <5 &&  n_nume != 0)
            {   
                an_ratio[n_i_ratio_count]= (n_nume*20)/n_denom ; //formular is ( n_y_ac *n_x_dc_max) / ( n_x_ac *n_y_dc_max) ;  ///*************************n_nume原来是*100************************//
                n_i_ratio_count++;
            }
        }
    }

    maxim_sort_ascend(an_ratio, n_i_ratio_count);
    n_middle_idx= n_i_ratio_count/2;

    if (n_middle_idx >1)
        n_ratio_average =( an_ratio[n_middle_idx-1] +an_ratio[n_middle_idx])/2; // use median
    else
        n_ratio_average = an_ratio[n_middle_idx ];

    if( n_ratio_average>2 && n_ratio_average <184){
        n_spo2_calc= uch_spo2_table[n_ratio_average] ;
        *pn_spo2 = n_spo2_calc ;
        *pch_spo2_valid  = 1;//  float_SPO2 =  -45.060*n_ratio_average* n_ratio_average/10000 + 30.354 *n_ratio_average/100 + 94.845 ;  // for comparison with table
    }
    else{
        *pn_spo2 =  -999 ; // do not use SPO2 since signal ratio is out of range
        *pch_spo2_valid  = 0;
    }
}
需要注意的是,这里使用的函数是SpO2 = -45.060*R*R+ 30.354*R+ 94.845,采用了查表法求解。
这个函数执行完后,变量n_heart_rate中存储的是心率,变量n_sp02存储的就是血氧饱和度。最后将血氧饱和度值显示出来就行了。

三、血氧仪测量准不准?
在实现过程中,SpO2与R的关系的系数是非常难确定的,需要大量的试验数据来拟合,见下图,是maxim公司应用文档中的拟合过程:
(每种颜色是一组测试结果,黄色叉是去除掉的偏离比较大的野值)
可以发现,有些测量数据的方差是相当大的,很多数据偏离了拟合后的曲线很远。maxim公司建议在校准时,需要不断剔除偏离较大的数据,均方根误差(RMES)需要在3.5%以内。
最终给出一组值:
可是,在另一篇maxim公司的应用文档中,又给出了SpO2 = 104-17*R这个公式,其中0.4<R<3.4。

为什么这两公式相差这么大?

通过查阅一些论文发现,对于R值与血氧饱和度的公式并不固定,SpO2可以表示为R的一个高次的多项式函数,由于正常人体测出的R值都较小,人们一般关注的是R值小于1的情况,大于1已经是明显的不健康情况。所以,在计算SpO2时常常会去掉高次项,采用一阶函数或者二阶函数来拟合。
又由于SpO2的测量方法本身误差较大,所以测量数据不同时,拟合出来的参数就大相径庭了。这里还收集了几个论文中拟合出的R值与SpO2之间的函数关系:
  • SpO2 = -45.060*R*R+ 30.354*R+ 94.845
  • SpO2 = -7.6*R*- 20.7*R+ 112.2,(0.5<R<1.4)
  • SpO2 = -86.47*R*R+ 77.21*R+ 81.68,(0.4<R<1)
  • SpO2 = -20*x+107.2,(0.36<R<0.66),-54*x+129.64,(0.66≤R<1)
把这几个函数的图形绘制在同一张图中:

可以看到,在R为0.4~1.0这个区间里,这些函数的值大体上相差不大,变化趋势也基本一样。而且这些参数,一般都是以正常人的数据来拟合的。所以,在正常血氧的范围内,可以认为用这种方法来测量血氧饱和度基本靠谱。而当血氧饱和度偏离正常值时,误差会显著增大。当然,这需要建立在光源的采集数据准确的前提下,也就是R值准确的时候。而现实是,在采集光源的数据时,会有环境光干扰、工频干扰、各种噪声干扰;即使滤除了这些噪声,还会有如下图这种低频的漂移。此时,要准确提取出光源的直流分量、交流分量是非常困难的。


因此,如果信号处理的算法不好,就会把微弱的噪声、漂移等等干扰识别为脉搏引起的光强变化,网上出现的各种能测出香肠的血氧和脉搏的笑话也就不足为奇了。综合来看,此类血氧仪作为健康监测的参考手段之一是可以的,但数据准确性存疑。所以,以它来判断身体是否健康是万万不能的!好了,本节内容就分享到这里了,希望这篇文章能对大家有所帮助。

来源:小白白学电子


+10
回复

使用道具 举报

沙发
发表于 2023-2-1 15:04:40 | 只看该作者

Digital Marketing Hub

This module is designed to develop within college students the postgraduate examine expertise which includes research awareness, business vocabulary, and local industrial acculturation. We work with tons of of consumers across the UK - from automotive vendor groups to franchise networks to massive corporates to small unbiased companies. We create advertising campaigns for b2b and b2c audiences and provide account set-up, administration or evaluation for one-off tasks and long run contracts. We are happy to come and meet you and equally joyful to review your present suppliers. Accredited by the Chartered Institute of Marketing , the course will prepare you for a successful career in quite a lot of advertising roles, including consultancy, brand management, marketing analysis, communications, and digital roles. The University of Exeter is among the few Russell Group universities to supply Masters in each Marketing and Digital Marketing.ยูฟ่า สล็อต ออโต้
This module goals to help you identify and make sense of significant patterns in data sets and can familiarise you with the analytical tools and techniques to assist evidence-based decision-making. The versatile supply of on-line studying assets and activities facilitated by digital marketing specialists and practitioners fits completely round a full-time job, wherever you may be based mostly. In addition, you may incessantly be required to place your expertise and information into apply throughout the course, with stay and practical applications 'on the job' as you progress. You also have the chance to entry research help, including tutorial writing and research abilities to enhance your career growth in the subject of management and coaching.ยูฟ่าเบท
It is a very good choice to decide on in case you are contemplating shifting into academic analysis or PhD upon completion of your master’s programme. This module aims to develop your core skills in social media-based focusing on and communication methods. We will consider a bunch of topics that look at the strategic evaluation of social media platforms from a communications perspective, key metrics, instruments, techniques and strategy improvement frameworks. Develop the abilities you want for a career in digital advertising on this specialist UK master’s course. Our lecturers mix analysis with professional knowledge, to incorporate the newest developments from the sector into your studying. You’ll be nicely ready to enter the trade, geared up with the skills which are most in  demand. สล็อตฝากถอน ไม่มี ขั้นต่ํา
You will work in devoted high-quality recording and post-production suites, and use the newest software program together  with Pro Tools, Ableton, FMOD and Unreal/Unity. User expertise, content material administration and search engine optimisation are addressed, with a concentrate on writing and creating content for web distribution and publishing. You will build skills within the creation of multimedia content, learn to set up a content material management system and modify it to present consumer experience and design tips. This platform permits you to combine and make an efficient use of the main on-line advertising strategies. No matter what kind of strategy you employ, all of them should work towards boosting your web site. Keep in mind that boosting your website is equal to selling your brand.
The School relies in the Redmonds Building, within the coronary heart of the bustling Mount Pleasant Campus and Liverpool’s rising Knowledge Quarter. The constructing is house to top quality lecture theatres and seminar rooms, social spaces, and a café. It is just a brief stroll from LJMU’s Aldham Robarts Library, which contains all of the sources you will require for your studies, and is open 24 hours a day, seven days per week. The MSc Digital Marketing at LJMU will prolong your conventional advertising data and equip you with new data and approaches to succeed in digital audiences.
Simon's in-depth understanding of such a broad vary of digital advertising channels and topics makes this book undoubtedly an important read for each budding and experienced digital marketing professionals alike. Build an efficient and practical digital advertising technique with this bestselling guide, covering every little thing from automation and analytics to integrating AI. Plan, implement and optimize a tailored, end-to-end digital advertising strategy that aligns with enterprise objectives with this re-creation of the global bestseller. You'll refine dynamic business and marketing practices, spending hours per week working on your craft, relying on whether you select to study full-time or part-time. There might be as a lot as two per 12 months and can typically run over weekends, to fit round your other commitments.
You can then examine bids, view tutors profile, college students responses and communicate with a tutor on-line before you schedule a lesson. I really have tutored college students all through their tutorial careers, from Secondary School to Undergraduate to Master's Level, overlaying topic content in addition to essay and examination preparation. Gain insight into rising digital marketing channels and the methods to make use of new technologies strategically.
+10
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号|Sitemap

GMT+8, 2024-9-28 00:18 , Processed in 0.233791 second(s), 46 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表