血氧饱和度计算函数异常:结果为负值问题求助
血氧饱和度计算函数异常排查与重实现
实现血氧饱和度计算函数时出现异常:采用公认的科学公式计算,返回结果为负值,且绝对值与正确值相差数个百分点,预期结果应为0-100之间的正值,推测问题出在血氧系数计算或常量使用上。
原问题代码
private float _calculate_blood_oxygen_saturation( float inspiredPartialPressure_kPa, float arterialPartialPressure_kPa, float temperature_C ) { // Constants for the oxygen-hemoglobin dissociation curve coefficients const float _A = -173.4292f; const float _B = 248.3763f; const float _C = 0.7102f; const float _D = -0.9959f; const float _E = -0.2337f; // Calculate the oxygen saturation curve coefficient float temperature_K = temperature_C + 273.15f; float oxygenSaturationCurveCoefficient = _A + ( _B / temperature_K ) + ( _C * Mathf.Log( temperature_K ) ) + ( _D * Mathf.Pow( 10.0f, _E * ( temperature_K - 50 ) ) ); // Calculate the oxygen saturation percentage float saturationPercentage = ( inspiredPartialPressure_kPa / arterialPartialPressure_kPa ) * 100.0f; float saturation = ( saturationPercentage / oxygenSaturationCurveCoefficient ) * 100.0f; return saturation; }
补充输入参数
arterialPartialPressure为常量(95 mmHg * 0.133322f)- 环境温度接近20℃
inspiredPartialPressure取值约为20
参考生理资料与重实现代码
参考生理资料:
- 血氧饱和度:血红蛋白中氧合血红蛋白的占比,可通过血氧测定仪直接测量
- 血氧容量:血红蛋白能结合的最大氧量,计算公式为患者血红蛋白值 × 1.34,单位为mL/100mL
基于上述资料修订公式与计算逻辑,简化使用平均生理常量以生成合理输出,更新后代码如下:
private float _calculate_blood_oxygen_content( float inspiredPartialPressure, float arterialPartialPressure) { // Calculate the partial pressure of oxygen in arterial blood via alveolar gas // using the formula PaO2 = PIO2 - (PaCO2 / R) - (F * (P - PaH2O)) // Note: we are intentionally disregarding: // F: the fraction of inspired gas which is not oxygen // PaH2O: and the partial pressure of water vapor in the inspired gas float PaCO2 = 5.25f; // partial pressure of CO2 in alveolar gas, in kPa // (widely variable, but distilled to an average until // a working model to correctly calculate this is built) float R = 0.8f; // respiratory exchange ratio (overly simplified) float PaO2 = inspiredPartialPressure - (PaCO2 / R); // Calculate the oxygen-hemoglobin dissociation curve, // using the formula S = (1 / (1 + 10^((p50 - log(P)) / n))) ^ m const float p50 = 3.5463652f; // kPa const float n = 2.25f; const float m = 2.5f; float x = 1f + Mathf.Pow(10f, (p50 - Mathf.Log(arterialPartialPressure))); float S = Mathf.Pow(1f / x / n, m); // Calculate oxygen content of bound and dissolved oxygen, // using the formula CaO2 = (SaO2 x Hb x 1.34) + (PaO2 x 0.003) const float oxygenSolubility = 0.003f; const float Hb = 14f; // average hemoglobin concentration in g/dL float SaO2 = S * 100f; float CaO2 = (SaO2 * Hb * 1.34f) + (PaO2 * oxygenSolubility); // mL O2 / dL blood return CaO2; }
内容的提问来源于stack exchange,提问作者szsleepy
相关产品推荐
相关产品推荐

