Method and device for automatically detecting epilepsy based on wire length algorithm in implantable closed-loop system

By adopting an epilepsy detection method based on line length algorithm in an implanted closed-loop system, using the SPI interface to configure detection parameters and calculate the line length ratio of bioelectric signals, the real-time and power consumption problems of epilepsy detection in the prior art are solved. Improves the accuracy and convenience of detection.

CN112972892BActive Publication Date: 2024-12-27HANGZHOU NUOWEI MEDICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110170234.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-05
Publication Date
2024-12-27
Estimated Expiration
2041-02-05

AI Technical Summary

Technical Problem

The existing epilepsy detection technology has poor real-time performance, high power consumption and unsuitable algorithm complexity, resulting in low detection convenience and integration.

Method used

The implanted closed-loop system is based on the line length algorithm, and the detection parameters are configured through the SPI serial peripheral interface, and bioelectric signals are collected in real time, the line length ratio of the detection window and the background window is calculated, and whether it is greater than the preset threshold is used to trigger the treatment signal.

Benefits of technology

Real-time epilepsy detection with low power consumption is realized, which improves the accuracy and convenience of detection, and is suitable for the integration of implantable devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112972892B_ABST
    Figure CN112972892B_ABST
Patent Text Reader

Abstract

One or more embodiments of this specification disclose a method and device for automatically detecting epilepsy based on a line length algorithm for an implantable closed-loop system, the method comprising: using a hardware algorithm to collect and detect bioelectric signals in real time, and then, according to the ratio between the average line length of the detection window and the average line length of the background window in each detection cycle and a preset threshold, determining whether epilepsy is triggered by stimulation treatment through an identification signal. Thus, real-time detection with low power consumption improves integration, detection accuracy, and convenience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This document relates to the field of medical device technology, and in particular to a method and device for automatically detecting epilepsy based on a line length algorithm in an implantable closed-loop system. Background Art

[0002] Epilepsy, commonly known as "epilepsy", is a chronic neurological disease caused by abnormal discharges formed by highly synchronized neuronal activity. The pathogenesis of epilepsy is complex, with many pathogenic factors, great harm to health, and difficult to cure. Therefore, the study of epilepsy detection technology is an important topic in neurology.

[0003] At present, epilepsy EEG is mostly collected through EEG machines, which analyze and process the collected EEG data offline and identify the time when epilepsy occurs. This detection has poor real-time performance and cannot take timely countermeasures when epilepsy is detected. The method of transplanting software algorithm programs to microcontroller chips MCU to detect epilepsy can achieve real-time performance, but it requires the MCU to run all the time, which consumes a lot of power; at the same time, too complex algorithms are difficult to apply to implantable devices and have low integration.

[0004] In summary, there is an urgent need to find a new epilepsy detection solution. Summary of the invention

[0005] The purpose of one or more embodiments of this specification is to provide a method and device for automatically detecting epilepsy based on a line length algorithm in an implantable closed-loop system, which uses a hardware algorithm to flexibly configure an integrated implantable device to perform low-power real-time detection of epilepsy, thereby improving integration and detection convenience.

[0006] To solve the above technical problems, one or more embodiments of this specification are implemented as follows:

[0007] In the first aspect, a method for automatically detecting epilepsy by an implantable closed-loop system based on a line length algorithm is proposed, which is applied to an epilepsy detection device composed of a chip, and the method comprises:

[0008] Configuring detection parameters through an SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle;

[0009] Collect bioelectric signals from the organism implanted with the detection chip in real time and store them in the memory and algorithm register;

[0010] The absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register are calculated in sequence and sent to an accumulator;

[0011] Based on the value in the accumulator, respectively determine the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window;

[0012] Determine whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold;

[0013] When the judgment result is greater than, an identification signal indicating an epileptic seizure is output to trigger a therapeutic device to stimulate the organism.

[0014] In the second aspect, an implantable closed-loop system is proposed to automatically detect epilepsy based on a line length algorithm, comprising:

[0015] A configuration module, configured with a detection parameter through an SPI serial peripheral interface, wherein the detection parameter at least includes: a detection window size, an interval window size, and a background window size within a detection cycle;

[0016] The acquisition and storage module collects bioelectric signals from the organism implanted with the detection chip in real time and stores them in the memory and algorithm register;

[0017] A calculation module, which calculates the absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register in sequence and sends them to an accumulator;

[0018] A determination module, based on the value in the accumulator, determines the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window;

