Self-adaptive time synchronization method, device and equipment for wireless brain-computer interface system

By filtering and verifying time datasets in a wireless brain-computer interface system, and using linear prediction functions and trigonometric inequalities for adaptive time synchronization, the problem of insufficient synchronization accuracy and stability in traditional methods is solved, achieving high-precision and high-reliability time synchronization.

CN122052959APending Publication Date: 2026-05-15BEIJING INST FOR BRAIN DISORDERS
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING INST FOR BRAIN DISORDERS
Filing Date
2026-02-24
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

In wireless brain-computer interface systems, due to factors such as hardware crystal oscillator errors and temperature drift, the frequency difference between clocks makes it difficult for traditional time synchronization methods to achieve high-precision synchronization at the microsecond level in complex wireless network environments. Furthermore, the computational overhead and communication burden are high, and they cannot effectively resist network jitter and clock drift.

Method used

By sending a time synchronization request command to the second device, recording the round-trip time, filtering the basic time dataset, using a rolling window and linear prediction function for data filtering and verification, and constructing a triangle inequality for time synchronization, adaptive correction and accuracy assessment are achieved.

Benefits of technology

It significantly improves the accuracy and stability of time synchronization, effectively resists network jitter and clock drift, ensures the logical correctness of synchronization results, and provides a highly reliable time synchronization solution for distributed systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122052959A_ABST
    Figure CN122052959A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a self-adaptive time synchronization method, device and equipment for a wireless brain-computer interface system, and the method takes linear clock drift, symmetric network time delay and time delay stability as assumptions, and comprises the steps: transmitting a time synchronization request instruction to second equipment, calculating round-trip time consumption, and screening based on a preset time consumption threshold range to obtain a basic time data set; calculating a window mean value and a global mean value through a rolling window, and setting a time-consuming threshold condition for secondary screening to obtain an effective time data set; a linear prediction function is input after reference moment correction, and slope and intercept parameters are updated through a least square method; the updated linear prediction function is used for calculating a second equipment time prediction value, the precision of the time prediction value is evaluated in combination with a confidence interval, a triangular inequality is constructed for verification, time synchronization is completed, network jitter and clock drift are effectively resisted, precision and stability are improved, and a reliable self-adaptive synchronization scheme is provided for a distributed system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of time synchronization technology, and in particular to an adaptive time synchronization method, apparatus and device for wireless brain-computer interface systems. Background Technology

[0002] Wireless brain-computer interface (BCI) systems are an important research area in neural engineering, with their core function being the acquisition, transmission, and processing of neural signals via wireless communication. In a typical wireless BCI system, the signal acquisition module at the implanted or wearable end interacts with the external signal processing unit via a wireless link, with each having its own independent local clock. Due to factors such as hardware crystal oscillator errors and temperature drift, a frequency difference and a fixed offset inevitably exist between the two clocks, resulting in an inconsistency in their time bases.

[0003] For a system to function properly, precise timing matching between EEG signals and stimulus events is essential. For example, in closed-loop neuromodulation, the timing accuracy between signal acquisition and stimulus triggering directly affects the therapeutic effect. Therefore, achieving high-precision time synchronization among multiple devices is a critical prerequisite for the normal operation of a wireless brain-computer interface system.

[0004] However, communication between wireless devices inevitably introduces network transmission latency, which fluctuates due to factors such as channel conditions and protocol stack processing. Traditional time synchronization methods, such as Network Time Protocol (NTP) and Precision Time Protocol (PTP), are limited by network jitter, asymmetric latency, and clock drift in complex wireless network environments, making it difficult to achieve microsecond-level synchronization accuracy. Especially in resource-constrained implantable or wearable devices, the computational overhead and communication burden of traditional methods are unbearable, and they lack effective adaptive handling capabilities for abnormal latency and packet loss, leading to the accumulation of synchronization errors over time and a decrease in system stability.

[0005] Therefore, there is an urgent need for a lightweight time synchronization technology that can effectively resist network jitter, adaptively correct clock drift, and verify the rationality of synchronization results, in order to meet the high-precision and high-reliability time synchronization requirements of wireless brain-computer interface systems. Summary of the Invention

[0006] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides an adaptive time synchronization method, apparatus, and device for wireless brain-computer interface systems.

[0007] This disclosure provides an adaptive time synchronization method for a wireless brain-computer interface system, the method comprising: Send a time synchronization request command to the second device, record the sending time, receive the reply signal with the second device's timestamp and record the receiving time, calculate the round-trip time based on the sending and receiving times, filter the original time dataset based on the round-trip time and a preset time threshold range, and obtain the basic time dataset. Based on the base time dataset, a scrolling window is determined. In response to the total number of valid window requests for the scrolling window, the window mean and global mean of the scrolling window are calculated. Based on the window mean and global mean, the base time dataset is filtered to obtain a valid time dataset. The effective time dataset is translated by selecting a reference time. The translated effective time dataset is then input into a preset linear prediction function. The slope parameter and intercept parameter of the linear prediction function are calculated and updated using the least squares method to obtain the updated linear prediction function. The updated linear prediction function is used to calculate the second device time prediction value corresponding to the current local time. The accuracy of the time prediction value is evaluated based on the confidence interval. A triangle inequality is constructed based on necessary conditions to verify the time prediction value. Time synchronization is completed based on the verification result.

[0008] The method provided in this disclosure sends a time synchronization request command to a second device, records the sending time, receives a reply signal with a timestamp from the second device and records the receiving time, calculates the round-trip time based on the sending and receiving times, and filters the original time dataset based on the round-trip time and a preset time threshold range to obtain a basic time dataset, including: The first device sends a time synchronization request command to the second device and records the time at which the time synchronization request command is sent. Receive a response signal with the second device's timestamp returned by the second device in response to the time synchronization request command, and record the time at which the response signal was received; The round-trip time of the time synchronization request instruction is calculated based on the difference between the receiving time and the sending time. If the time taken for a single round trip does not fall within the preset time threshold range, the corresponding original time data is discarded. If the time taken for a single round trip falls within the preset time threshold range, the corresponding original time data is retained, and all retained original time data are combined to obtain the basic time dataset.

