A multi-modal sleep physiological index time series report generation method and system
Patent Information
- Application Number
- CN202611020225.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-10-13
AI Technical Summary
[0007]为了解决现有技术中存在的缺陷或不足,本发明提供了一种多模态睡眠生理指标时间序列报告生成方法及系统,通过构建模拟真实睡眠医疗团队协作范式的多智能体框架,并引入共享内存缓冲区实现智能体间高效并发控制;利用技师智能体结合临床文本生成个性化生理预警边界,解决了单一模型缺乏上下文解释及固定阈值导致的假阳性问题;通过医师智能体与顾问智能体的反事实质询交互,克服了单一模型易陷入确认偏误、无法模拟对抗性会诊的缺陷;借助代码智能体在安全沙箱中执行代码生成可视化图表,并由医师智能体评分筛选最优图表集合,再经综合智能体融合生成长文诊断报告,从而有效解决了大语言模型在处理精确医疗数值计算时易产生计算幻觉、多模态上下文窗口饱和及视觉证据缺失的问题
(1)通过构建包含技师智能体、医师智能体、顾问智能体、代码智能体及综合智能体的多智能体协同架构,并引入共享内存缓冲区实现智能体间的高效并发控制,在睡眠生理时间序列分析领域实现了模拟真实临床医疗团队协作范式的自动化诊断流程。与传统的人工逐帧判读或单一的机器学习检测算法相比,本发明不仅输出睡眠分期与事件标签,更能生成包含病理机制解释、反事实推理过程及多模态视觉证据的自然语言长文诊断报告,显著降低了临床医生的认知负荷,将整夜长达数小时的数据分析效率提升至分钟级。
Smart Images