[0019] A detection module, determining whether a ratio of an average line length of the current detection window to an average line length of the background window is greater than a preset threshold;

[0020] The treatment module, when the judgment result is greater than, outputs an identification signal indicating an epileptic seizure to trigger the treatment device to stimulate the organism for treatment.

[0021] In the third aspect, a device for automatically detecting epilepsy based on a line length algorithm of an implantable closed-loop system is proposed, which at least includes: a hardware algorithm chip for executing the above method and other functional modules; wherein, the hardware algorithm chip includes: a serial peripheral interface, a memory, an algorithm register, an accumulator, and a counter; wherein,

[0022] The serial peripheral interface is used to configure detection parameters and transmit bioelectric signals; wherein the detection parameters at least include: detection window size, interval window size and background window size within a detection cycle;

[0023] The memory and algorithm register are respectively used to store bioelectric signals collected in real time from a biological body implanted with a detection chip, and after the absolute values ​​of the amplitude differences of adjacent bioelectric signals in the algorithm register are calculated in sequence by a counter, they are sent to an accumulator;

[0024] After respectively determining the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window based on the value in the accumulator, the detection enable end determines whether a ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold;

[0025] When the judgment result is greater than, the serial peripheral interface outputs an identification signal indicating an epileptic seizure to trigger a therapeutic device to stimulate the organism.

[0026] In a fourth aspect, an electronic device is provided, comprising:

[0027] Processor; and

[0028] a memory arranged to store computer executable instructions which, when executed, cause the processor to:

[0029] Configuring detection parameters through an SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle;

[0030] Collect bioelectric signals from the organism implanted with the detection chip in real time and store them in the memory and algorithm register;

[0031] The absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register are calculated in sequence and sent to an accumulator;

[0032] Based on the value in the accumulator, respectively determine the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window;

[0033] Determine whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold;

[0034] When the judgment result is greater than, an identification signal indicating an epileptic seizure is output to trigger a therapeutic device to stimulate the organism.

[0035] It can be seen from the technical solutions provided by one or more embodiments of the present specification that, through the above technical solutions, a hardware algorithm can be used to collect and detect bioelectric signals in real time, and then, according to the comparison between the ratio of the average line length of the detection window and the average line length of the background window in each detection cycle and the preset threshold, it is determined whether epilepsy is triggered by stimulation treatment through the identification signal. Thus, real-time detection with low power consumption is achieved, and integration, detection accuracy and convenience are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the description of one or more embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0037] Figure 1 It is a schematic diagram of the steps of a method for automatically detecting epilepsy based on a line length algorithm by an implantable closed-loop system provided in an embodiment of this specification.

[0038] Figure 2 It is a schematic diagram of the detection cycle provided in the embodiments of this specification.

[0039] Figure 3 It is a schematic diagram of the structure of an implantable closed-loop system for automatically detecting epilepsy based on a line length algorithm provided in an embodiment of this specification.

[0040] Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of this specification.

[0041] Figure 5 This is a schematic diagram of the structure of an implantable closed-loop system for automatically detecting epilepsy based on a line length algorithm in this specification. DETAILED DESCRIPTION

[0042] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below in conjunction with the drawings in one or more embodiments of this specification. Obviously, the one or more embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.

[0043] The embodiment of this specification proposes a hardware algorithm for automatically detecting epilepsy based on a line length algorithm in an implantable closed-loop system, which belongs to the field of neuroscience and medical devices. The hardware algorithm can be written in Verilog hardware language or other implementable hardware language, and can accurately detect whether the bioelectric signal is abnormal in real time, and pull up the Flag warning signal when the bioelectric signal is abnormal. At this time, the detection enable signal is 1, and the hardware algorithm suspends detection. When the detection enable signal is 0, the hardware algorithm performs detection. The specific detection standard can refer to the following content, so that the signal data of the previous period (generally set to 30s) when the abnormal signal occurs and the signal data of the next period (generally set to 60s) when the abnormal signal occurs can be transmitted through the serial peripheral interface SPI protocol, and this part of the data can be stored externally for medical research. In the entire detection process, for each round of detection, the size of the detection window, background window, interval window and threshold of the algorithm are adjustable, and the applicability is wide. Moreover, the hardware algorithm can be used as an IP core, that is, an intellectual property module, which is an IC module that has been verified, can be reused, and has a certain function. It is divided into soft IP core, firm IP core and hard IP core. Soft IP uses a high-level language to describe the behavior of the functional block, but does not involve what circuits and circuit elements are used to implement these behaviors. The embodiment of this application is soft IP. It is made into an algorithm chip through semiconductor technology and can be used in various neurotherapy devices. Compared with the software algorithm running on MCU, it has lower power consumption and higher integration.