[0009] The method provided in this disclosure, which determines a scrolling window based on the base time dataset, calculates the window mean and global mean of the scrolling window in response to the total number of valid window requests for the scrolling window, and filters the base time dataset to obtain a valid time dataset based on the window mean and global mean, includes: Obtain the time synchronization accuracy requirement, and determine the rolling window by combining the time synchronization accuracy requirement with the basic time dataset; Based on each piece of data included in the basic time dataset, update the total window round-trip time, the total number of valid window requests, the total global round-trip time, and the total number of valid global requests. When the total number of requests within the current scrolling window reaches the window size, the window average is calculated based on the total round-trip time of the window and the total number of valid requests in the window, and the global average is calculated based on the total global round-trip time and the total number of valid global requests. The time consumption threshold is determined based on the window mean and the global mean. The basic time dataset is then filtered based on the time consumption threshold to obtain the effective time dataset.

[0010] The method provided in this disclosure involves selecting a reference time to perform coordinate translation on the effective time dataset, inputting the translated effective time dataset into a preset linear prediction function, calculating and updating the slope and intercept parameters of the linear prediction function using the least squares method, and obtaining the updated linear prediction function, including: Select the sending time of the first time data in the basic time dataset and the timestamp of the second device, and add a preset offset to each to determine the first reference time of the first device and the second reference time of the second device; Input the effective time dataset into a preset linear prediction function; For each group of data in the effective time dataset, fit the first reference time with the second reference time; Based on the fitting results, the cumulative values ​​of the first device and the second device are calculated, and the new relevant parameters of the linear prediction function are calculated using the cumulative values ​​of the first device and the second device. The linear prediction function is updated based on the new relevant parameters, which include slope and intercept parameters.

[0011] The method provided in this disclosure includes: calculating a second device time prediction value corresponding to the current local time using the updated linear prediction function; evaluating the accuracy of the time prediction value based on a confidence interval; verifying the time prediction value by constructing a triangle inequality based on necessary conditions; and completing time synchronization based on the verification result. The necessary conditions are obtained to construct a triangle inequality. The theoretical boundary of the one-way transmission time is determined based on the sending and receiving time of the last time synchronization request instruction and the round-trip time. Based on the theoretical boundary, a preset fault tolerance constant is introduced to determine the upper and lower limit constraints of the triangle inequality. Using the updated linear prediction function, the predicted time value of the second device is calculated based on the current time data of the first device; The offset of the current local time is calculated based on the effective dataset, and a confidence interval is set according to the offset. The accuracy of the time prediction value is evaluated based on the confidence interval. The sending time of the last time synchronization request command, the second device timestamp, and the receiving time are benchmarked to obtain the theoretical upper bound and the theoretical lower bound. Based on the theoretical upper bound and the theoretical lower bound, a preset fault tolerance constant is introduced to construct upper and lower bound constraints. If the time prediction value of the second device meets the upper and lower limit constraints, then the confidence interval of the time prediction value of the second device is evaluated. If the evaluation result of the confidence interval is credible, the time prediction value of the second device is output, and the current time data is synchronized according to the time prediction value of the second device. If the upper and lower limit constraints are not met, the triangle inequality will not hold, and an error will occur in the timing synchronization.

[0012] The method provided in this disclosure includes: The formulas corresponding to the theoretical upper and lower bounds are:

[0013] Where lower_bound represents the theoretical lower bound; upper_bound represents the theoretical upper bound; Indicates the time of transmission; Indicates the time of reception; Indicates the second reference time; Indicates the timestamp of the second device; Indicates the first reference time; The formulas for calculating the upper and lower limit constraints are:

[0014] in, is the fault tolerance constant; L represents the lower limit of the theoretical time prediction value; U represents the upper limit of the theoretical time prediction value; This indicates the current time data of the first device.

[0015] This disclosure provides an adaptive time synchronization device for a wireless brain-computer interface system, the device comprising: The preliminary screening module is used to send a time synchronization request command to the second device, record the sending time, receive the reply signal with the second device's timestamp and record the receiving time, calculate the round-trip time based on the sending time and receiving time, and filter the original time dataset based on the round-trip time and a preset time threshold range to obtain the basic time dataset. The scrolling window filtering module is used to determine the scrolling window based on the basic time dataset, and in response to the total number of valid window requests of the scrolling window, calculate the window mean and global mean of the scrolling window, and filter the basic time dataset based on the window mean and global mean to obtain a valid time dataset. The prediction function update module is used to select a reference time to perform coordinate translation on the effective time dataset, input the translated effective time dataset into a preset linear prediction function, calculate and update the slope parameter and intercept parameter of the linear prediction function using the least squares method, and obtain the updated linear prediction function. The time synchronization module is used to calculate the second device time prediction value corresponding to the current local time using the updated linear prediction function, evaluate the accuracy of the time prediction value based on the confidence interval, verify the time prediction value by constructing a triangle inequality based on necessary conditions, and complete the time synchronization according to the verification result.

[0016] The apparatus provided in this disclosure, wherein the preliminary screening module is specifically used for: The first device sends a time synchronization request command to the second device and records the time at which the time synchronization request command is sent. Receive a response signal with the second device's timestamp returned by the second device in response to the time synchronization request command, and record the time at which the response signal was received; The round-trip time of the time synchronization request instruction is calculated based on the difference between the receiving time and the sending time. If the time taken for a single round trip is not within the preset time threshold range, the corresponding original time data is discarded; if the time taken for a single round trip is within the preset time threshold range, the corresponding original time data is retained, and all retained original time data are combined to obtain the basic time dataset.

[0017] The apparatus provided in this disclosure, wherein the scrolling window filtering module is specifically used for: Obtain the time synchronization accuracy requirement, and determine the rolling window by combining the time synchronization accuracy requirement with the basic time dataset; Based on each piece of data included in the basic time dataset, update the total window round-trip time, the total number of valid window requests, the total global round-trip time, and the total number of valid global requests. When the total number of requests within the current scrolling window reaches the window size, the window average is calculated based on the total round-trip time of the window and the total number of valid requests in the window, and the global average is calculated based on the total global round-trip time and the total number of valid global requests. The time consumption threshold is determined based on the window mean and the global mean. The basic time dataset is then filtered based on the time consumption threshold to obtain the effective time dataset.

[0018] The apparatus provided in this disclosure, wherein the prediction function update module is specifically used for: Select the sending time of the first time data in the basic time dataset and the timestamp of the second device, and add a preset offset to each to determine the first reference time of the first device and the second reference time of the second device; Input the effective time dataset into a preset linear prediction function; For each group of data in the effective time dataset, fit the first reference time with the second reference time; Based on the fitting results, the cumulative values ​​of the first device and the second device are calculated, and the new relevant parameters of the linear prediction function are calculated using the cumulative values ​​of the first device and the second device. The linear prediction function is updated based on the new relevant parameters, which include slope and intercept parameters.