Figure CN122907223A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the interdisciplinary field of medical and health informatics and clinical decision support systems, and in particular to a method and system for generating time series reports of multimodal sleep physiological indicators. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] In modern clinical sleep medicine, continuous monitoring of multimodal physiological signals throughout the night (such as electroencephalogram, electrooculogram, electrocardiogram, blood oxygen saturation, respiratory airflow, and chest and abdominal movements) constitutes the core basis for diagnosing sleep disorders. With the widespread use of high-precision wearable devices and polysomnography (PSG), the massive, high-frequency overnight data streams acquired by medical institutions have not been effectively translated into improved clinical decision-making efficiency. Traditional methods mainly rely on manual frame-by-frame interpretation or automated detection algorithms based on models such as support vector machines, long short-term memory networks, and Transformers. These methods can only output isolated sleep stage labels or fragments of abnormal events, failing to provide contextual natural language explanations regarding pathological mechanisms, causes of sleep apnea, and the risk of systemic complications. In clinical sleep assessments, physicians need to manually correlate observed deviations in sleep physiological signals with a large amount of information such as the patient's clinical background (e.g., past medical history, demographic characteristics), and basic medications. This enormous "cognitive load" and the data length of several hours significantly restrict diagnostic efficiency.
[0004] In recent years, the explosive growth of generative artificial intelligence, especially large language models with hundreds of billions of parameters (such as GPT, Claude, and Llama), has provided new directions for processing complex medical texts and time-series data. Many studies have attempted to use single, all-encompassing large language models to directly transform complex physiological signals into clinical interpretations in natural language. However, existing large language model inference systems still face several serious technical challenges when deployed in real-world sleep medicine scenarios: First, the diagnosis of modern evidence-based sleep medicine is essentially an adversarial game process involving multiple roles and including a "hypothesis-falsification" phase (such as determining whether it is obstructive or central sleep apnea). However, the single Large Language Model (LLM) is limited by the linear nature of its autoregressive generation, making it prone to confirmation bias in the early stages of reasoning and unable to intrinsically simulate the cross-consultation and counterfactual blind spot screening led by senior specialists in a medical team.
[0005] Second, the severity grading of sleep disorders heavily relies on absolutely precise mathematical feature extraction, such as the continuous statistics of the Apnea-Hypopnea Index (AHI) and the Oxygen Desaturation Index (ODI). LLM, essentially a neural term predictor based on probability distributions, is highly susceptible to fine-tuning biases when performing deterministic floating-point operations or multidimensional matrix aggregation. In medical settings, even minute boundary errors in numerical calculations can lead to misdiagnosis, such as incorrectly determining the disease severity level.
[0006] Third, the discretization of long-term physiological time series spanning up to 8 hours overnight can trigger the "curse of dimensionality," rapidly depleting the attentional context window of LLM and causing the "lost in the middle" effect. Furthermore, plain text reports lack objective visual assets such as sleep structure diagrams (Hypnograms) and polyphasic waveforms of abnormal breathing events as data anchors, making it difficult to establish cognitive trust among human physicians. Summary of the Invention
[0007] To address the shortcomings and deficiencies in existing technologies, this invention provides a method and system for generating time-series reports of multimodal sleep physiological indicators. It constructs a multi-agent framework simulating a real-world sleep healthcare team collaboration paradigm and introduces a shared memory buffer to achieve efficient concurrent control between agents. By utilizing a technician agent in conjunction with clinical text to generate personalized physiological warning boundaries, it solves the false positive problem caused by the lack of contextual explanation and fixed thresholds in single models. Through counterfactual questioning interaction between physician and consultant agents, it overcomes the shortcomings of single models, such as being prone to confirmation bias and unable to simulate adversarial consultations. Furthermore, by using a code agent to execute code in a secure sandbox to generate visual charts, and having the physician agent score and select the optimal chart set, which is then fused by a comprehensive agent to generate a long-form diagnostic report, this effectively solves the problems of computational illusion, multimodal context window saturation, and lack of visual evidence that large language models easily generate when processing precise medical numerical calculations.
[0008] On the one hand, a method for generating time series reports of multimodal sleep physiological indicators is provided, including: Multimodal sleep physiological sequence data and clinical text data are acquired, and the physiological sequence data is preprocessed and written into a shared memory buffer. Based on the physiological sequence data, a technician's intelligent agent is used to calculate a quantitative index including the apnea-hypopnea index, and combined with the clinical text data to generate a physiological warning boundary. The physician agent generates an initial diagnostic hypothesis based on the quantitative indicators; the advisor agent challenges the initial diagnostic hypothesis with counterfactual statements; the physician agent responds to the counterfactual statements and generates natural language instructions; the code agent converts the natural language instructions into code and executes them in a secure sandbox, outputting a visual chart. The physician agent scores the clinical relevance of the visualization charts and selects the optimal set of charts based on the scoring results. When the evidence in the optimal set of charts meets the preset conditions or the number of iterations reaches the preset limit, the integrated agent reads the time series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and merges the read data to generate a long-form diagnostic report.
[0009] Furthermore, the technician agent, the physician agent, the consultant agent, the code agent, and the integrated agent interact using a star topology architecture. A central coordinator is deployed at the central node of this star topology architecture to centrally manage the global shared memory buffer, and concurrent control between agents is achieved through an event bus and read-write locks.
[0010] Furthermore, the technician intelligent agent, physician intelligent agent, consultant intelligent agent, code intelligent agent, and comprehensive intelligent agent are all built based on a large language model; the technician intelligent agent also includes a mathematical calculation kernel for calculating quantitative indicators; the code intelligent agent also includes an abstract syntax tree analyzer for static code analysis and a sandbox for isolating and executing code.
[0011] Furthermore, physiological warning boundaries are generated by combining the aforementioned clinical text data, specifically as follows: The technician's intelligent agent reads the patient's past medical history and medication records, and dynamically adjusts the alarm thresholds of physiological indicators based on specific pathological states in the past medical history. The dynamic adjustment includes: when the past medical history includes chronic obstructive pulmonary disease, adjusting the lower limit of the alarm baseline for blood oxygen saturation from an absolute threshold to a relative threshold based on the percentage decrease in the patient's awake baseline.
[0012] Furthermore, the physician agent generates an initial diagnostic hypothesis based on the quantitative indicators; the advisor agent challenges the initial diagnostic hypothesis with counterfactual statements, and the physician agent responds to the counterfactual statements by generating natural language instructions. Specifically, the physician agent constructs a two-dimensional severity mapping function based on the apnea-hypopnea index and the lowest nocturnal oxygen saturation, and outputs an initial diagnostic hypothesis that includes a severity rating of sleep apnea; the advisor agent is injected with a counterfactual prompt protocol, which forces the physician agent to consider pathological possibilities that contradict the current diagnostic hypothesis; the physician agent generates natural language instructions based on the forced requirement.
[0013] Furthermore, the code agent translates the natural language instructions into code and executes it in a secure sandbox, outputting a visual chart. Specifically, the code agent generates Python source code containing scientific computing library calls based on a large language model and parses the source code into an abstract syntax tree; before execution, it statically traverses all nodes, prohibiting nodes containing network requests, operating system calls, and dynamic code execution; after passing static checks, the source code is submitted to the Docker sandbox for execution; if an exception is thrown during execution, the exception stack is captured and returned to the code agent for self-correction, regenerating the code until execution is successful or the maximum number of corrections is reached; after successful execution, the output visual chart is stored in a shared memory buffer.
[0014] Furthermore, the physician agent performs clinical relevance scoring on the visualization charts and selects the optimal chart set based on the scoring results. Specifically, the physician agent performs graded scoring on each visualization chart, where high-grade charts reflect key pathological features and low-grade charts are considered redundant. A preset number of charts with the highest scores are selected from all charts as the optimal chart set, and charts with scores below a preset low score threshold are unloaded from the active context.
[0015] Furthermore, the integrated intelligent agent reads the time-series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and integrates the read data to generate a long-text diagnostic report. Specifically, the integrated intelligent agent reads the patient background, quantitative indicators, physiological warning boundaries, diagnostic reasoning logs, and optimal chart set in the shared memory buffer; according to the sleep medicine report template, the charts are embedded into the corresponding abnormal event descriptions in an inline text and image mixed format to generate a long-text diagnostic report.
[0016] On the other hand, a multimodal sleep physiological index time series report generation system is provided, including: The data acquisition and preprocessing module is configured to: acquire multimodal sleep physiological sequence data and clinical text data, and write the physiological sequence data into a shared memory buffer after preprocessing it; The technician intelligent agent module is configured to: calculate a quantitative index including the apnea-hypopnea index based on the physiological sequence data, and generate a physiological warning boundary in combination with the clinical text data; The physician intelligent agent module is configured to: generate initial diagnostic hypotheses based on the quantitative indicators; respond to counterfactual inquiries from the advisor intelligent agent module and generate natural language instructions; score the clinical relevance of the visualization charts and select the optimal set of charts based on the scoring results; The advisory agent module is configured to: challenge the initial diagnostic hypothesis with counterfactual statements; The code-based intelligent agent module is configured to: convert the natural language instructions into code and execute them in a secure sandbox, outputting visual charts; The integrated intelligent agent module is configured to: when the evidence in the optimal chart set reaches a preset condition or the number of iterations reaches a preset upper limit, read the time series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and fuse the read data to generate a long-form diagnostic report.
[0017] In another aspect, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, performs the method described in the first aspect.
[0018] The above technical solution has the following advantages or beneficial effects: (1) By constructing a multi-agent collaborative architecture comprising technician agents, physician agents, consultant agents, code agents, and integrated agents, and introducing a shared memory buffer to achieve efficient concurrent control among agents, an automated diagnostic process simulating the collaborative paradigm of a real clinical medical team has been realized in the field of sleep physiological time series analysis. Compared with traditional manual frame-by-frame interpretation or single machine learning detection algorithms, this invention not only outputs sleep stages and event labels, but also generates long-form natural language diagnostic reports containing explanations of pathological mechanisms, counterfactual reasoning processes, and multimodal visual evidence, significantly reducing the cognitive load on clinicians and improving the efficiency of data analysis, which can take several hours overnight, to the minute level.
[0019] (2) A dual-track calculation pipeline is adopted, in which the deterministic mathematical kernel of the technician agent completes the closed-loop calculation of core quantitative indicators such as apnea-hypopnea index and oxygen depletion index, while the large language model is only used for semantic reasoning and personalized threshold generation. This decoupled design fundamentally blocks the probabilistic misjudgment of medical-grade values, ensures the absolute accuracy of disease severity classification, and avoids the risk of misdiagnosis due to small numerical deviations.
[0020] (3) The counterfactual questioning loop between the physician agent and the consultant agent reproduces the adversarial game logic of "hypothesis-falsification" in multidisciplinary consultation. The consultant agent forces the physician agent to consider pathological possibilities that contradict the initial diagnosis (such as distinguishing between obstructive and central sleep apnea) and generate quantitative physiological signal cross-validation tasks, thereby effectively overcoming the defect of single autoregressive models that are prone to early confirmation bias and significantly reducing the rate of missed diagnosis and misdiagnosis.
[0021] (4) A ranking-selection-pruning algorithm based on clinical relevance scoring was introduced. The physician agent scores each visualization chart, retaining only a preset number of charts with the highest scores as the optimal chart set, and dynamically pruning redundant visual assets with low information gain. This maximizes the density of clinical evidence within a limited context window and alleviates the "lost in the middle" effect of large language models. In addition, the generated report embeds high-value charts in the description of abnormal events in a mixed text and image format, providing clinicians with objective and traceable visual anchors and establishing cognitive trust in human-machine collaboration.
[0022] In summary, the present invention significantly outperforms existing technologies in key dimensions such as interpretability, numerical accuracy, inference robustness, and contextual efficiency in diagnostic report generation. Attached Figure Description
[0023] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0024] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention; Figure 2 This is an overall framework diagram of the method in Embodiment 1 of the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings. Those skilled in the art should understand that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0026] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0027] Example 1 This invention relates to a method for generating time-series reports of multimodal sleep physiological indicators that integrates Large Language Models (LLMs) and a multi-agent collaborative architecture. Addressing the complex medical environment of hospital sleep medicine centers and sleep monitoring rooms (including polysomnography monitoring, etc.) with their interwoven multimodal high-frequency data, this invention constructs a multi-agent framework that simulates a real-world sleep medicine team collaboration paradigm (encompassing roles such as sleep monitoring technicians, sleep specialists, respiratory / neurological consultation consultants, data scientists, and senior general physicians). This provides an intelligent monitoring and interpretation method for sleep physiological states that conforms to real-world clinical diagnostic logic and is driven by objective graphical evidence. This method not only overcomes the technical bottlenecks of traditional automatic sleep staging and respiratory event detection but also effectively solves the technical problem of "illusions" easily generated by large language models when processing precise medical numerical calculations.
[0028] To overcome the technical barriers of unreliable numerical calculations, unidirectional reasoning logic, and broken visual evidence chains in existing LLM (Low-Level Microscopy) multivariate time-series sleep analysis, this invention surgically decouples the traditional black-box LLM holistic reasoning task and reconstructs it into a multi-stage directed acyclic process consisting of "deterministic initial screening feature extraction," "adversarial diagnostic consultation loop," "restricted sandbox code execution," and "evidence information entropy pruning and synthesis." Specifically, this invention introduces a non-neural computational local execution pipeline to ensure that the calculation error of clinically sensitive scale indicators (such as AHI and ODI) approaches absolute zero, fundamentally blocking computational illusions; it creates a set of agents with different system-level prompts and action spaces, especially introducing a consultation agent that enforces counterfactual reasoning, using a multi-agent game network to reduce false negative rates; and it proposes a goal optimization algorithm based on "sorting-selection-pruning" to dynamically manage the global context window. By driving the code agent to generate graphical assets and retaining only visual charts that maximize clinical information gain, it effectively suppresses attentional distractions and provides intuitive medical interpretability.
[0029] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings. This embodiment provides a method for generating time series reports of multimodal sleep physiological indicators. Figure 1 This is a flowchart of a method according to Embodiment 1 of the present invention, which specifically includes the following steps: S101: Acquire multimodal sleep physiological sequence data and clinical text data, and write the physiological sequence data into a shared memory buffer after preprocessing. S102: Based on physiological sequence data, the technician's intelligent agent calculates quantitative indicators including the apnea-hypopnea index and combines them with clinical text data to generate physiological warning boundaries. S103: The physician agent generates an initial diagnostic hypothesis based on quantitative indicators; the advisor agent conducts counterfactual questioning on the initial diagnostic hypothesis; the physician agent responds to the counterfactual questioning and generates natural language instructions; the code agent converts the natural language instructions into code and executes them in a secure sandbox, outputting a visual chart. S104: The physician agent scores the clinical relevance of the visualized charts and selects the optimal set of charts based on the scoring results; S105: When the evidence in the optimal chart set meets the preset conditions or the number of iterations reaches the preset limit, the integrated agent reads the time series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and merges the read data to generate a long-form diagnostic report.
[0030] Figure 2 This is an overall framework diagram of the method proposed in this invention. Specifically, in step S101, initialization and multimodal perception data preprocessing are first performed. Before the multi-agent system begins inference, the multimodal sleep physiological sequence data collected by the front-end sleep monitoring device must undergo rigorous physiological rationality filtering and outlier cleaning. This is not only a requirement to eliminate sensor detachment noise, but also a necessary means to prevent subsequent large-scale models from generating erroneous inferences.
[0031] Specifically, the system connects in real-time to sleep monitoring equipment via standard medical protocols such as HL7 / FHIR to acquire multimodal sleep physiological sequence data (such as EEG, SpO2, and airflow) with timestamps, representing the total number of sampling points collected within the entire night's sleep time window. Simultaneously, the system acquires the patient's clinical text data, including chief complaint, past medical history, medication records, and demographic characteristics (such as age, gender, and body mass index), and stores this text data in the patient's baseline profile partition within a shared memory buffer.
[0032] To ensure the quality of data written to the Shared Memory Buffer (SMB), this invention incorporates a physiological rationality boundary filter. For any sampling point at any given time, it determines whether it falls outside physiological limits (e.g., setting reasonable ranges for heart rate (bpm) and blood oxygen saturation). Artifacts caused by patient turning over, i.e., discrete values exceeding these absolute boundaries or experiencing sudden changes, are marked as sensor artifacts and smoothed using a smoothing algorithm based on cubic spline interpolation or adaptive Kalman filtering. The preprocessed multidimensional time series matrix is written into the time series block of the SMB, and a time boundary index is established to ensure that all awakened agents observe time-aligned data from the same time segment.
[0033] In terms of concurrency control, SMB is designed as a state machine-driven, high-concurrency, safe JSON object graph. This embodiment abandons the inefficient peer-to-peer (P2P) direct communication paradigm between agents, adopting a star topology architecture with a central coordinator and a global shared memory buffer. The patient's multidimensional time-series matrix (such as EEG, SpO2, and airflow), unstructured electronic medical record text, quantitative calculation scalars, and visual chart pointers are all serialized and mounted in the SMB's object tree. The core partitions of the buffer include: Subject_Baseline_Profile (subject's sleep baseline characteristics and NLP vectorized medical history), PSG_Scoring_Metrics (sleep quantification indicators output by the technician agent during the initial screening stage), Diagnostic_Reasoning_Log (multi-agent dynamic diagnostic inference evolution log), and Visual_Evidence_Assets (URIs of visualization chart files and their dynamic information entropy weight pool). The central coordinator monitors the state changes of each partition through an event bus and applies mutex locks during sandbox I / O operations to ensure strong consistency between chart writing and large model reading. Each agent acts as an independent working node, accessing the SMB through strict read / write locks and event-driven interfaces, thereby ensuring state consistency and sandbox isolation during high-frequency interactions.
[0034] In step S102, after completing the data preprocessing and shared memory buffer construction in step S101, step S102 enters the dual-track computing pipeline and personalized physiological threshold dynamic deduction stage. Because large language models are extremely unstable in numerical sensitivity tasks and prone to "hallucinations," a dual-track architecture that separates the deterministic computing engine and the semantic understanding engine is adopted when waking up the technician agent to avoid this risk at its source.
[0035] The initial screening process is a pre-processing step before the system introduces large-scale model inference. It involves a technician agent using a deterministic pre-defined algorithm to transform the raw waveforms into objective numerical indicators. Specifically, the technician agent has a built-in local C++ / Python mathematical calculation kernel independent of the LLM interface. When the initial screening process is triggered, this kernel directly reads the time series data from the SMB and calculates core quantitative indicators based on fixed sleep medicine interpretation standards (such as the AASM guidelines). Specifically, it scans the entire night's data, extracts the total effective sleep time (TST), and counts the total number of detected apnea events and hypopnea events to calculate the Apnea-Hypopnea Index (AHI). ; in, and The total number of apnea and hypoventilation events detected. Total effective sleep time is measured in hours.
[0036] Simultaneously, the number of times blood oxygen levels dropped beyond a preset threshold (3% or 4%) was counted to obtain the oxygen depletion index (ODI): ; in, This refers to the number of times blood oxygen levels dropped by more than 3% or 4%. The results calculated by this local engine are timestamped and written to the SMB to ensure absolute accuracy.
[0037] Based on the high-precision quantitative indicators obtained above, the large-model semantic module of the technician's intelligent agent is invoked to read the clinical text data (including the patient's past medical history, medication records, and demographic characteristics, etc.) stored in the shared memory buffer (SMB) in step S101, and personalized baseline drift inference is performed using clinical rules. For example, when a patient's PMH includes "severe chronic obstructive pulmonary disease," the LLM will generate adaptive adjustment instructions in the background to overturn the general nighttime blood oxygen alarm baseline (such as a fixed one). ), and dynamically relax it to baseline dynamic tracking mode (e.g., modify the trigger condition to Or, compared to a 4% relative decrease from the patient's baseline conscious state. This is because for patients with severe COPD, their baseline conscious blood oxygenation is already at a low level, and relatively small fluctuations in blood oxygenation can trigger clinically significant oxygen depletion events. This mechanism ensures that a large number of false positive alarms are not generated due to a fixed threshold. Through this mechanism, the generated physiological warning boundaries can be adapted to the individualized pathological characteristics of the patient. These highly personalized clinical backgrounds and threshold rules will serve as global presets, continuously standardizing the judgment criteria of other agents in subsequent processes.
[0038] In step S103, an adversarial ward round loop based on a counterfactual framework is initiated. To avoid a single model falling into the diagnostic trap of premature closure, an adversarial image reading workflow containing an internal loop state machine is designed, which unfolds between the physician agent and the consultant agent. A preset maximum number of iterations is set, and the sub-steps are repeated as long as the preset upper limit is not exceeded and the evidence sufficiency flag is false.
[0039] At the start of each cycle, the physician agent reads the latest sequential physiological data from the SMB, proposes initial diagnostic hypotheses, and outputs structured quantitative predictions. Specifically, the physician agent, based on the clinical guidelines of the Chinese Medical Association's "Guidelines for the Diagnosis and Treatment of Adult Obstructive Sleep Apnea," combines the apnea-hypopnea index (AHI) with the lowest nocturnal oxygen saturation (NOS). Construct a two-dimensional severity mapping function The more severe grade between the two is taken as the final clinical diagnosis level (i.e., the "higher is better" principle), and its conditional piecewise function is defined as follows: .
[0040] After obtaining the objective severity grading, the physician agent further reads the Epworth Sleepiness Scale (ESS) score parsed in step S101 from the shared memory buffer, using it as the core quantitative dimension characterizing the patient's subjective daytime symptoms. ESS is an internationally recognized standardized self-report questionnaire tool used to assess the degree of daytime sleepiness in patients, with a total score ranging from 0 to 24 points; a higher score indicates a more severe tendency towards daytime sleepiness. In clinical studies, an ESS total score ≥9 is typically defined as the threshold indicating pathological daytime sleepiness. The physician agent is configured to execute a subjective-objective cross-mapping logic, that is, to perform a consistency comparison between the objective severity grading and the subjective ESS score to output the final initial diagnostic hypothesis and the corresponding confidence level.
[0041] Specifically, in this embodiment, the physician agent reads the ESS score from the shared memory buffer in step S101. Based on the existing sleep apnea severity grading results from step S103 (Severity is assessed on a scale of 0, 1, 2, and 3 according to the aforementioned criteria), an upward intervention warning mechanism is established: when the two-dimensional mapping function is objectively determined to be mild OSA (i.e., However, the patient's subjective assessment showed significant daytime sleepiness (e.g.) When this occurs, the symptom weighting penalty item is activated, forcibly triggering a clinical active intervention warning and upgrading the treatment path towards non-invasive ventilator (CPAP) intervention.
[0042] On the other hand, a reverse error-checking trigger mechanism is set up: when objectively determined to be a moderate to severe anomaly (e.g. However, the subjective symptom score was no drowsiness (e.g., no somnolence). When this "severe deviation between subjective and objective factors" is detected, the feature is extracted as an anomaly anchor point. Furthermore, the physician agent is forced to use a Chain of Thought (CoT) to demonstrate this multi-dimensional classification judgment, explaining why the patient is classified as either a severe OSA requiring non-invasive ventilator (CPAP) treatment or a mild condition requiring only lifestyle and postural interventions.
[0043] Subsequently, the advisor agent intervenes forcefully, injected with a stringent counterfactual cue protocol, to perform counterfactual reasoning on the initial inference. For example, suppose the physician agent concludes that "the patient frequently experiences cessation of airflow through the mouth and nose accompanied by a decrease in blood oxygen, diagnosed as severe obstructive sleep apnea (OSA)." The advisor agent will not simply agree, but will generate adversarial counterfactual challenges based on rules: "Criticism: The sleep physician's assumption has blind spots, ignoring the possibility of Cheyne-Stokes respiration and central sleep apnea (CSA) caused by central nervous system abnormalities or heart failure. An exclusive verification task is required: Thoracoabdominal efficacy signals synchronized with the airflow-missing segments must be retrieved and subjected to dynamic cross-correlation analysis in a sandbox. If thoracic and abdominal efficacy also completely disappears during the airflow cessation, it is highly likely to be central sleep apnea, and the initial diagnosis must be revised."
[0044] The physician agent is forced to respond to the criticisms of the advisor agent, generating specific quantitative analysis natural language instructions, which are then sent to the data operation backend (i.e., the code agent) via the system bus. This micro-cycle of "hypothesis-questioning-data exploration" replicates the complex logic of multidisciplinary consultations for difficult sleep problems.
[0045] After receiving natural language instructions, the code agent generates Python source code containing calls to scientific computing libraries (such as NumPy and SciPy) based on a large language model. To ensure the absolute security of the host machine hosting the medical system, an abstract syntax tree (AST) analyzer is set up for static code analysis before the script injection sandbox execution: Python's built-in `ast` module parses the source code generated by the large model into an abstract syntax tree (AST). Before execution, all nodes are statically traversed, and any nodes containing network requests (requests or urllib), operating system-level calls (such as `os.system`), and dynamic code execution are prohibited. Once a node is found to contain unauthorized module imports or malicious system calls, it is immediately intercepted outside the sandbox.
[0046] After static analysis, the source code is submitted to a Docker runtime sandbox with strict system call interception and network layer isolation for execution. To address issues such as data dimension mismatch (e.g., attempting to directly multiply a 256Hz EEG array with a 1Hz SpO2 array without resampling) or syntax errors (e.g., writing >= as a mathematical symbol) in the large model generation code, this invention incorporates a self-healing loop based on reinforcement feedback. If an exception is thrown during execution, the stack trace is captured and the reinforcement feedback loop is triggered, prompting the code agent to perform self-regressive correction. For example, if the sandbox execution returns a non-zero exit code or throws a Traceback exception, the exception text will not be fed back to the front-end doctor but will be captured and directly returned to the code agent as a system prompt. A predefined parameter for the maximum number of self-correction iterations (e.g., setting...) is used. The code agent automatically reflects on and modifies the previously generated code based on the error message, such as adding a layer of array truncation and alignment logic or resampling and frequency reduction logic, and resubmits it to the sandbox for execution after regeneration until it succeeds or reaches the limit.
[0047] Upon successful execution, the sandbox outputs the calculated scalar feature set and a high-resolution visualization chart. (e.g., a magnified view of the waveforms of each indicator), and stored in the SMB's Visual_Evidence_Assets pool.
[0048] In step S104, after completing multiple rounds of adversarial ward rounds and code execution in step S103, a large number of visualization charts of different categories may have been generated. However, if the number of charts is not controlled, as the "hypothesis-code execution-chart generation" cycle progresses, the unrestricted charts will quickly exhaust the context window of the large language model, causing the "lost in the middle" effect. To avoid the proliferation of charts and context window expansion caused by multiple rounds of adversarial ward rounds, step S104 performs a standardized score on the clinical relevance of each chart, and forcibly prunes low-scoring redundant nodes accordingly. The physician agent then selects the optimal chart set to minimize the dynamic information entropy of the multimodal context.
[0049] Specifically, this invention proposes a "sort-select-prune" attention-focusing algorithm. Whenever the sandbox outputs a new set of charts, bundled data containing the context of those charts is sent back to the physician agent. The physician agent is tasked with acting as a "medical editor," and must edit the set of charts output by the sandbox. Each visualization chart in the document is scored for in-depth clinical relevance.
[0050] Specifically, the system calls the multimodal large language model visual reasoning interface at the bottom layer of the physician's intelligent agent to transform the visualization chart to be evaluated into a sequence of visual features. This sequence, along with the current clinical query context and preset quantitative scoring criteria, is encapsulated into multimodal prompts. Further combined with a thought chain reasoning mechanism, the system ultimately outputs a quantitative score for the chart. Let the visualization chart be... The score is a one-dimensional function The scoring criteria are highly quantified. High correlation (8-10 points): Visual charts clearly reveal key pathological features (such as a typical obstructive apnea lasting up to 60 seconds accompanied by a cliff-like drop in blood oxygen, or a sleep structure diagram that reflects the structure throughout the night).
[0051] Moderate correlation (4-7 points): Provides auxiliary support, but the signal has high noise or redundancy.
[0052] Low correlation (1-3 points): a completely normal, smooth physiological waveform, or a graph that is severely unreadable due to missing data.
[0053] SMB maintains a maximum capacity of A priority chart queue is used. After each evaluation, the union of the current queue and the new charts is calculated, and pruning is performed. That is, a preset number of charts with the highest scores are selected as the optimal chart set, and charts with scores below a preset low score threshold are forcibly unloaded from the active context. The final optimal chart set selected and retained is represented as follows: ; in, This represents the total library score of all charts generated by the code agent in the room-checking game. This represents the candidate combination schemes selected from the main database. This means that the number of charts in the candidate combination must be strictly equal to 1. Useless charts rated 1-3 will be forcibly unloaded from the context. Only the selected top-level core charts will be kept in the shared memory buffer for subsequent use by the agent. This simulates the thinking habit of clinicians who prioritize decisive evidence, effectively suppressing distractions and alleviating the model's visual illusions.
[0054] In step S105, after completing the optimal chart set screening in step S104, step S105 performs evidence sufficiency determination and zero-sample clinical report synthesis.
[0055] Specifically, the physician agent integrates all currently available evidence, including: precise quantitative indicators (total sleep time, apnea-hypopnea index, oxygen depletion index) and personalized physiological warning boundaries calculated by the technician agent in step S102; diagnostic reasoning logs generated in the adversarial consultation cycle in step S103 (including initial diagnostic hypotheses, counterfactual questioning content, natural language instructions generated by the physician's response, and visual charts produced after code execution and their corresponding sandbox execution status); and the optimal set of charts retained after clinical relevance scoring in step S104. Based on preset sufficiency judgment rules, the physician agent outputs a Boolean-type evidence sufficiency flag. .
[0056] The sufficiency determination rules specifically include: Counterfactual questioning coverage: The system determines whether all counterfactual questions and exclusive differential diagnosis items (specifically including the possibility of central sleep apnea or Chernobyl respiration) raised by the consultant agent in each iteration have been logically rejected or data-supported by the physician agent, and whether there are any unresolved conflicting paths in the current diagnostic network. Visual-semantic convergence: The system determines whether the scores of the core pathological charts in the optimal chart set all reach the preset high relevance threshold (i.e., scores ≥ 8 points), and whether the waveform morphology represented by the charts does not conflict with the current text diagnostic conclusion in a directional manner. The computational pipeline is complete: the system determines that the most recent code agent had no operational anomalies in the sandbox, and that the calculated multimodal quantization metrics had no missing items.
[0057] like If the number of iterations has not exceeded the limit, the process will return to step S103 to begin a new round of "hypothesis-question-code execution" iterations. Conversely, if it is determined that the existing evidence has formed a closed loop ( If the preset safety limit for forced exit has been reached (e.g., a maximum of 3 iterations), the ward round cycle will then terminate.
[0058] At this point, the integrated agent is triggered. To prevent additional divergence during the summary phase, the integrated agent's operating mode is set to an absolute "zero-shot" synthesis mode, meaning no reference examples are provided in the prompts, forcing the model to rely directly on pre-training capabilities and strictly using the objective evidence retained in shared memory as the sole context boundary for generation. It reads the output data of the SMB, including: patient baseline characteristics and preprocessed physiological sequences from step S101; precise overnight quantitative indicators (such as total sleep time, apnea-hypopnea index, and oxygen depletion index) and personalized physiological warning boundaries calculated by the technician agent in step S102; key diagnostic reasoning logs and natural language instructions recorded in the adversarial consultation cycle in step S103; and the optimal set of charts retained after scoring and filtering by the physician agent in step S104.
[0059] By integrating the intelligent agent with the standardized sleep medicine report template, the above data is fused to generate a comprehensive diagnostic report. The report uses a mixed text and image format, directly embedding top-level charts into the analysis of corresponding abnormal events. For example, when describing "frequent chest and abdominal reverse movements during REM sleep," a multiphase respiratory waveform is simultaneously inserted as a visual anchor. The final report can be interfaced with hospital electronic medical records or image archiving systems via API, thus achieving a fully automated conversion from high-frequency sleep physiological signals to a structured specialist report.
[0060] In summary, this embodiment instantiates five agent components with specific functional boundaries through the underlying large language model interface, forming a multi-agent collaborative driving engine based on role constraints and adversarial reasoning. Optionally, the underlying large language model can be a GPT series model, a Claude series model, a Llama series model, or other autoregressive large language models with semantic understanding and code generation capabilities. Specifically, the technician agent deploys a dual-track computation graph: the main track calls a deterministic mathematical library to automatically stage sleep physiological signals and extract respiratory events, while the secondary track utilizes the large model's semantic reasoning module combined with past medical history to infer and map dynamic individual physiological early warning boundaries.
[0061] The physician agent simulates the cognitive logic of a sleep specialist, proposing initial diagnostic hypotheses and classifying the severity of sleep apnea based on observational data, and evaluating the convergence of the system's visual evidence chain after multiple rounds of interaction. The advisor agent deploys adversarial review logic, performing exclusive pathological tracing against the physician agent's initial hypotheses, and forcing the output of a data exploration task space targeting specific physiological variable coupling relationships (such as the cross-comparison of airflow and chest and abdominal movements).
[0062] The code agent deploys a code generation and self-correction model, parses exploration instructions and dynamically compiles data analysis scripts, and delivers them to a restricted isolation sandbox for execution, completing the dimensionality reduction of temporal features and the visualization rendering of high-dimensional space (such as sleep structure diagram generation). The integrated agent is configured in a zero-sample decoding state. After the inference chain is closed, it fuses high information gain data and chart assets retained in the shared memory buffer to synthesize a highly structured multimodal assisted diagnosis report.
[0063] The five intelligent agents mentioned above work closely together through a shared memory buffer to fully realize the automatic generation process from raw sleep physiological signals to highly reliable clinical reports.
[0064] Example 2 This embodiment provides a multimodal sleep physiological index time series report generation system, including: The data acquisition and preprocessing module is configured to: acquire multimodal sleep physiological sequence data and clinical text data, and write the physiological sequence data into a shared memory buffer after preprocessing it; The technician intelligent agent module is configured to: calculate quantitative indicators including the apnea-hypopnea index based on physiological sequence data, and generate physiological warning boundaries by combining clinical text data; The physician agent module is configured to: generate initial diagnostic hypotheses based on quantitative indicators; respond to counterfactual inquiries from the advisor agent module and generate natural language instructions; score the clinical relevance of visualization charts and select the optimal set of charts based on the scoring results. The advisory agent module is configured to: challenge the initial diagnostic assumptions with counterfactual statements; The code-based intelligent agent module is configured to: translate natural language instructions into code and execute them in a secure sandbox, outputting visual charts; The integrated intelligent agent module is configured to: when the evidence in the optimal chart set meets the preset conditions or the number of iterations reaches the preset limit, read the time series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and fuse the read data to generate a long-form diagnostic report.
[0065] It should be noted that each module in this embodiment corresponds one-to-one with each step in Embodiment 1, and their specific implementation process is the same, so it will not be repeated here.
[0066] Example 3 This embodiment also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Embodiment 1.
[0067] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating time series reports of multimodal sleep physiological indicators, characterized in that, include: Multimodal sleep physiological sequence data and clinical text data are acquired, and the physiological sequence data is preprocessed and written into a shared memory buffer. Based on the physiological sequence data, a technician's intelligent agent is used to calculate a quantitative index including the apnea-hypopnea index, and combined with the clinical text data to generate a physiological warning boundary. The physician agent generates initial diagnostic hypotheses based on the aforementioned quantitative indicators; The advisor agent challenges the initial diagnostic hypothesis with counterfactual statements, the physician agent responds to the counterfactual statements and generates natural language instructions, and the code agent converts the natural language instructions into code and executes them in a secure sandbox, outputting a visual chart. The physician agent scores the clinical relevance of the visualization charts and selects the optimal set of charts based on the scoring results. When the evidence in the optimal set of charts meets the preset conditions or the number of iterations reaches the preset limit, the integrated agent reads the time series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and merges the read data to generate a long-form diagnostic report.
2. The method according to claim 1, characterized in that, The technician agent, physician agent, consultant agent, code agent, and integrated agent interact using a star topology architecture. A central coordinator is deployed at the central node of this star topology architecture to centrally manage the global shared memory buffer, and concurrent control between agents is achieved through an event bus and read-write locks.
3. The method according to claim 1, characterized in that, The technician agent, physician agent, consultant agent, code agent, and comprehensive agent are all built based on a large language model; the technician agent also includes a mathematical calculation kernel for calculating quantitative indicators; the code agent also includes an abstract syntax tree analyzer for static code analysis and a sandbox for isolating and executing code.
4. The method according to claim 1, characterized in that, The physiological warning boundary is generated by combining the aforementioned clinical text data, specifically as follows: The technician's intelligent agent reads the patient's past medical history and medication records, and dynamically adjusts the alarm thresholds of physiological indicators based on specific pathological states in the past medical history. The dynamic adjustment includes: when the past medical history includes chronic obstructive pulmonary disease, adjusting the lower limit of the alarm baseline for blood oxygen saturation from an absolute threshold to a relative threshold based on the percentage decrease in the patient's awake baseline.
5. The method according to claim 1, characterized in that, The physician agent generates an initial diagnostic hypothesis based on the quantitative indicators; the advisor agent challenges the initial diagnostic hypothesis with counterfactual statements, and the physician agent responds to the counterfactual statements by generating natural language instructions. Specifically, the physician agent constructs a two-dimensional severity mapping function based on the apnea-hypopnea index and the lowest nocturnal oxygen saturation, and outputs an initial diagnostic hypothesis that includes a severity rating of sleep apnea; the advisor agent is injected with a counterfactual prompt protocol, which forces the physician agent to consider pathological possibilities that contradict the current diagnostic hypothesis; the physician agent generates natural language instructions based on the forced requirement.
6. The method according to claim 1, characterized in that, The code agent translates the natural language instructions into code and executes them in a secure sandbox, outputting a visual chart. Specifically, the code agent generates Python source code containing scientific computing library calls based on a large language model and parses the source code into an abstract syntax tree. Before execution, it statically traverses all nodes, prohibiting nodes containing network requests, operating system calls, and dynamic code execution. After passing the static check, the source code is submitted to the Docker sandbox for execution. If an exception is thrown during execution, the exception stack is captured and sent back to the code agent for self-correction. The code is regenerated until execution is successful or the maximum number of corrections is reached. After successful execution, the output visualization chart is stored in a shared memory buffer.
7. The method according to claim 1, characterized in that, The physician agent scores the clinical relevance of the visualization charts and selects the optimal chart set based on the scoring results. Specifically, the physician agent scores each visualization chart in a grade, where high-grade charts reflect key pathological features and low-grade charts are considered redundant. A preset number of charts with the highest scores are selected from all charts as the optimal chart set, and charts with scores below a preset low score threshold are unloaded from the active context.
8. The method according to claim 1, characterized in that, The integrated intelligent agent reads time-series data, natural language instructions, initial diagnostic hypotheses, and visualization charts from the shared memory buffer, and integrates the read data to generate a long-text diagnostic report. Specifically, the integrated intelligent agent reads the patient background, quantitative indicators, physiological warning boundaries, diagnostic reasoning logs, and optimal chart set from the shared memory buffer; according to the sleep medicine report template, the charts are embedded into the corresponding abnormal event descriptions in an inline text and image mixed format to generate a long-text diagnostic report.
9. A multimodal sleep physiological index time series report generation system, characterized in that, include: The data acquisition and preprocessing module is configured to: acquire multimodal sleep physiological sequence data and clinical text data, and write the physiological sequence data into a shared memory buffer after preprocessing it; The technician intelligent agent module is configured to: calculate a quantitative index including the apnea-hypopnea index based on the physiological sequence data, and generate a physiological warning boundary in combination with the clinical text data; The physician intelligent agent module is configured to: generate initial diagnostic hypotheses based on the quantitative indicators; respond to counterfactual inquiries from the advisor intelligent agent module and generate natural language instructions; score the clinical relevance of the visualization charts and select the optimal chart set based on the scoring results; The advisory agent module is configured to: challenge the initial diagnostic hypothesis with counterfactual statements; The code-based intelligent agent module is configured to: convert the natural language instructions into code and execute them in a secure sandbox, outputting visual charts; The integrated intelligent agent module is configured to: when the evidence in the optimal chart set reaches a preset condition or the number of iterations reaches a preset upper limit, read the time series data, natural language instructions, initial diagnostic hypotheses, and visualization charts in the shared memory buffer, and fuse the read data to generate a long-form diagnostic report.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the method for generating a multimodal sleep physiological index time series report as described in any one of claims 1-8.