[0044] Embodiment 1

[0045] Reference Figure 1 As shown, it is a schematic diagram of the steps of a method for automatically detecting epilepsy based on a line length algorithm of an implantable closed-loop system provided in an embodiment of this specification. It should be understood that the method is applied to an epilepsy detection device composed of a chip, and its execution subject can be an integrated circuit of the chip or an epilepsy detection device composed of the chip; the detection method may include the following steps:

[0046] Step 102: configuring detection parameters through the SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle.

[0047] It should be noted that, refer to Figure 2 As shown, in each round of detection scheme, multiple detection cycles can be included, and each detection cycle includes a background window, an interval window and a detection window. Moreover, the background window can be located in the previous time period of the detection window, and the interval window is located between the background window and the detection window. Figure 2The first detection cycle shown in is from t0-t5, where t0-t2 is the background window, t2-t4 is the interval window, and t4-t5 is the detection window; the second detection cycle is from t1-t6, where t1-t3 is the background window, t3-t5 is the interval window, and t5-t6 is the detection window. The subsequent third detection cycle and fourth detection cycle are similar. Figure 2 It can be seen that, except for the first detection cycle, each detection cycle partially overlaps with the previous detection cycle, that is, the bioelectric signal in the current detection cycle contains part of the bioelectric signal in the previous detection cycle.

[0048] The background window size may be N1 times the detection window size, and the interval window size may be N2 times the detection window size; wherein both N1 and N2 are positive integers greater than or equal to 2. It should be understood that in the embodiments of this specification, the values ​​of N1 and N2 may be equal or unequal. After the size of the detection window is determined, the background window size and the interval window size may be flexibly configured according to the requirements of this round of detection.

[0049] Step 104: Collect bioelectric signals from the organism implanted with the detection chip in real time and store them in the memory and algorithm register.

[0050] In the embodiments of this specification, the bioelectric signal may specifically be an electroencephalogram signal, or a deep brain electrophysiological signal, or a cerebral cortex bioelectric signal, or a central nervous system signal, etc.

[0051] The memory may be a Sraml memory with a capacity of 40 kB.

[0052] Step 106: Calculate the absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register in sequence and send them to the accumulator.

[0053] The accumulator may be an accumulator for accumulating the sum of line lengths in each detection window. It should be understood that the ratio of the amplitude of the bioelectric signal to the DC bias is essentially the ratio of the area covered by the amplitude of the bioelectric signal to the area covered by the DC bias.

[0054] Step 108: Based on the value in the accumulator, determine the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window.

[0055] Optionally, if the current detection window belongs to the first detection cycle of this round of detection, when the counter counts from 1 to N1, the value in the accumulator is written to the background window register until the count ends at N1, and the background window register stores the line length sum of the background window corresponding to the current detection window; when the counter counts to N1+N2+1, the value in the accumulator is written to the detection window register, and the detection window register stores the line length sum of the current detection window.

[0056] Furthermore, before counting, the method further includes: taking the detection window as the basic window unit, determining the number N1+N2+1 of basic window units in the background window, the interval window and the detection window included in the first detection cycle; accordingly,

[0057] When the count value of the counter is not greater than N1+N2+1 and the current window sampling is ended, the value of the memory is written into the buffer from low address to high address, and the counter is increased by 1 at the same time; when the count value of the counter is less than or equal to N1 and the current window sampling is ended, the memory is accumulated and written into the background window register in sequence, and the background window register stores the sum of the line lengths of the background window in the first detection cycle; when the count value of the counter is equal to N1+N2+1 and the current sampling window is ended, the memory is written into the detection window register, and the detection window register stores the sum of the line lengths of the detection window in the first detection cycle.

[0058] Optionally, if the current detection window belongs to a detection cycle other than the first detection cycle of this round of detection, the value of the lowest bit is read from the buffer and written into the first temporary register for temporary storage;

[0059] The buffer is shifted left once, the value of the memory is written to the N1+N2+1th address, and then the value of the N1+1th bit in the buffer is read and temporarily stored in the second temporary register;

[0060] Writing the value in the memory into the detection window register to facilitate re-assignment of the line length and value of the current detection window;

[0061] The value of the background window register minus the value of the first temporary register is added to the value of the second temporary register, and the result is written into the background window register as the line length and value of the current background window.

[0062] Step 110: Determine whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold.