[0019] The device provided in this disclosure, wherein the time synchronization module is specifically used for: The necessary conditions are obtained to construct a triangle inequality. The theoretical boundary of the one-way transmission time is determined based on the sending and receiving time of the last time synchronization request instruction and the round-trip time. Based on the theoretical boundary, a preset fault tolerance constant is introduced to determine the upper and lower limit constraints of the triangle inequality. Using the updated linear prediction function, the predicted time value of the second device is calculated based on the current time data of the first device; The offset of the current local time is calculated based on the effective dataset, and a confidence interval is set according to the offset. The accuracy of the time prediction value is evaluated based on the confidence interval. The sending time of the last time synchronization request command, the second device timestamp, and the receiving time are benchmarked to obtain the theoretical upper bound and the theoretical lower bound. Based on the theoretical upper bound and the theoretical lower bound, a preset fault tolerance constant is introduced to construct upper and lower bound constraints. If the time prediction value of the second device meets the upper and lower limit constraints, then the confidence interval of the time prediction value of the second device is evaluated. If the evaluation result of the confidence interval is credible, the time prediction value of the second device is output, and the current time data is synchronized according to the time prediction value of the second device. If the upper and lower limit constraints are not met, the triangle inequality will not hold, and an error will occur in the timing synchronization.

[0020] The apparatus provided in this disclosure includes: The formulas corresponding to the theoretical upper and lower bounds are:

[0021] Where lower_bound represents the theoretical lower bound; upper_bound represents the theoretical upper bound; Indicates the time of transmission; Indicates the time of reception; Indicates the second reference time; Indicates the timestamp of the second device; Indicates the first reference time; The formulas for calculating the upper and lower limit constraints are:

[0022] in, is the fault tolerance constant; L represents the lower limit of the theoretical time prediction value; U represents the upper limit of the theoretical time prediction value; This indicates the current time data of the first device.

[0023] This disclosure also provides an electronic device, the electronic device comprising: a processor; a memory for storing executable instructions of the processor; the processor being configured to read the executable instructions from the memory and execute the instructions to implement the time synchronization technology method provided in this disclosure.

[0024] The technical solution provided in this disclosure has the following advantages compared with the prior art: The time synchronization method provided in this disclosure involves sending instructions to a second device to calculate round-trip time, filtering the original data using a time threshold to obtain a base time dataset, determining a rolling window based on the base time dataset, calculating the window mean and global mean based on the number of valid requests, and filtering out the effective time dataset. The effective time data is then input into a linear prediction function to update its parameters. Time synchronization is completed based on the triangle inequality and the updated linear prediction function. This effectively resists network jitter and clock drift, significantly improving time synchronization accuracy and long-term stability. Combined with physical verification using the triangle inequality, the logical correctness of the synchronization result is ensured, providing a highly reliable and adaptive software-level synchronization solution for distributed systems. Attached Figure Description

[0025] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0026] Figure 1 A flowchart illustrating the time synchronization technique method provided in the embodiments of this disclosure; Figure 2A wearable brain-computer interface application diagram of an adaptive time synchronization device for a wireless brain-computer interface system provided in an embodiment of this disclosure; Figure 3 This disclosure provides a user-centric multi-agent collaborative brain-computer interface system according to embodiments of the present disclosure. Figure 4 A wireless interventional brain-computer interface application diagram for an adaptive time synchronization device for a wireless brain-computer interface system provided in an embodiment of this disclosure; Figure 5 A schematic diagram of the structure of an adaptive time synchronization device for a wireless brain-computer interface system provided in an embodiment of this disclosure; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0027] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0028] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0029] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0030] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0031] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0032] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0033] To address the aforementioned problems, this disclosure provides a time synchronization technique, which will be described below with reference to specific embodiments.

[0034] Figure 1 This is a flowchart illustrating an adaptive time synchronization method for a wireless brain-computer interface system provided in an embodiment of the present disclosure. The method can be executed by an adaptive time synchronization device for a wireless brain-computer interface system, wherein the device can be implemented in software and / or hardware, and is generally integrated into an electronic device.

[0035] Example 1: An adaptive time synchronization method for wireless brain-computer interface systems provided in this embodiment includes: S101: Send a time synchronization request command to the second device, record the sending time, receive the reply signal with the second device's timestamp returned by the second device and record the receiving time, calculate the round-trip time based on the sending time and receiving time, filter the original time dataset based on the round-trip time and a preset time threshold range, and obtain the basic time dataset. S102: Determine the scrolling window based on the basic time dataset; in response to the total number of valid window requests for the scrolling window, calculate the window mean and global mean of the scrolling window; and filter the basic time dataset based on the window mean and global mean to obtain a valid time dataset. S103: Select a reference time and perform coordinate translation on the effective time dataset. Input the translated effective time dataset into a preset linear prediction function. Calculate and update the slope parameter and intercept parameter of the linear prediction function using the least squares method to obtain the updated linear prediction function. S104: Calculate the second device time prediction value corresponding to the current local time using the updated linear prediction function, evaluate the accuracy of the time prediction value based on the confidence interval, and verify the time prediction value by constructing a triangle inequality based on necessary conditions, and complete time synchronization based on the verification result.

[0036] This embodiment is based on the following three fundamental assumptions: Assumption 1: Linear clock drift. Within a short time period, the time of the second device is approximately linearly related to the time of the first device, i.e. Where k reflects the clock frequency difference caused by hardware crystal oscillator errors, temperature drift, etc., k ≈ 1 indicates that the frequencies are almost identical; b is a fixed offset. Assumption 2: Symmetric network delay. In a single time synchronization interaction, the uplink delay of the first device sending the time synchronization request. With downlink latency If they are approximately equal, then the round trip time is... Where p is the processing time of the second device, which is extremely small relative to the uplink and downlink latency and can be approximated as negligible. Assumption 3: Network latency is stable. Under the condition of maintaining the connection unchanged, the network latency of the wireless brain-computer interface system is basically stable within a certain period of time. That is, the network latency when time synchronization needs are generated at different times is approximately the same.

