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
| """ 汽车座椅纺织ECG方案
借鉴军用飞行服纺织传感器技术 """ CAR_SEAT_ECG_DESIGN = { 'electrode_type': '织物电极(碳纤维/银纤维)', 'position': { 'back_left': '座椅靠背左侧(接触左背)', 'back_right': '座椅靠背右侧(接触右背)', 'reference': '座椅坐垫(接触大腿)', }, 'advantages': [ '无需用户佩戴任何设备', '自然接触(靠背+坐垫)', '不可见,美观', '可加热/通风不影响信号', ], 'challenges': [ '衣物厚度影响接触阻抗', '不同体型接触压力不同', '运动伪影(颠簸路面)', '长期使用磨损', ], 'expected_performance': { 'resting_hr_accuracy': '< 3 bpm', 'hrv_accuracy': 'SDNN误差<10%', 'stress_detection_accuracy': '~75%', 'usable_time': '> 85%', } }
class CarSeatECGMonitor: """ 汽车座椅ECG监测器 硬件: - 3个织物电极(靠背左/靠背右/坐垫参考) - AD8232心率监测IC - BLE/MCU连接DMS处理器 """ def __init__(self): self.config = CAR_SEAT_ECG_DESIGN self.sampling_rate = 250 self.quality_assessor = ECGSignalQualityAssessor() def monitor(self, ecg_raw): """ 实时监测 Args: ecg_raw: shape=(n_samples,), 座椅ECG原始信号 Returns: vital_signs: dict """ quality, metrics = self.quality_assessor.assess(ecg_raw) if quality == 'C': return {'status': 'unavailable', 'reason': 'poor_signal'} hr = self._estimate_hr(ecg_raw) hrv = self._estimate_hrv(ecg_raw) stress_prob = self._estimate_stress(hr, hrv) return { 'heart_rate': hr, 'hrv_sdnn': hrv, 'stress_probability': stress_prob, 'signal_quality': quality, } def _estimate_hr(self, ecg): """心率估计""" from scipy.signal import find_peaks peaks, _ = find_peaks(ecg, distance=100, height=0.3*np.max(ecg)) if len(peaks) < 3: return None rr = np.diff(peaks) / self.sampling_rate hr = 60 / np.mean(rr) return hr def _estimate_hrv(self, ecg): """HRV(SDNN)估计""" from scipy.signal import find_peaks peaks, _ = find_peaks(ecg, distance=100, height=0.3*np.max(ecg)) if len(peaks) < 5: return None rr = np.diff(peaks) / self.sampling_rate * 1000 return np.std(rr) def _estimate_stress(self, hr, hrv): """压力估计(LF/HF代理)""" if hr is None or hrv is None: return 0.5 stress = min(max((hr - 60) / (100 - 60), 0), 1) if hrv < 30: stress = min(stress + 0.2, 1.0) return stress
|