[0063] The preset threshold may be a standard value obtained based on an empirical data signal, and is used to measure whether an organism implanted with the detection chip has epilepsy.

[0064] Step 112: When the result of the judgment is greater than, an identification signal indicating an epileptic seizure is output to trigger a treatment device to stimulate the organism for treatment.

[0065] In a specific implementation, the identification signal may be a Flag signal. When the Flag signal is pulled high, it indicates an epileptic seizure, which may trigger stimulation therapy. Otherwise, if the epileptic seizure has not occurred, no treatment is performed and further detection is continued.

[0066] The epilepsy detection scheme involved in this specification is described in detail below through specific examples, taking EEG signals as an example.

[0067] First, the algorithm signals and hardware units involved in the detection scheme are introduced.

[0068] The input ports of the hardware algorithm are: CLK1 port, CLK2 port, nRST port, MOSI port, Data_ADC port, EN_detect port; the output ports are MISO port and Flag port. The communication mode of the overall solution adopts the serial peripheral interface SPI. Among them, the SPI communication mode is to send data on the rising edge and collect data on the falling edge. The CLK1 port and the CLK2 port are two master clock ports with the same phase. The nRST port is the reset signal port, the signal output 0 is reset, and the signal output 1 is normal operation. The MOSI port is the SPI communication port, and the signal direction is host output and slave input. The Data_ADC port is used to transmit 16-bit wide EEG data, and can be connected to the output of the 16-bit ADC in actual applications. The EN_detect port is the detection enable signal port. The MISO port is the SPI communication port, and the signal direction is host input and slave output. The Flag port is the epileptic seizure warning signal port. Correspondingly, each port has a corresponding signal output.

[0069] Further, T is defined as the number of sampling points in the detection window, which is configured through the SPI port and has a range of 0-511. N1 is the multiple of the size of the background window and the size of the detection window, which is configured through the SPI port and has a range of 0-255. N2 is the multiple of the size of the interval window and the size of the detection window, which is configured through the SPI port and has a range of 0-255. LIM is the preset threshold, which is configured through the SPI port and has a range of 110-180. Data_H1 is an algorithm register for storing EEG signals, which is mainly used to store the EEG signals of the previous falling edge. Data_H0 is an algorithm register for storing EEG signals, which is mainly used to store the EEG signals of the next falling edge. CNT1 is a counter for counting the number of sampling points in the detection window. Q is a variable for counting the number of detection windows in the first calculation cycle. Sum1 is an accumulator used to accumulate the sum of line lengths in each detection window. Sum_background is a background window register used to accumulate the sum of line lengths in the background window. Sum_detect is a detection window register used to store the sum of line lengths in the detection window in each calculation cycle. Sum_L is the first temporary register, used to store the value of the lowest bit in the buffer. Sum_N is the second temporary register, used to store the value of the N1+1th bit in the buffer. Sram1 is a memory with a capacity of 40kB. Fifo1 is a buffer, a dual-port ram, used to store intermediate calculation results during the calculation process. Sram_fifo is an output buffer, used for buffering when epileptic EEG data is output.

[0070] The detection scheme in this manual can generally include the following parts:

[0071] 1. Configure algorithm parameters.

[0072] 2. Store the EEG signal in Sram1 and the algorithm register group.

[0073] 3. Calculate the difference between the amplitudes of adjacent EEG signals and take the absolute value.

[0074] 4. The calculation process for detecting whether epilepsy occurs.

[0075] (4.1) First, calculate the sum of the line lengths of each detection window, write the sum of the line lengths of the background window into the Sum_background register, and write the sum of the line lengths of the detection window into the Sum_detect register.

[0076] (4.2) Calculate the average line length of the detection window, calculate the average line length of the background window, judge the detection result and give a Flag signal.

[0077] 5. The process data of epilepsy detection is serially output through the communication port.

[0078] The specific implementation process can refer to the following content:

[0079] 1. The EEG data of Data_ADC[15:0] is written into the Sram1 memory and the register group Data_H1[15:0] at a frequency of 200 Hz. At the falling edge of the next clock, the data in Data_H1[15:0] is written into Data_H0[15:0].

[0080] The input frequency can be set flexibly, and 200 Hz here is just an example.

[0081] 2. Subtract the value in the Data_H0[15:0] register (the amplitude of the EEG signal) from the value in the Data_H1[15:0] register (the amplitude of the EEG signal), and calculate the absolute value of the difference. The absolute values ​​are accumulated in the Sum1 accumulator in sequence. In other words, the difference between the amplitude of the previous EEG signal and the amplitude of the adjacent next EEG signal is taken as the input and accumulated and written into the accumulator. The CNT1[10:0] counter counts the number of accumulations of Sum1 from 0, with the length of a detection window as one cycle.