[0037] In this embodiment, the second device refers to a device that serves as a time reference source, typically possessing a more accurate or stable clock. In the synchronization architecture, it responds to time synchronization requests from the first device (client) and provides its own timestamp as a reference. Its role is similar to a server or master clock node in a traditional client / server model. For example, the first device could be a multi-channel neural signal acquisition module implanted under the patient's skin in a wireless brain-computer interface, responsible for wirelessly transmitting EEG data. The second device could be an external processing unit worn by the patient in the wireless brain-computer interface, responsible for analyzing EEG signals in real time and determining whether to trigger electrical stimulation to suppress epilepsy.

[0038] In this embodiment, the time request instruction is a network signaling or data packet initiated by the first device, the core purpose of which is to request the current timestamp from the second device. This instruction is typically designed to be lightweight to minimize network load and processing latency. For example, the multi-channel neural signal acquisition module (first device) sends a short data packet to the processing unit (second device) via body area network, meaning "Please tell me the current time".

[0039] In this embodiment, the round-trip time (RTT) is the total time taken for a complete time synchronization interaction, calculated using the following formula: RTT represents the round-trip time. It includes network transmission latency (uplink and downlink) and secondary device processing latency.

[0040] In this embodiment, the effective time data is input into the linear prediction function, the reference time is fitted and the cumulative amount of the two devices is calculated, and the new slope and intercept parameters of the linear prediction function are calculated using the cumulative amount, thereby updating the linear prediction function.

[0041] In this embodiment, the time-consuming threshold range is a preset reasonable delay interval, such as [0, RTT_max]. This is used to quickly determine whether a single measurement is unavailable due to severe network congestion, packet loss and retransmission, or system anomalies. Measurements outside this range are considered invalid.

[0042] In this embodiment, the effective time dataset is a subset of the basic time dataset that meets the time consumption threshold condition.

[0043] In this embodiment, the linear prediction function is a mathematical model that describes the mapping relationship between the time of the first device and the time of the second device.

[0044] In this embodiment, the raw time dataset is a set of unprocessed data directly collected from multiple time synchronization interactions during the initial stage of the synchronization process. Each piece of raw time data is a triple: (sending time, second device timestamp, receiving time).

[0045] In this embodiment, the basic time dataset is the result of preliminary filtering of the original time dataset. The filtering criterion is that the round-trip time corresponding to each data point must be within a preset time threshold. This dataset retains measurement data with reasonable timing logic and normal network latency, serving as input for subsequent fine-tuning.

[0046] In this embodiment, the necessary condition refers to the physical constraint that the server processing time is non-negative. That is, the server cannot send a reply before receiving the request, and the reply must be received by the client after it has been received.

[0047] In this embodiment, upper and lower limit constraints and confidence intervals are constructed based on necessary conditions. The updated linear prediction function is used to calculate the time prediction value corresponding to the current local experiment. The upper and lower limit constraints are first used for logical verification, and the confidence interval is used to evaluate the accuracy. After both are qualified, the result is output and used for synchronization.

[0048] In this embodiment, such as Figure 2 As shown, this includes fields such as brain-computer interfaces, virtual reality, cognitive neuroscience experiments, and rehabilitation medicine. Through dynamic round-trip time calibration, rolling window data filtering, and adaptive prediction models, precise time synchronization between visual, auditory, and tactile stimulation signals and EEG signals is achieved, improving the system's real-time performance, anti-interference capabilities, and user experience in wearable environments, and supporting long-term stable operation.

[0049] In this embodiment, such as Figure 3 As shown, time alignment among multiple agents is achieved through data interaction and clock time delivery. This technology is applicable to distributed brain-computer interfaces, multi-agent collaborative decision-making, and group neural signal synchronization analysis, providing a unified time reference for the system, ensuring data consistency, and supporting real-time interaction.

[0050] In this embodiment, such as Figure 4 As shown, the device acquires neural signals via a vascular interventional stent electrode at the front end, and performs signal processing and intelligent analysis at the back end. This device ensures time synchronization between front-end acquisition and back-end processing, providing a precise time reference for neural signal decoding and real-time feedback, and is suitable for implantable medical devices and closed-loop neural modulation scenarios.

[0051] The working principle and beneficial effects of this embodiment are as follows: By sending a time synchronization request to the second device, the sending and receiving times are recorded to calculate the round-trip time. A basic dataset is obtained by filtering the original data according to a preset time threshold. A rolling window is set based on the basic dataset, and the window mean and global mean are calculated. This is used to further filter out the effective time dataset. After selecting a reference time and performing coordinate translation, a linear prediction function is fitted using the least squares method. The linear prediction function is then updated, and the updated linear prediction function is used to calculate the predicted time value of the second device corresponding to the current local time. Its accuracy is evaluated using confidence intervals and verified using the triangle inequality, thereby achieving high-precision and high-reliability time synchronization. Invalid measurement data with network anomalies or excessive latency is automatically removed, improving the quality of the basic dataset and providing clean and reliable input for subsequent time synchronization calculations, thus enhancing the stability and anti-interference capability of the synchronization algorithm.

[0052] Example 2: The method provided in this embodiment of the present disclosure sends a time synchronization request command to a second device, records the sending time, receives a reply signal with the second device's timestamp returned by the second device and records the receiving time, calculates the round-trip time based on the sending and receiving times, and filters the original time dataset based on the round-trip time and a preset time threshold range to obtain a basic time dataset, including: The first device sends a time synchronization request command to the second device and records the time at which the time synchronization request command is sent. Receive a response signal with the second device's timestamp returned by the second device in response to the time synchronization request command, and record the time at which the response signal was received; The round-trip time of the time synchronization request instruction is calculated based on the difference between the receiving time and the sending time. If the time taken for a single round trip does not fall within the preset time threshold range, the corresponding original time data is discarded. If the time taken for a single round trip falls within the preset time threshold range, the corresponding original time data is retained, and all retained original time data are combined to obtain the basic time dataset.

[0053] In this embodiment, the sending time is the instantaneous moment recorded by the first device under its local clock when the time synchronization request command is successfully sent from the local device. This is the starting point of the entire round-trip time measurement, and its accuracy directly affects the accuracy of the synchronization calculation. For example, the multi-channel neural signal acquisition module (the first device) sends this request packet when its own clock reading (which may drift due to body temperature and power consumption) is 152,000,000 µs.