[0082] 3. The first calculation cycle: Register Q records the number of detection windows in the first calculation cycle, Q>=0 and Q<=N1+N2+2. When Q<=N1+N2+1 and CNT1=T (the current detection window ends and the next adjacent detection window begins), the Sum1 value is written into Fifo1 from low address to high address, and Q is increased by 1. When Q<=N1 and CNT1=T, Sum1 is accumulated and written into the Sum_background register in sequence, and the Sum_background register stores the sum of the line lengths of the background window in the first detection cycle; when Q=N1+N2+1 and CNT1=T, Sum1 is written into the Sum_detect register, that is, the Sum_detect register stores the sum of the line lengths of the detection window. According to the ratio of the average line length of the detection window to the average line length of the background window, the ratio is compared with the preset threshold LIM. If it is greater than LIM, it means that an epileptic seizure has occurred, and the Flag signal is pulled high. Otherwise, an epileptic seizure has not occurred. The preset threshold LIM may be 400%, that is, when the ratio is less than or equal to 400%, the Flag signal will not be triggered to be pulled high.

[0083] 5. After the first test is completed, enter the second test cycle.

[0084] At this time, Fifo1 stores N1+N2+1 values. The data of the lower N1 bits is the Sum1 value of the background window in the first calculation cycle. The data of the next N2 bits is the Sum1 value of the interval window in the first calculation cycle. The highest bit is the Sum1 value of the detection window. When CNT1=T, the lowest bit of data in fifo1 is first read out to the first temporary register Sum_L for temporary storage. Then Fifo1 shifts left once and writes the Sum1 value to the N1+N2+1th address. Then, the data of the N1+1th bit in Fifo1 is read to the second temporary register Sum_N for temporary storage. At the same time, the value of Sum1 is also written into the register Sum_detect. The current Sum_background stores the line length sum of the background interval in the first calculation cycle. At this time, Sum_background-Sum_L+Sum_N is assigned to Sum_background, which is the background window line length sum of the second calculation cycle. According to formula (1) again, the ratio of the average line length of the detection interval in the second calculation cycle to the average line length of the background window can be obtained, and it is also compared with the threshold LIM. If it is greater than LIM, it means that an epileptic seizure has occurred and the Flag signal is pulled high. Otherwise, the epileptic seizure has not occurred.

[0085] 6. Continue the third and subsequent detection cycles according to the logic in 5.

[0086] 7. Every time an epileptic seizure is detected and the Flag is pulled high, the EN_detect terminal can be pulled high externally to pause the detection and perform stimulation.

[0087] At the same time, the Sram1 read enable in the hardware algorithm takes effect. By controlling the address terminal, the EEG data of 30 seconds before and 60 seconds after the epileptic seizure can be read. Since the Sram1 reading frequency is much lower than the SPI communication frequency, the data output by Sram1 is written into the cache Sram_fifo. After the data is written, it is read out from low to high in sequence and output serially through the MISO port. After output, it can be stored in the external Flash and can be used for subsequent medical research. It is of great significance to the research of neuroscience.

[0088] Therefore, through the above technical solution, the hardware algorithm can be used to collect and detect bioelectric signals in real time, and then, according to the comparison between the ratio of the average line length of the detection window and the average line length of the background window in each detection cycle and the preset threshold, it is determined whether epilepsy is triggered by stimulation treatment through the identification signal. Thus, real-time detection with low power consumption improves integration, detection accuracy and convenience.

[0089] Embodiment 2

[0090] Reference Figure 3As shown, an implantable closed-loop system for automatically detecting epilepsy based on a line length algorithm 300 provided in an embodiment of this specification is mainly composed of:

[0091] Configuration module 302, configuring detection parameters through the SPI serial peripheral interface, wherein the detection parameters at least include: detection window size, interval window size and background window size within a detection cycle;

[0092] The acquisition and storage module 304 acquires bioelectric signals from the organism implanted with the detection chip in real time and stores them in the memory and algorithm register;

[0093] The calculation module 306 calculates the absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register in sequence and sends them to the accumulator;

[0094] A determination module 308, based on the value in the accumulator, determines the sum of line lengths of the current detection window and the sum of line lengths of the background window corresponding to the current detection window;

[0095] The detection module 310 determines whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold;