[0054] In this embodiment, the second device timestamp is a data field embedded in the second device's reply signal. Its value is the local clock value read by the second device at the moment it prepares to send a reply. It is a direct and unique observation of the second device's time obtained by the first device. For example, the processing unit (second device) receives a request, prepares to reply when its own highly stable clock (such as a GPS-disciplined crystal oscillator) reading is 1,002,500,150 µs, and fills this value into the reply packet.

[0055] In this embodiment, the response signal is a response data packet that the second device returns to the first device immediately (or after a very short processing delay) after receiving the time synchronization request instruction. The core payload of this signal is the second device's timestamp.

[0056] In this embodiment, the reception time is the instant recorded by the first device at its local clock when it successfully receives the reply signal from the second device. This is the end point for the round-trip time measurement.

[0057] The working principle and beneficial effects of this embodiment are as follows: The round-trip time is calculated by measuring the time difference between the sending and receiving times. This round-trip time is then compared with a preset threshold range to filter the original time data, retaining only the data that falls within the range to form a basic time dataset. Invalid measurement data with network anomalies or excessive latency is automatically removed, improving the quality of the basic dataset and providing clean and reliable input for subsequent time synchronization calculations, thus enhancing the stability and anti-interference capability of the synchronization algorithm.

[0058] Example 3: The method provided in this embodiment of the present disclosure determines a scrolling window based on the basic time dataset, calculates the window mean and global mean of the scrolling window in response to the total number of valid window requests for the scrolling window, and filters the basic time dataset based on the window mean and global mean to obtain a valid time dataset, including: Obtain the time synchronization accuracy requirement, and determine the rolling window by combining the time synchronization accuracy requirement with the basic time dataset; Based on each piece of data included in the basic time dataset, update the total window round-trip time, the total number of valid window requests, the total global round-trip time, and the total number of valid global requests. When the total number of requests within the current scrolling window reaches the window size, the window average is calculated based on the total round-trip time of the window and the total number of valid requests in the window, and the global average is calculated based on the total global round-trip time and the total number of valid global requests. The time consumption threshold is determined based on the window mean and the global mean. The basic time dataset is then filtered based on the time consumption threshold to obtain the effective time dataset.

[0059] In this embodiment, the time synchronization accuracy requirement refers to the maximum allowable error for clock alignment between the first and second devices under a specific application scenario. It directly determines the algorithm's design parameters, such as sampling frequency and tolerance latency. In wireless brain-computer interfaces, this requirement is often sub-millisecond level to ensure accurate time stamping of neural events.

[0060] In this embodiment, the rolling window performs a calculation once it is full (reaching a preset number of valid requests), then clears and receives the next batch of new data. The window size is determined by the synchronization accuracy requirement and the time synchronization request frequency. For example, when the wireless brain-computer interface needs to achieve 100 µs accuracy, it needs to quickly track latency changes. The time synchronization request frequency is set to 50 times / second, and the window duration is set to 1 second to smooth out the instantaneous effects of a single heartbeat or movement. Therefore, the rolling window size N = 50 (data entries). The specific workflow of the rolling window is as follows: When the request queue of the first device is empty, a time synchronization request is automatically sent. For each data entry that passes the initial screening (normal RTT), the following operations are performed: the sending time, the second device timestamp, and the receiving time of the data entry are recorded in the buffer. The total window time is updated, the total number of valid window requests is updated, the total global RTT is updated, and the total number of valid global requests is updated.

[0061] In this embodiment, the total window time is the cumulative value of the single round-trip time corresponding to all basic time data within the current scrolling window, and the corresponding calculation formula is as follows: Where tmp_total represents the total time elapsed in the current window; tmp1_total represents the total time elapsed in the historical windows; the total number of valid window requests is the number of entries of the base time data successfully included in the calculation within the current scrolling window, and the corresponding calculation formula is: Where tmp_cnt represents the total number of valid requests in the current window; tmp1_cnt represents the total number of valid requests in the historical windows; the formula for the window mean is... Where temp_average represents the window mean.

[0062] In this embodiment, the global total time is the historical cumulative value of the round-trip time of all single trips that have entered the basic time dataset since the system started or was reset. The corresponding calculation formula is: , where rtt_total The current global time consumption is represented by `rtt1_total`; the historical global time consumption is represented by `rtt1_total`; the total number of global valid requests is the total number of entries that have entered the basic time dataset since the system started or was reset, and the corresponding calculation formula is... Where total_cnt represents the current total number of valid global requests; total1_cnt represents the total number of valid global requests in the past. The global mean is calculated using the following formula: , where total_average represents the global average.

[0063] In this embodiment, the window mean is calculated by dividing the total window latency by the total number of valid window requests. It reflects the average network round-trip latency over the short time period covered by the currently scrolling window. It is sensitive to transient network jitter.

[0064] In this embodiment, the global mean is calculated by dividing the total global latency by the total number of valid global requests. It reflects the historical average level and stable baseline of network round-trip latency over a long period since the system began operating.

[0065] In this embodiment, the time consumption threshold is a dynamic, statistically based filtering criterion. The corresponding specific inequality is: ,in, This is a set ratio; the purpose is to eliminate jitter spikes and enhance the robustness and long-term stability of the time synchronization algorithm.

[0066] The working principle and beneficial effects of this embodiment are as follows: a rolling window is set according to the synchronization accuracy, the round-trip time data between the window and the global data are accumulated and their respective averages are calculated, and a time threshold is set by combining the window average and the global average. Based on this, the basic time data is filtered a second time to generate an effective time dataset. By performing a second filtering through the time threshold condition, abnormal data caused by instantaneous network jitter can be effectively identified and removed, and a high-quality dataset reflecting stable latency characteristics can be obtained, thereby improving the accuracy and robustness of subsequent model fitting.

[0067] Example 4: The method provided in this embodiment selects a reference time to perform coordinate translation on the effective time dataset, inputs the translated effective time dataset into a preset linear prediction function, calculates and updates the slope and intercept parameters of the linear prediction function using the least squares method, and obtains the updated linear prediction function, including: Select the sending time of the first time data in the basic time dataset and the timestamp of the second device, and add a preset offset to each to determine the first reference time of the first device and the second reference time of the second device; Input the effective time dataset into a preset linear prediction function; For each group of data in the effective time dataset, fit the first reference time with the second reference time; Based on the fitting results, the cumulative values ​​of the first device and the second device are calculated, and the new relevant parameters of the linear prediction function are calculated using the cumulative values ​​of the first device and the second device. The linear prediction function is updated based on the new relevant parameters, which include slope and intercept parameters.