[0096] The treatment module 312, when the judgment result is greater than, outputs an identification signal indicating an epileptic seizure to trigger the treatment device to stimulate the organism.

[0097] Optionally, as an embodiment, the background window size is N1 times the detection window size, and the interval window size is N2 times the detection window size; wherein both N1 and N2 are positive integers greater than or equal to 2.

[0098] In a specific implementation of the embodiment of this specification, the determining module 308 is specifically used to:

[0099] When the counter counts from 1 to N1, the value in the accumulator is written into the background window register until the count ends at N1, and the background window register stores the line length sum of the background window corresponding to the current detection window;

[0100] When the counter counts to N1+N2+1, the value in the accumulator is written into the detection window register, and the detection window register stores the line length sum of the current detection window.

[0101] In another specific implementation of the embodiment of this specification, before counting, the determining module 308 is further configured to:

[0102] Taking the detection window as the basic window unit, determine the number of basic window units N1+N2+1 in the background window, interval window and detection window included in the first detection cycle; accordingly,

[0103] When the count value of the counter is not greater than N1+N2+1 and the current window sampling is completed, the value of the memory is written into the buffer from the low address to the high address, and the counter is incremented by 1;

[0104] When the count value of the counter is less than or equal to N1 and the current window sampling is completed, the memory accumulates and writes into the background window register in sequence, and the background window register stores the line length and the background window in the first detection cycle;

[0105] When the count value of the counter is equal to N1+N2+1 and the current sampling window ends, the memory writes into the detection window register, and the detection window register stores the line length sum of the detection window in the first detection cycle.

[0106] In another specific implementation of the embodiment of the present specification, if the current detection window belongs to a non-first detection cycle of the current round of detection, the determination module is specifically used to:

[0107] Reading the value of the lowest bit from the buffer and writing it into the first temporary register for temporary storage;

[0108] The buffer is shifted left once, the value of the memory is written to the N1+N2+1th address, and then the value of the N1+1th bit in the buffer is read and temporarily stored in the second temporary register;

[0109] Writing the value in the memory into the detection window register to facilitate re-assignment of the line length and value of the current detection window;

[0110] The value of the background window register minus the value of the first temporary register is added to the value of the second temporary register, and the result is written into the background window register as the line length and value of the current background window.

[0111] In another specific implementation of the embodiments of the present specification, when the biological body is stimulated for treatment, it also includes an output module for acquiring bioelectric signals of a first period before the epileptic seizure and a second period after the epileptic seizure, and outputting them serially via SPI.

[0112] Through the above technical solution, the hardware algorithm can be used to collect and detect bioelectric signals in real time, and then, according to the comparison between the ratio of the average line length of the detection window and the average line length of the background window in each detection cycle and the preset threshold, it is determined whether epilepsy is triggered by stimulation treatment through the identification signal. Thus, real-time detection with low power consumption is achieved, and the integration, detection accuracy and convenience are improved.

[0113] Embodiment 3

[0114] Reference Figure 5 As shown, it is a schematic diagram of the structure of an implantable closed-loop system for automatically detecting epilepsy based on a line length algorithm provided in an embodiment of this specification, which at least includes: a hardware algorithm chip for executing the method in the above-mentioned embodiment 1 and other functional modules; wherein, the hardware algorithm chip includes: a serial peripheral interface, a memory, an algorithm register, an accumulator, and a counter; wherein,

[0115] The serial peripheral interface is used to configure detection parameters and transmit bioelectric signals; wherein the detection parameters at least include: detection window size, interval window size and background window size within a detection cycle;

[0116] The memory and algorithm register are respectively used to store bioelectric signals collected in real time from a biological body implanted with a detection chip, and after the absolute values ​​of the amplitude differences of adjacent bioelectric signals in the algorithm register are calculated in sequence by a counter, they are sent to an accumulator;

[0117] After respectively determining the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window based on the value in the accumulator, the detection enable end determines whether a ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold;

[0118] When the judgment result is greater than, the serial peripheral interface outputs an identification signal indicating an epileptic seizure to trigger a therapeutic device to stimulate the organism.

[0119] For other hardware units, please refer to the contents of the first embodiment and will not be described in detail here.

[0120] Embodiment 4

[0121] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 4 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0122] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0123] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.

[0124] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming an automatic epilepsy detection device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0125] Configuring detection parameters through an SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle;

[0126] Collect bioelectric signals from the organism implanted with the detection chip in real time and store them in the memory and algorithm register;

[0127] The absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register are calculated in sequence and sent to an accumulator;

[0128] Based on the value in the accumulator, respectively determine the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window;

[0129] Determine whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold;

[0130] When the judgment result is greater than, an identification signal indicating an epileptic seizure is output to trigger a therapeutic device to stimulate the organism.

[0131] The above is as in this manual Figure 1The method performed by the device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in one or more embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in one or more embodiments of this specification can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0132] The electronic device may also perform Figure 1 The method and the corresponding device are implemented in Figure 1 The functions of the illustrated embodiments will not be described in detail in the embodiments of this specification.

[0133] Of course, in addition to software implementation, the electronic device of the embodiments of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0134] Through the above technical solution, the hardware algorithm can be used to collect and detect bioelectric signals in real time, and then, according to the comparison between the ratio of the average line length of the detection window and the average line length of the background window in each detection cycle and the preset threshold, it is determined whether epilepsy is triggered by stimulation treatment through the identification signal. Thus, real-time detection with low power consumption is achieved, and the integration, detection accuracy and convenience are improved.

[0135] In short, the above description is only a preferred embodiment of this specification and is not intended to limit the protection scope of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the protection scope of this specification.

[0136] The systems, devices, modules or units described in one or more of the above embodiments may be implemented by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0137] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0138] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0139] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0140] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

Claims

1. A method for automatically detecting epilepsy using an implantable closed-loop system based on a line length algorithm, characterized in that: Applied to an epilepsy detection device composed of a hardware algorithm chip, the method comprises: The detection parameters are configured through the SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle, wherein, except for the first detection cycle, each detection cycle partially overlaps with the previous detection cycle, the background window size is N1 times the detection window size, and the interval window size is N2 times the detection window size; wherein both N1 and N2 are positive integers greater than or equal to 2; Collect bioelectric signals from the organism implanted with the detection chip in real time and store them in the memory and algorithm register; The absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals recorded in the algorithm register are calculated in sequence and sent to an accumulator; Based on the value in the accumulator, the line length sum of the current detection window and the line length sum of the background window corresponding to the current detection window are determined respectively, wherein, if the current detection window belongs to a detection cycle other than the first detection cycle of this round of detection, the value of the lowest bit is read from the buffer and written into the first temporary register for temporary storage; the buffer is shifted left once, the value of the memory is written to the N1+N2+1th address, and then the value of the N1+1th bit in the buffer is read into the second temporary register for temporary storage; the value in the memory is written into the detection window register so as to reassign the line length sum of the current detection window; the value of the background window register is subtracted from the value of the first temporary register, and the value of the second temporary register is added, and the result is written into the background window register as the line length sum of the current background window; Determine whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold; When the result of the determination is greater than, an identification signal indicating an epileptic seizure is output.

2. The method for automatically detecting epilepsy based on a line length algorithm using an implantable closed-loop system as claimed in claim 1, characterized in that: If the current detection window belongs to the first detection cycle of this round of detection, the line length sum of the current detection window and the line length sum of the background window corresponding to the current detection window are determined based on the value in the accumulator, specifically including: When the counter counts from 1 to N1, the value in the accumulator is written into the background window register until the count ends at N1, and the background window register stores the line length sum of the background window corresponding to the current detection window; When the counter counts to N1+N2+1, the value in the accumulator is written into the detection window register, and the detection window register stores the line length sum of the current detection window.

3. The method for automatically detecting epilepsy based on a wire length algorithm using an implantable closed-loop system as claimed in claim 2, characterized in that: Prior to counting, the method further comprises: Taking the detection window as the basic window unit, determine the number of basic window units N1+N2+1 in the background window, interval window and detection window included in the first detection cycle; accordingly, When the count value of the counter is not greater than N1+N2+1 and the current window sampling is completed, the value of the memory is written into the buffer from the low address to the high address, and the counter is incremented by 1; When the count value of the counter is less than or equal to N1 and the current window sampling is completed, the memory accumulates and writes into the background window register in sequence, and the background window register stores the line length and the background window in the first detection cycle; When the count value of the counter is equal to N1+N2+1 and the current sampling window ends, the memory writes into the detection window register, and the detection window register stores the line length sum of the detection window in the first detection cycle.

4. The method for automatically detecting epilepsy based on a wire length algorithm using an implantable closed-loop system as claimed in claim 1, characterized in that: The method further comprises: The bioelectric signal of the first period before the epileptic seizure and the bioelectric signal of the second period after the epileptic seizure are obtained and output serially through SPI.