[0068] In this embodiment, the linear prediction function is a mathematical model describing the mapping relationship between the first device time and the second device time, and is typically a linear function. Where x represents the current time of the first device, ; y represents the current time of the second device, k represents the slope parameter; b represents the intercept parameter. This function is the core of time synchronization. Its slope k compensates for the relative frequency difference, and its intercept b compensates for the initial phase difference.

[0069] In this embodiment, the baseline time fitting is the process of selecting representative time points from the effective dataset as the common origin for coordinate system translation and converting all absolute timestamps into relative time values.

[0070] In this embodiment, the formula for calculating the cumulative amount is: ; ; ; ;in, This represents the relative time of the first device in the i-th set of valid time data; This represents the relative time of the second device in the i-th set of valid time data; This represents all instances of the algorithm starting from the beginning of its execution. The sum of This represents all instances of the algorithm starting from the beginning of its execution. sum; This represents all instances of the algorithm starting from the beginning of its execution. The sum of squares, This represents all instances of the algorithm starting from the beginning of its execution. and The sum of the products of .

[0071] In this embodiment, the calculation formula for the relevant parameters is as follows: Where cnt represents the total number of valid time data points in the valid time dataset. Only when... Fitting is performed only when the sample size is too small to avoid incorrect fitting. k reflects the clock frequency difference caused by hardware crystal oscillator errors, temperature drift, etc. This indicates that the frequencies are almost identical, and b is a fixed offset (where N is a set threshold).

[0072] The working principle and beneficial effects of this embodiment are as follows: the effective time data is input into the linear prediction function, the reference time is fitted and the cumulative amount of the two devices is calculated, the cumulative amount is used to calculate the new slope and intercept parameters of the linear prediction function, and the linear prediction function is updated accordingly. The function parameters are dynamically updated through data-driven methods, and the clock frequency deviation and initial offset between the first device and the second device are continuously calibrated to achieve long-term stable high-precision time synchronization.

[0073] Example 5: The method provided in this embodiment of the present disclosure calculates the second device time prediction value corresponding to the current local time using the updated linear prediction function, evaluates the accuracy of the time prediction value based on a confidence interval, verifies the time prediction value by constructing a triangle inequality based on necessary conditions, and completes time synchronization based on the verification result, including: The necessary conditions are obtained to construct a triangle inequality. The theoretical boundary of the one-way transmission time is determined based on the sending and receiving time of the last time synchronization request instruction and the round-trip time. Based on the theoretical boundary, a preset fault tolerance constant is introduced to determine the upper and lower limit constraints of the triangle inequality. Using the updated linear prediction function, the predicted time value of the second device is calculated based on the current time data of the first device; The offset of the current local time is calculated based on the effective dataset, and a confidence interval is set according to the offset. The accuracy of the time prediction value is evaluated based on the confidence interval. The sending time of the last time synchronization request command, the second device timestamp, and the receiving time are benchmarked to obtain the theoretical upper bound and the theoretical lower bound. Based on the theoretical upper bound and the theoretical lower bound, a preset fault tolerance constant is introduced to construct upper and lower bound constraints. If the time prediction value of the second device meets the upper and lower limit constraints, then the confidence interval of the time prediction value of the second device is evaluated. If the evaluation result of the confidence interval is credible, the time prediction value of the second device is output, and the current time data is synchronized according to the time prediction value of the second device. If the upper and lower limit constraints are not met, the triangle inequality will not hold, and an error will occur in the timing synchronization.

[0074] In this embodiment, the updated linear prediction function determines the time prediction value. ,in This represents the predicted time value for the second device.

[0075] In this embodiment, the fault tolerance constant is a preset small constant. It is used to increase the fault tolerance of the calibration and resist measurement noise and micro-sequence jitter.

[0076] In this embodiment, the offset is the time difference between the current local time and the reference time.

[0077] In this embodiment, the confidence interval is the range of uncertainty of the time-predicted value calculated based on the historical fitted residual distribution. The specific formula corresponding to the confidence interval is... ,in, This indicates the offset of the first device. .

[0078] In this embodiment, the time prediction value is a second device time estimate corresponding to the current local time, calculated using an updated linear prediction function.

[0079] The working principle and beneficial effects of this embodiment are as follows: Upper and lower bound constraints and confidence intervals are constructed based on necessary conditions. The updated linear prediction function is used to calculate the time prediction value corresponding to the current local experiment. Logical verification is first performed using the upper and lower bound constraints, and then the accuracy is evaluated using the confidence intervals. Once both are deemed satisfactory, the result is output and used for synchronization. Through dual verification of physical logic and statistical accuracy, the time synchronization result is ensured to conform to causal laws and possess high reliability, effectively filtering out erroneous predictions and guaranteeing the safety and stability of the time synchronization system.

[0080] Example 6: The method provided in this embodiment of the disclosure includes: The formulas corresponding to the theoretical upper and lower bounds are:

[0081] Where lower_bound represents the theoretical lower bound; upper_bound represents the theoretical upper bound; Indicates the time of transmission; Indicates the time of reception; Indicates the second reference time; Indicates the timestamp of the second device; Indicates the first reference time; The formulas for calculating the upper and lower limit constraints are:

[0082] in, is the fault tolerance constant; L represents the lower limit of the theoretical time prediction value; U represents the upper limit of the theoretical time prediction value; This indicates the current time data of the first device.

[0083] To implement the above embodiments, this disclosure also proposes an adaptive time synchronization device for wireless brain-computer interface systems.

[0084] Figure 5This is a schematic diagram of the structure of an adaptive time synchronization device for a wireless brain-computer interface system provided in an embodiment of this disclosure. The device 200 can be implemented by software and / or hardware and is generally integrated into an electronic device. Figure 5 As shown, the device 200 includes: a preliminary screening module 201, a scrolling window screening module 202, a prediction function update module 203, and a time synchronization module 204, wherein, The preliminary screening module 201 is used to send a time synchronization request instruction to the second device, record the sending time, receive the reply signal with the second device timestamp returned by the second device and record the receiving time, calculate the round-trip time based on the sending time and the receiving time, and filter the original time dataset based on the round-trip time and the preset time consumption threshold range to obtain the basic time dataset. The scrolling window filtering module 202 is used to determine the scrolling window based on the basic time dataset, and in response to the total number of valid window requests of the scrolling window, calculate the window mean and global mean of the scrolling window, and filter the basic time dataset based on the window mean and global mean to obtain a valid time dataset. The prediction function update module 203 is used to select a reference time to perform coordinate translation on the effective time dataset, input the translated effective time dataset into a preset linear prediction function, calculate and update the slope parameter and intercept parameter of the linear prediction function using the least squares method, and obtain the updated linear prediction function. The time synchronization module 204 is used to calculate the second device time prediction value corresponding to the current local time using the updated linear prediction function, evaluate the accuracy of the time prediction value based on the confidence interval, verify the time prediction value by constructing a triangle inequality based on necessary conditions, and complete the time synchronization according to the verification result.

[0085] The apparatus provided in this disclosure, wherein the preliminary screening module 201 is specifically used for: The method provided in this disclosure sends a time synchronization request command to a second device, records the sending time, receives a reply signal with a timestamp from the second device and records the receiving time, calculates the round-trip time based on the sending and receiving times, and filters the original time dataset based on the round-trip time and a preset time threshold range to obtain a basic time dataset, including: The first device sends a time synchronization request command to the second device and records the time at which the time synchronization request command is sent. Receive a response signal with the second device's timestamp returned by the second device in response to the time synchronization request command, and record the time at which the response signal was received; The round-trip time of the time synchronization request instruction is calculated based on the difference between the receiving time and the sending time. If the time taken for a single round trip is not within the preset time threshold range, the corresponding original time data is discarded; if the time taken for a single round trip is within the preset time threshold range, the corresponding original time data is retained, and all retained original time data are combined to obtain the basic time dataset.

[0086] The apparatus provided in this disclosure, wherein the scrolling window filtering module 202 is specifically used for: Obtain the time synchronization accuracy requirement, and determine the rolling window by combining the time synchronization accuracy requirement with the basic time dataset; Based on each piece of data included in the basic time dataset, update the total window round-trip time, the total number of valid window requests, the total global round-trip time, and the total number of valid global requests. When the total number of requests within the current scrolling window reaches the window size, the window average is calculated based on the total round-trip time of the window and the total number of valid requests in the window, and the global average is calculated based on the total global round-trip time and the total number of valid global requests. The time consumption threshold is determined based on the window mean and the global mean. The basic time dataset is then filtered based on the time consumption threshold to obtain the effective time dataset.

[0087] The apparatus provided in this disclosure, wherein the prediction function update module 203 is specifically used for: Select the sending time of the first time data in the basic time dataset and the timestamp of the second device, and add a preset offset to each to determine the first reference time of the first device and the second reference time of the second device; Input the effective time dataset into a preset linear prediction function; For each group of data in the effective time dataset, fit the first reference time with the second reference time; Based on the fitting results, the cumulative values ​​of the first device and the second device are calculated, and the new relevant parameters of the linear prediction function are calculated using the cumulative values ​​of the first device and the second device. The linear prediction function is updated based on the new relevant parameters, which include slope and intercept parameters.

[0088] The time synchronization module 204 in the apparatus provided in this disclosure is specifically used for: The necessary conditions are obtained to construct a triangle inequality. The theoretical boundary of the one-way transmission time is determined based on the sending and receiving time of the last time synchronization request instruction and the round-trip time. Based on the theoretical boundary, a preset fault tolerance constant is introduced to determine the upper and lower limit constraints of the triangle inequality. Using the updated linear prediction function, the predicted time value of the second device is calculated based on the current time data of the first device; The offset of the current local time is calculated based on the effective dataset, and a confidence interval is set according to the offset. The accuracy of the time prediction value is evaluated based on the confidence interval. The sending time of the last time synchronization request command, the second device timestamp, and the receiving time are benchmarked to obtain the theoretical upper bound and the theoretical lower bound. Based on the theoretical upper bound and the theoretical lower bound, a preset fault tolerance constant is introduced to construct upper and lower bound constraints. If the time prediction value of the second device meets the upper and lower limit constraints, then the confidence interval of the time prediction value of the second device is evaluated. If the evaluation result of the confidence interval is credible, the time prediction value of the second device is output, and the current time data is synchronized according to the time prediction value of the second device. If the upper and lower limit constraints are not met, the triangle inequality will not hold, and an error will occur in the timing synchronization.

[0089] The apparatus provided in this disclosure includes: The formulas corresponding to the theoretical upper and lower bounds are:

[0090] Where lower_bound represents the theoretical lower bound; upper_bound represents the theoretical upper bound; Indicates the time of transmission; Indicates the time of reception; Indicates the second reference time; Indicates the timestamp of the second device; Indicates the first reference time; The formulas for calculating the upper and lower limit constraints are:

[0091] in, is the fault tolerance constant; L represents the lower limit of the theoretical time prediction value; U represents the upper limit of the theoretical time prediction value; This indicates the current time data of the first device.

[0092] The adaptive time synchronization device for wireless brain-computer interface systems provided in this disclosure can execute the time synchronization technology method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0093] To implement the above embodiments, this disclosure also proposes a computer program product, including a computer program / instruction, which, when executed by a processor, implements the time synchronization technology method described above.

[0094] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.

[0095] The following is a detailed reference. Figure 6 The diagram illustrates a structural schematic suitable for implementing the electronic device 300 in the embodiments of this disclosure. The electronic device 300 in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0096] like Figure 6 As shown, the electronic device 300 may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a memory 308 into a random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the electronic device 300. The processor 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0097] Typically, the following devices can be connected to I / O interface 305: input devices 306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 307 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 308 including, for example, magnetic tapes, hard disks, etc.; and communication devices 309. Communication device 309 allows electronic device 300 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 300 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0098] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs.

[0099] Electronic devices can be programmed with computer program code in one or more programming languages ​​or combinations thereof to perform the operations of this disclosure. These programming languages ​​include, but are not limited to, object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0100] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and apparatuses according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0101] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0102] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.

[0103] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0104] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0105] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. An adaptive time synchronization method for wireless brain-computer interface systems, characterized in that, include: Send a time synchronization request command to the second device, record the sending time, receive the reply signal with the second device's timestamp and record the receiving time, calculate the round-trip time based on the sending and receiving times, filter the original time dataset based on the round-trip time and a preset time threshold range, and obtain the basic time dataset. Based on the base time dataset, a scrolling window is determined. In response to the total number of valid window requests for the scrolling window, the window mean and global mean of the scrolling window are calculated. Based on the window mean and global mean, the base time dataset is filtered to obtain a valid time dataset. The effective time dataset is translated by selecting a reference time. The translated effective time dataset is then input into a preset linear prediction function. The slope parameter and intercept parameter of the linear prediction function are calculated and updated using the least squares method to obtain the updated linear prediction function. The updated linear prediction function is used to calculate the second device time prediction value corresponding to the current local time. The accuracy of the time prediction value is evaluated based on the confidence interval. A triangle inequality is constructed based on necessary conditions to verify the time prediction value. Time synchronization is completed based on the verification result.