5. An implantable closed-loop system for automatically detecting epilepsy based on a line length algorithm, characterized in that: The device for detecting epilepsy is composed of a hardware algorithm chip, including: A configuration module, configured with detection parameters through an SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle, wherein, except for the first detection cycle, each detection cycle partially overlaps with the previous detection cycle, the background window size is N1 times the detection window size, and the interval window size is N2 times the detection window size; wherein both N1 and N2 are positive integers greater than or equal to 2; The acquisition and storage module collects bioelectric signals from the organism implanted with the detection chip in real time and stores them in the memory and algorithm register; A calculation module, which calculates the absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register in sequence and sends them to an accumulator; A determination module determines the line length sum of the current detection window and the line length sum of the background window corresponding to the current detection window based on the value in the accumulator, wherein if the current detection window belongs to a detection cycle other than the first detection cycle of this round of detection, the value of the lowest bit is read from the buffer and written into the first temporary register for temporary storage; the buffer is shifted left once, the value of the memory is written to the N1+N2+1th address, and then the value of the N1+1th bit in the buffer is read into the second temporary register for temporary storage; the value in the memory is written into the detection window register to facilitate reassignment of the line length sum of the current detection window; the value of the background window register is subtracted from the value of the first temporary register, and the value of the second temporary register is added, and the value is written into the background window register as the line length sum of the current background window; A detection module, determining whether a ratio of an average line length of the current detection window to an average line length of the background window is greater than a preset threshold; The treatment module outputs an identification signal indicating an epileptic seizure when the judgment result is greater than.

6. An implantable closed-loop system for automatically detecting epilepsy based on a line length algorithm, characterized in that: At least comprising: a hardware algorithm chip and other functional modules for executing the method described in any one of claims 1 to 4; wherein, the hardware algorithm chip comprises: a serial peripheral interface SPI, a memory, an algorithm register, an accumulator, and a counter; wherein, The serial peripheral interface is used to configure detection parameters and transmit bioelectric signals; wherein the detection parameters at least include: detection window size, interval window size and background window size within a detection cycle; The memory and algorithm register are respectively used to store bioelectric signals collected in real time from a biological body implanted with a detection chip, and after the absolute values ​​of the amplitude differences of adjacent bioelectric signals in the algorithm register are calculated in sequence by a counter, they are sent to an accumulator; After respectively determining the sum of the line lengths of the current detection window and the sum of the line lengths of the background window corresponding to the current detection window based on the value in the accumulator, the detection enable end determines whether a ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold; When the judgment result is greater than, the serial peripheral interface outputs an identification signal indicating an epileptic seizure.

7. The device for automatically detecting epilepsy based on a wire length algorithm of an implantable closed-loop system as claimed in claim 6, characterized in that: The SPI is also used to obtain the bioelectric signal of the first time period before the epileptic seizure and the bioelectric signal of the second time period after the epileptic seizure, and output them in series.

8. An electronic device, comprising: processor; as well as a memory arranged to store computer executable instructions which, when executed, cause the processor to: The detection parameters are configured through the SPI serial peripheral interface, wherein the detection parameters at least include: a detection window size, an interval window size, and a background window size within a detection cycle, wherein, except for the first detection cycle, each detection cycle partially overlaps with the previous detection cycle, the background window size is N1 times the detection window size, and the interval window size is N2 times the detection window size; wherein both N1 and N2 are positive integers greater than or equal to 2; Collect bioelectric signals from the organism implanted with the detection chip in real time and store them in the memory and algorithm register; The absolute values ​​of the differences between the amplitudes of adjacent bioelectric signals in the algorithm register are calculated in sequence and sent to an accumulator; Based on the value in the accumulator, the line length sum of the current detection window and the line length sum of the background window corresponding to the current detection window are determined respectively, wherein, if the current detection window belongs to a detection cycle other than the first detection cycle of this round of detection, the value of the lowest bit is read from the buffer and written into the first temporary register for temporary storage; the buffer is shifted left once, the value of the memory is written to the N1+N2+1th address, and then the value of the N1+1th bit in the buffer is read into the second temporary register for temporary storage; the value in the memory is written into the detection window register so as to reassign the line length sum of the current detection window; the value of the background window register is subtracted from the value of the first temporary register, and the value of the second temporary register is added, and the result is written into the background window register as the line length sum of the current background window; Determine whether the ratio of the average line length of the current detection window to the average line length of the background window is greater than a preset threshold; When the result of the determination is greater than, an identification signal indicating an epileptic seizure is output.