2. The method according to claim 1, characterized in that, A time synchronization request command is sent to the second device, and the sending time is recorded. A reply signal with the second device's timestamp is received from the second device, and the receiving time is recorded. The round-trip time is calculated based on the sending and receiving times. The original time dataset is filtered based on the round-trip time and a preset time threshold range to obtain a basic time dataset, including: The first device sends a time synchronization request command to the second device and records the time at which the time synchronization request command is sent. Receive a response signal with the second device's timestamp returned by the second device in response to the time synchronization request command, and record the time at which the response signal was received; The round-trip time of the time synchronization request instruction is calculated based on the difference between the receiving time and the sending time. If the time taken for a single round trip does not fall within the preset time threshold range, the corresponding original time data is discarded. If the time taken for a single round trip falls within the preset time threshold range, the corresponding original time data is retained, and all retained original time data are combined to obtain the basic time dataset.

3. The method according to claim 1, characterized in that, Based on the base time dataset, a scrolling window is determined. In response to the total number of valid window requests for the scrolling window, the window mean and global mean of the scrolling window are calculated. Based on the window mean and global mean, the base time dataset is filtered to obtain a valid time dataset, including: Obtain the time synchronization accuracy requirement, and determine the rolling window by combining the time synchronization accuracy requirement with the basic time dataset; Based on each piece of data included in the basic time dataset, update the total window round-trip time, the total number of valid window requests, the total global round-trip time, and the total number of valid global requests. When the total number of requests within the current scrolling window reaches the window size, the window average is calculated based on the total round-trip time of the window and the total number of valid requests in the window, and the global average is calculated based on the total global round-trip time and the total number of valid global requests. The time consumption threshold is determined based on the window mean and the global mean. The basic time dataset is then filtered based on the time consumption threshold to obtain the effective time dataset.

4. The method according to claim 1, characterized in that, A reference time is selected to perform coordinate translation on the effective time dataset. The translated effective time dataset is then input into a preset linear prediction function. The slope and intercept parameters of the linear prediction function are calculated and updated using the least squares method to obtain the updated linear prediction function, including: Select the sending time of the first time data in the basic time dataset and the timestamp of the second device, and add a preset offset to each to determine the first reference time of the first device and the second reference time of the second device; Input the effective time dataset into a preset linear prediction function; For each group of data in the effective time dataset, fit the first reference time with the second reference time; Based on the fitting results, the cumulative values ​​of the first device and the second device are calculated, and the new relevant parameters of the linear prediction function are calculated using the cumulative values ​​of the first device and the second device. The linear prediction function is updated based on the new relevant parameters, which include slope and intercept parameters.

5. The method according to claim 2, characterized in that, The updated linear prediction function is used to calculate the second device time prediction value corresponding to the current local time. The accuracy of the time prediction value is evaluated based on a confidence interval. A triangle inequality is constructed based on necessary conditions to verify the time prediction value. Time synchronization is completed based on the verification result, including: The necessary conditions are obtained to construct a triangle inequality. The theoretical boundary of the one-way transmission time is determined based on the sending and receiving time of the last time synchronization request instruction and the round-trip time. Based on the theoretical boundary, a preset fault tolerance constant is introduced to determine the upper and lower limit constraints of the triangle inequality. Using the updated linear prediction function, the predicted time value of the second device is calculated based on the current time data of the first device; The offset of the current local time is calculated based on the effective dataset, and a confidence interval is set according to the offset. The accuracy of the time prediction value is evaluated based on the confidence interval. The sending time of the last time synchronization request command, the second device timestamp, and the receiving time are benchmarked to obtain the theoretical upper bound and the theoretical lower bound. Based on the theoretical upper bound and the theoretical lower bound, a preset fault tolerance constant is introduced to construct upper and lower bound constraints. If the time prediction value of the second device meets the upper and lower limit constraints, then the confidence interval of the time prediction value of the second device is evaluated. If the evaluation result of the confidence interval is credible, the time prediction value of the second device is output, and the current time data is synchronized according to the time prediction value of the second device. If the upper and lower limit constraints are not met, the triangle inequality will not hold, and an error will occur in the timing synchronization.

6. The method according to claim 5, characterized in that, include: The formulas corresponding to the theoretical upper and lower bounds are: Where lower_bound represents the theoretical lower bound; upper_bound represents the theoretical upper bound; Indicates the time of transmission; Indicates the time of reception; Indicates the second reference time; Indicates the timestamp of the second device; Indicates the first reference time; The formulas for calculating the upper and lower limit constraints are: Where eps is the fault tolerance constant; L represents the lower limit of the theoretical time prediction value; and U represents the upper limit of the theoretical time prediction value. This indicates the current time data of the first device.

7. An adaptive time synchronization device for wireless brain-computer interface systems, characterized in that, The device includes: The preliminary screening module is used to send a time synchronization request command to the second device, record the sending time, receive the reply signal with the second device's timestamp and record the receiving time, calculate the round-trip time based on the sending time and receiving time, and filter the original time dataset based on the round-trip time and a preset time threshold range to obtain the basic time dataset. The scrolling window filtering module is used to determine the scrolling window based on the basic time dataset, and in response to the total number of valid window requests of the scrolling window, calculate the window mean and global mean of the scrolling window, and filter the basic time dataset based on the window mean and global mean to obtain a valid time dataset. The prediction function update module is used to select a reference time to perform coordinate translation on the effective time dataset, input the translated effective time dataset into a preset linear prediction function, calculate and update the slope parameter and intercept parameter of the linear prediction function using the least squares method, and obtain the updated linear prediction function. The time synchronization module is used to calculate the second device time prediction value corresponding to the current local time using the updated linear prediction function, evaluate the accuracy of the time prediction value based on the confidence interval, verify the time prediction value by constructing a triangle inequality based on necessary conditions, and complete the time synchronization according to the verification result.

8. An electronic device, characterized in that, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the time synchronization technique method as described in any one of claims 1-6.