Abstract:
A system ( 10 ) analyzes signals representative of a subject&#39;s brain activity in a signal processor ( 12 ) for information indicating the subject&#39;s current activity state and for predicting a change in the activity state. One preferred embodiment uses a combination of nonlinear filtering methods to perform real-time analysis of the electro-encephalogram (EEG) or electro-corticogram (ECoG) signals from a subject patient for information indicative of or predictive of a seizure, and to complete the needed analysis at least before clinical seizure onset. The preferred system then performs an output task for prevention or abatement of the seizure, or for recording pertinent data.

Description:
CROSS REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application is a continuation of co-pending application for U.S. patent application Ser. No. 10/210,497, filed Aug. 1, 2002 and now U.S. Pat. No. 7,630,757, issued Dec. 8, 2009; which is a continuation of application for U.S. Patent, application Ser. No. 09/329,593, filed Jun. 10, 1999 and now U.S. Pat. No. 6,549,804, issued Apr. 15, 2003; which is a continuation of application for U.S. patent application Ser. No. 08/778,771, filed Jan. 6, 1997 and now U.S. Pat. No. 5,995,8681, issued Nov. 30, 1999. 
     
    
     FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT 
       [0002]    Not applicable. 
       COMPUTER PROGRAM LISTING APPENDIX 
       [0003]    A computer program listing appendix on compact disk is included in this application as patent_code.ps, 92.2 KB, loaded on disk Jul. 8, 2002, which is incorporated herein by reference. The content of each CD is in ASCII format for an IBM PC/MS Windows compatible computer system. 
       BACKGROUND OF THE INVENTION 
       [0004]    1. Field of the Invention 
         [0005]    The present invention relates to the field of neuroscience for analyzing signals representative of a subject&#39;s brain activity including signals indicative or predictive of epileptic seizures. More particularly, the invention concerns the automated analysis of brain activity signals to detect an activity state and transitions between states, and to detect precursors predictive of a change in the subject&#39;s activity state to a different state. 
         [0006]    The invention is based on ideas and research in the fields of mathematics, neurology, statistics and engineering which enable the real-time analysis of biologic signals such as the electro-encephalogram (EEG) or electro-corticogram (ECoG), by the simultaneous execution of multiple methods. In the preferred embodiment, these signals are rapidly, accurately, and automatically analyzed in order to: 
         [0007]    1) Detect and signal the occurrence of an epileptic seizure in real time (or contemporaneously with the arrival of the signal at the processor/device), 
         [0008]    2) To predict behavioral changes typically associated with seizures, 
         [0009]    3) To predict seizures by detecting precursors to the onset of the electrographic or clinical components of a seizure, 
         [0010]    4) To detect and further analyze epileptiform discharges (spikes), and 
         [0011]    5) To download the detection or prediction outputs to devices for warning, or therapeutic interventions or the storage of data. 
         [0012]    2. Description of the Prior Art 
         [0013]    Humans and animals have several normal states of behavior such as wakefulness and sleep, as well as multiple sub-states such as attentive wakefulness and REM sleep. Abnormal states include reversible states such as seizures and progressive states such as dementia. 
         [0014]    Epilepsy, a disabling disease, affects 1-2% of the American and industrialized world&#39;s population, and up to 10% of people in under-developed countries. Electroencephalography is the single most important ancillary test in the investigation of this disease. EEG&#39;s are recorded continuously for hours to days in an increasing number of cases with unclear diagnosis or poor response to adequate medical treatment. The amount of EEG data for analysis is extremely large (e.g., 64 channels of data at 240 Hz gives 1.3 billion data points/24 hr or 2.6 Gigabytes/day) and consists of complex waveforms with infinite variations. 
         [0015]    Visual analysis of these signals remains (exclusive of this invention) the “gold standard” but it is impracticable for continuous EEG interpretation as this is the most time-consuming part of any electrodiagnostic test and requires special training and skills which make this procedure expensive and thus of limited access and use. Valuable EEG data is often discarded unexamined. The length of recording is unnecessarily prolonged in a specially equipped hospital suite until patients have several seizures. If the patient is unaware of the seizures, a common occurrence, then a nurse or relative must observe and document the occurrence of these changes. As seizures are brief and previously considered unpredictable, the need for continuous observation becomes imperative, adding to the cost in a non-effective manner. 
         [0016]    Present methods of seizure detection are not only expensive, but rely on poorly discriminating methods, increasing the review time and nursing assistance because of the large number of false positives, and increasing the length of hospitalization through the false negatives. Furthermore, these methods often “detect” the seizure well after its onset or even its end, when prevention or abatement of the seizure is not possible or irrelevant. 
         [0017]    The inability to process data in real time has thwarted the scientific and clinical development of the fields of epilepsy and electroencephalography. Cardiology has developed into a clinical science largely based on the power of electrocardiography to analyze the heart&#39;s electrical activity in a rapid and accurate manner. This has resulted in pace-makers, implanted defibrilators, and other devices which have saved thousands of individuals from premature death. The comparison between cardiology/EKG and epilepsy/EEG must take into account the fact that the electrical brain signals are far more complex than those originating from the heart. This explains in large part the developmental lag between these two disciplines. 
         [0018]    Electrical brain signals, because of their spatial and temporal characteristics such as non-stationarity, have resisted accurate real-time automatic manipulation. The prior art methods presently used to characterize these states are severely limited. For example, the prior art consists of a long history of failed attempts to identify changes in EEG during certain behavioral states or tasks and to discern epi-phenomenology from phenomenology, a distinction that would help answer questions of fundamental importance. Other limitations include the inability to determine whether spikes are a static marker of epilepsy, or whether they are dynamically related to seizure generation. 
         [0019]    Present methods of automatic EEG analysis have many major limitations which render them virtually useless for widespread, safe and effective clinical applications. These limitations include: 
         [0020]    1) Lack of speed. The time it takes most methods to analyze the input signals and produce an output which detects or predicts a state change is too great for use in warning, intervention, or prevention of epileptic seizures and other abnormal brain states. 
         [0021]    2) Lack of accuracy. Prior art methods have a large number of false positives (incorrectly identifying non-seizure activity as a seizure) and false negatives (failure to identify a true seizure), increasing the technical and financial burden. 
         [0022]    3) Lack of adaptability to subject or seizure type; no compromise between speed vs. accuracy. 
         [0023]    4) Lack of portability and implantability. 
         [0024]    5) High cost. 
         [0025]    Accurate and reproducible prediction of behavioral or biologic signal changes associated with seizures has not been possible as these events occur unpredictably. Our methods and devices enable seizure prediction by providing a worthwhile prediction time that makes warning, abortion/abatement, and prevention of seizures possible. The new treatment modalities that can be based on this method will lead to a significant reduction in seizure frequency and, consequently, to a reduction in the occurrence of injuries and fatalities, allowing persons with epilepsy to become productive and lead normal lives. 
         [0026]    The prior art in automated seizure and spike detection consists of variations of two primary methods: “rule-based” analysis and, more recently, analysis by artificial neural networks. The most popular is a “rule-based” method which has been under development since the late 1970&#39;s, primarily by Dr. Jean Gotman. In the Gotman method, the signal is initially replaced by a piecewise linear approximation which connects maxima and minima. 
         [0027]    In the Gotman method, there is a list of rules which are then applied to throw out some of the smaller line segments in an attempt to remove fast activity that is superimposed on an underlying wave of interest. The larger line segments which remain are called “half waves.” Gotman&#39;s algorithm then compares properties of the half waves such as averages of amplitude, duration, rhythmicity, and sharpness in moving ⅓ sec. windows to those of past and future data segments. As currently implemented, the method uses a total of 30 seconds of past data and 8-10 seconds of future data in these comparisons. A set of rules and thresholds are given to determine when these comparisons of past, present, and future properties yield a detection of a spike or seizure. 
         [0028]    These rule-based methods have a number of limitations, including a large false positive rate, and usually a long delay to detect even abrupt changes (often 10 or more seconds). 
         [0029]    Another method for spike and seizure detection involves training an artificial neural network (ANN) using past data tracings with annotated spikes and seizures to “learn” to recognize similar changes in unseen data. The large number of “neurons” required for accurate analysis of a multichannel EEG/ECoG input signal precludes real-time analysis. Consequently, the current state of the art implementations rely on a smaller number of “neurons” and a parametrized input signal in place of the raw signal. The Gotman half-wave decomposition mentioned above is commonly used in this signal parametrization step—causing the inclusion of many of the limitations inherent in this method to adversely affect the ANN methods. In addition, the adaptation of an ANN to improve its performance for a particular individual or group is performed off-line and requires time consuming retraining by experienced epileptologists. This important limitation is overcome by the present invention. 
         [0030]    3. Glossary of Terms and Useful Definitions 
         [0031]    The onset of the clinical component of a seizure is the earlier of either (1) the time at which the subject is aware that a seizure is beginning (the “aura”), or (2) the time at which an observer recognizes a significant physical or behavioral change typical of a seizure. 
         [0032]    The onset of the electrographic component of a seizure is defined by the appearance of a class of signal changes recognized by electroencephalographers as characteristic of a seizure. This analysis requires visual review of signal tracings of varying duration, both before and after the perceived signal changes, using multiple channels of information and clinical correlates. The precise determination of the onset is subject to personal interpretation, and may vary based on the skill and attention level of the reviewer, the quality of data and its display. 
         [0033]    The electroencephalogram, or EEG, refers to voltage potentials recorded from the scalp. EEG will encompass any recordings outside the dura mater. The electrocorticogram, or ECoG, refers to voltage potentials recorded intracranially, e.g., directly from the cortex. EKG is the abbreviation for electrocardiogram, EMG for electromyogram (electrical muscle activity), and EOG for electrooculogram (eye movements). 
         [0034]    The period of time during which a seizure is occurring is called the ictal period. (Those skilled in the art will appreciate that the term ictal can be applied to phenomena other than seizures.) The period of time when the patient is not in the state of seizure, or in transition into or out of the seizure state, is known as the interictal period. The preictal period corresponds to the time of transition between the interictal and the beginning of the ictal period, and the postictal period corresponds to the time period between the end of the seizure and the beginning of the interictal period. 
         [0035]    Herein the term real-time describes a system with negligible latency between input and output. 
         [0036]    The term false positive refers to the case of a system mistakenly detecting a non-seizure signal and classifying it as a seizure. The term false negative describes the case in which a true seizure goes undetected by a system. Systems that have a low rate of false positive detections are called specific, while those with a low rate of false negative detections are called sensitive. 
         [0037]    The terms epileptiform discharge and spike are used interchangeably herein to refer to a class of sharply contoured waveforms, usually of relatively large power, and with duration rarely exceeding 200 msec. These spikes can form complexes with slow waves, and can occur in singlets or in multiplets. 
         [0038]    The terms epileptologist and electroencephalographer are used interchangeably. 
       SUMMARY OF THE INVENTION 
       [0039]    The present invention solves the problems and overcomes the limitations of prior art, while providing pioneering advances in the state of the art. Its preferred embodiment enables (1) the accurate, automated, real-time detection of seizures, as well as the determination of their site of origin, propagation path and speed through regions of the brain, and their duration and intensity; (2) the prediction of the onset of the clinical component of seizures; (3) the prediction of the onset of the electrographic component of seizures; (4) the online self-adaptation, or offline adaptation of (1-3) to each individual, (5) the automated use of (1-3) for diagnosis, quantitative analysis, imaging, warning, treatment, and storing of data; and (6) the miniaturization of the system to a portable or implantable device. 
         [0040]    The adaptation of the system to each individual takes into account, seizure type and location, and changes in the signal(s) over time, making use of any existing preictal, ictal, or postictal “fingerprints” for the subject. The speed of analysis and levels of sensitivity and specificity can also be adjusted to desired levels, and the method can be implemented in either digital or analog form (or a combination). 
         [0041]    The preferred embodiment of the invention uses intracranial or scalp electrodes to obtain signals representative of current brain activity and a signal processor such as a personal computer or micro-processor, for continuous monitoring and analysis of these signals, detecting important changes or the appearance of precursors predictive of an impending change, as soon as they occur. The output of this analysis is then fed to a device which produces an immediate response (e.g., warning, treatment or storage) to the change or predicted change in state. The signal processing includes an adaptive analysis of frequency, energy, wave shape and dynamics, phase relationships, measures of rhythmicity, “sequency,” and temporo-spatial stereotypia, variability, dimension, complexity of the signal, and noise reduction. 
       1. Methods for Real-Time Seizure Detection: 
       [0042]    The following is an overview of the steps which comprise the preferred embodiment of the invention for real-time seizure detection. 
         [0043]    (1) Extract from the entire signal the part with ictal characteristics. This step is accomplished with adaptive filtering, allowing the selection of patient- and/or sensor-specific initial parameters, and an adaptation process in which these filters automatically improve as important signal characteristics are learned online. 
         [0044]    (2) The output of this filter is used to compute an index of ictal activity in each current signal epoch (the “foreground”), which is then divided by a corresponding measure associated with the background signal, forming a ratio. Novel application of median filtering and time and state weighted averaging are used in this step. 
         [0045]    (3) When the value of this ratio reaches a particular threshold level, a seizure detection is immediately signaled. 
         [0046]    (4) Grading and verification of seizures is then accomplished using an analysis of duration, intensity, pattern recognition of spatio-temporal propagation, and postictal seizure signal changes. 
         [0047]    In addition, a new seizure imaging method has been developed based on the detection methodology presented here. 
       2. Methods for Detecting Precursors to Seizure: 
       [0048]    These embodiments detect the occurrence of signal characteristics or patterns which may be precursors to the clinical and/or electrographic components of seizure, resulting in their prediction. Determination of the onset of a seizure by visual analysis (which is considered “the gold standard”) is a subjective and empiric process, at the present level of scientific development. Determination of time of seizure onset depends in part upon the specifications and parameters associated with the recording devices and of the location and type of sensors in reference to the tissue from where the seizure originates. The intensity and degree of spread of the seizure also affects detection. 
         [0049]    From a practical standpoint, prediction based on the detection of seizure precursors or the electrographic component itself yield a worthwhile time during which warning and intervention can be instituted to abort or prevent the onset of either of the components of the seizure. By virtue of their self-tuning ability (detailed in a later section), the continued application of these prediction methods to a given individual or seizure type may improve the reliability of subsequent predictions, and may lengthen the predictively worthwhile time. 
         [0050]    Seizure precursors include, but are not limited to: 
         [0051]    (1) certain significant patterns of epileptiform discharges (or spikes), 
         [0052]    (2) significant abrupt attenuation of signal energy on some or all sensors, and 
         [0053]    (3) significant changes in various characteristics of the power spectral density associated with each of the signals that are being monitored, e.g., a sudden significant drop in the median frequency of a given signal. 
         [0054]    Prediction of seizures may occur during different stages of their temporal evolution: 
         [0055]    a) Prediction of the vibratory (or first) state, i.e., the state before the seizure spreads beyond the anatomical or functional boundaries of the “critical epileptogenic mass” (defined as the smallest mass that, once fully synchronized, consistently generates the next states). 
         [0056]    b) Prediction of the electrographic component of seizure. This component is mainly defined by temporal continuity of the ictal signal with or without evolution across a frequency spectrum and with some degree of propagation outside the critical mass. Prediction of this state can be made by identifying precursors (see examples). Precursors have temporal, spectral, and other characteristics which distinguish them from the electrographic component. 
         [0057]    c) Prediction of the clinical component of seizure. The real-time detection of the electrographic seizure component is akin, for partial or secondarily generalized seizures to the prediction of the clinical onset as there is a latency between the two components. Precursor detections further lengthen the predictive time of the clinical component. 
       3. A Method for Spike Detection, Classification, and Counting: 
       [0058]    The invention also includes a new method for measuring signal “sharpness,” which we refer to as least-squares acceleration filtering (LSA-filtering), that is used as the basis for a new spike detection method. It can also be used to improve existing spike detection methods. In this method, the signal is continuously monitored for the occurrence of such things as spikes, and their amplitude, frequency, waveform, “sequency” (degree or pattern of clustering), rate of occurrence, location, and polarity, are computed and stored. This information is then analyzed for conformance to any seizure precursor pattern. 
       4. Devices for the Detection of Seizures, Precursors, and Spikes, and for the Prediction of Seizures: 
       [0059]    The algorithms listed above and defined in detail herein can be realized in digital or analog form in a signal processor. The preferred embodiment has been implemented in an Intel 486 based PC for real-time monitoring and storage of data for patients undergoing clinical evaluation. 
         [0060]    The Real-Time Detection of: 
         [0061]    (a) seizure precursors and the resulting prediction of the electrographic and clinical seizure components, 
         [0062]    (b) the electrographic component and the resulting prediction of the clinical component, or 
         [0063]    (c) spikes, enables the institution of safety and therapeutic measures, and initiates or continues the adaptation and self-learning of the methods. For example, a seizure prediction can be used to trigger a device for systemic, intraventricular, or intracerebral administration of a medicament or substance, for electrical, magnetic, or thermal activation or deactivation of a nerve or a region of the subject&#39;s brain, for activation or deactivation of physiologic receptors, for ablation of a region of the subject&#39;s brain, for activation of a warning or biofeedback device, or for selection of segments of signals for transmission or storage (or for annotation of continuously recorded signals) and further off-line analysis. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWING FIGURES 
         [0064]      FIG. 1  is a schematic illustration of the preferred apparatus of the present invention showing inputs of brain (or other biologic system) signals of a subject from surface and/or implanted (e.g., intracranial) sensors to a signal processor and various types of outputs; 
           [0065]      FIG. 2  is a graphical illustration of the segments of data which may be used in one preferred seizure detection method for operating the apparatus of  FIG. 1  to represent current (“foreground”) signal activity (e.g., the most recent 2 seconds), and signal background activity (e.g., a segment of 20 or more seconds in length) delayed 1 second from the end of the foreground window; 
           [0066]      FIG. 3A  is a graphical illustration showing a finite impulse response (FIR) filter which may be used in the first step of the preferred embodiment for detecting seizures in the input signals to the apparatus of  FIG. 1 . 
           [0067]      FIG. 3B  is a graphical illustration showing the power spectral density (PSD) associated with the FIR filter of  FIG. 3A ; 
           [0068]      FIG. 4  is a graphical illustration of an ECoG signal used as an input to the apparatus of  FIG. 1 ; 
           [0069]      FIG. 5A  is a graphical illustration of the result of applying the generic FIR filter of  FIG. 3A  to the signal of  FIG. 4 , and squaring the output signal values in an embodiment of the invention; 
           [0070]      FIG. 5B  is a graphical illustration of the dimensionless ratio of a 1 second foreground median filter and a 20 second background delayed median filter applied to the squared, FIR-filtered signal shown in  FIG. 5A  in an embodiment of an invention; 
           [0071]      FIG. 6A  is a graphical illustration of the part of the ECoG signal from  FIG. 4  during which the clinical and electrographic seizure onset and subject activation of the event button occurred, and during which the apparatus of  FIG. 1  detected the seizure; 
           [0072]      FIG. 6B  is a graphical illustration of the output of the seizure detection embodiment as presented in  FIG. 5B  but restricting the time window to that time period corresponding to the signal of  FIG. 6A ; 
           [0073]      FIG. 7  is a graphical illustration of an embodiment for a seizure imaging method and apparatus applied to 16 simultaneous ECoG recordings containing a seizure event; 
           [0074]      FIG. 8A  is a graphical illustration of an ECoG signal which contains a number of epileptiform discharges; 
           [0075]      FIG. 8B  is a graphical illustration of the output of first step of the spike detection embodiment; potential spikes with sharpness as computed by LSA filtering) exceeding a given threshold and their respective polarity (up or down) are identified. 
           [0076]      FIG. 9  is a graphical illustration showing the power spectral, density (PSD) or the impulse response of the presently preferred IIR filter designed to be used in detection of the seizure precursor spikes as described in Example 1. 
           [0077]      FIG. 10  is a graphical illustration of an ECoG signal which contains a seizure precursor signal (the quasi-periodic epileptiform discharge precursor detailed in Example 1). In this Figure, the times of the electrographic onset of the seizure, the clinical onset of the seizure, and the time of detection of the seizure precursor using an embodiment of the invention are annotated; 
           [0078]      FIG. 11A  is a graphical illustration of an ECoG signal of a subject which contains a seizure precursor signal (the signal attenuation precursor detailed in Example 2); 
           [0079]      FIG. 11B  is a graphical illustration of the output of the precursor detection embodiment for this type of seizure precursor; 
           [0080]      FIG. 12A  shows the illustration of  FIG. 11A  with the time axis restricted to a smaller range of times which still include the detection time of the seizure precursor, and the times of the electrographic and clinical onsets for the seizure; 
           [0081]      FIG. 12B  shows the illustration of  FIG. 11B  with the time axis restricted to a smaller range of times which still include the detection time of the seizure precursor, and the times of the electrographic and clinical onsets for the seizure; 
           [0082]      FIG. 13A  is a graphical illustration of an ECoG signal of a subject which contains another seizure precursor signal (a rapid drop in median frequency, as detailed in Example 3). The times of the electrographic onset, the clinical onset, and the event button press by the subject are annotated; 
           [0083]      FIG. 13B  is a graphical illustration of the result of applying the embodiment of the invention for detection of this particular seizure precursor to the signal presented in  FIG. 13A . The electrographic and clinical seizure onsets, and the time of event button press are also annotated, as well as the time of precursor detection; 
           [0084]      FIG. 14A  is a graphical illustration of 4.27 sec. of ECoG signal data. 
           [0085]      FIG. 14B  is a graphical illustration of the power spectral density (PSD) of the signal in  FIG. 14A , showing the modal frequency, median frequency, and mean frequency of the signal; 
           [0086]      FIG. 15A  is a graphical illustration of 2 seconds of ECoG signal recorded from a subject during an interictal (non-seizure) period; and 
           [0087]      FIG. 15B  is a graphical illustration of the absolute value of wavelet coefficients from levels 1-4 obtained by applying the fast wavelet transform to the signal of  FIG. 14A . 
       
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
       [0088]      FIG. 1  illustrates the preferred apparatus  10  for receiving and analyzing signals representative of a subject&#39;s brain activity and for producing different types of outputs. Apparatus  10  includes signal processor  12 , inputs  14  and outputs  16 . Signal processor  12  is preferably a computer such as one with capabilities that meet or exceed those of an Intel 486-based computer having 33 MHz clockspeed and 8 MB of RAM. Those skilled in the art will appreciate that an appropriate digital signal processor can be used in place of the preferred computer, as could a custom-designed semi-conductor chip having the requisite capability, preferably configured for implantation or as a portable device. Signal processor  12  could also be an analog processor or an analog/digital combination. Appendix 1 is incorporated as part of the disclosure hereof and contains the presently preferred computer program for use by apparatus  10  and, in particular, signal processor  12 , and for implementing the preferred methods of the present invention as further described herein. 
         [0089]    Inputs  14  include EEG (or other type of scalp) signals obtained from a plurality of scalp sensors  18  transmitted through associated lines  22 , or ECoG signals obtained from implanted sensors  23  and transmitted through associated lines  24 . The input signals used in the development of this invention were amplified and converted from analog to digital form at a rate of 240 Hz with a dynamic range of [−300,300] μV and digital resolution of 0.59 μV (10 bits of precision per datum). This provides 144 Kb of data per minute, per channel. Those skilled in the art will appreciate that sampling may be performed at fixed or varying rates (higher or lower than 240 Hz) and precision (with more or less precision than 10 bits), using linear or nonlinear analog to digital conversion, and with constant or varying dynamic range (i.e., adjustable gain). Data acquisition may also be performed using adaptive sampling techniques, in which these sampling parameters vary over time and are determined by characteristics of the signal being sampled. Adaptive sampling techniques can be used to selectively enhance relevant signal characteristics and increase signal quality and resolution in certain frequency bands. 
         [0090]    Outputs  16  can trigger portable or implanted devices, electrodes  26  which may be intracranial or extracranial, or placed over or around a nerve  28 , a medicament injector or pump  32 , an audio or LED output or any other form of warning  34 , and auxiliary memory  36  for storing input signals and event data. Implanted electrodes  26  can be used for any form of activation or deactivation (e.g., electrical, thermal, etc.) of local or remote brain cells or for ablation of the epileptogenic tissue. Nerve stimulator  28  is preferably associated with the vagus nerve as such stimulation has been found to abate or prevent a seizure. Physiologic (or natural) stimulation to receptors (e.g., light to retinal receptors) can prevent or abate seizures and is the function of stimulator  30 . Injector  32  is preferably implanted for automated instantaneous release of the appropriate medicament (inclusive of any efficacious substance) for treating, preventing or abating a seizure. Memory  36  is provided to store signal and event data for archival and analysis purposes. 
         [0091]    As discussed further herein, the analysis performed in signal processor  12  can be customized for a particular patient to improve the detection of brain states and state transitions, and the prediction of changes in brain states. The customization of the signal processing can be based on the information stored in memory  36  via feedback of this information to signal processor  12 . For example, this information may be used to monitor efficacy of treatment and to optimize seizure/spike detection and prediction, and therapeutic or safety interventions. Those skilled in the art will also appreciate that memory  36  can be included as an integral part of signal processor  12 . 
         [0092]    Those skilled in the art will recognize that changes in cerebral state are highly correlated with changes in level and type of activity of other organ systems (e.g., heart, etc.) and as such these signals, may be useful for detection and prediction or validation of seizures or of other changes in brain state. The following signals (not annotated in  FIG. 1 ) may be used in conjunction with EEG and ECoG signals to further improve performance of the system: 
         [0093]    1) Non-electrical cerebral (global or regional) signals, such as concentrations of glucose, free radicals, metabolic by-products, neuro-transmitters, or other substances, or measurements of intracranial pressure, temperature, blood flow or indices of metabolic activity, etc., 
         [0094]    2) Cardiovascular signals such as heart rate, R-R interval and variability, etc., 
         [0095]    3) Respiratory signals such as tidal volume, peak-to-peak interval, etc., 
         [0096]    4) Electrodermal and other DC potentials, 
         [0097]    5) Signals representative of concentrations in the blood or other peripheral tissues of gases, substances, or chemicals such as lactic acid, etc., 
         [0098]    6) Signals representative of the level or type of activity of cranial or peripheral nerves (e.g. frequency and pattern of action potentials, etc.), 
         [0099]    7) Signals related to EMG activity, force, direction, and patterns of limb or body movements. 
       Real Time Seizure Detection 
       [0100]    Successful real-time detection of seizures depends on the ability of any method to rapidly and accurately distinguish the ictal from the non-ictal part of the signal. We begin with a detailed description of the generic method, then discuss additional features and modifications which are used to enhance its sensitivity and specificity by making it adaptive, i.e., allowing it to learn online. The preferred embodiment as detailed here is based on a sampling rate of 240 Hz with 10 bits of precision. However, there is a wide range of digitization techniques which may be used, together with the appropriate modifications to the algorithm&#39;s parameters.  FIG. 4  shows a 4 minute segment of ECoG signal which is used to illustrate a preferred embodiment for detecting the electrographic component of a seizure. 
         [0101]    The first step of the method consists of applying a filter to the signal to decompose the entire signal into its ictal and non-ictal components. As a result of research performed for this invention, identification of key differences between ictal and non-ictal signal characteristics was successfully accomplished. These results enabled the construction of filters to accomplish this first step of the method. These include “generic” digital filters of both finite impulse response (FIR) (also known as a convolution filter and moving average (MA) filter) or infinite impulse response (IIR). One such FIR filter is shown in  FIG. 3 , together with an estimate of its power spectral density (PSD). These filters could include analog filters as well and were constructed using a data base of over 100 seizures in the following manner: 
         [0102]    1) Each seizure was divided into segments according to its temporal evolution, and the PSD of each segment was computed; 
         [0103]    2) The resulting PSD&#39;s were then compared with PSD&#39;s obtained from interictal segments. Power-frequency envelopes were then computed, more heavily weighing the spectra at frequencies which yielded the greatest separation between the ictal and interictal PSD values. 
         [0104]    3) The orders and type (e.g. FIR or IIR) of the “generic” filters were then chosen, taking into account the trade off between computational bur-den/speed and goodness-of-fit of their impulse response to the desired shape. The filter coefficients were then computed from the desired impulse response using standard filter design methodology. 
         [0105]    Those skilled in the art are aware of the many degrees of freedom or options available in designing filters. For instance, the magnitude and phase specifications of the filter&#39;s impulse response may be adjusted to match the PSD characteristics of a set of seizures, or infinite impulse response (instead of FIR) filters may be used when speed of processing is the primary objective, especially if the filter must precisely discriminate between extremely low frequencies (e.g., less than 2 Hz.). Genetic algorithms provide a useful approach to solving the multi-dimensional constrained optimization problem of designing a best filter for a given set of data. 
         [0106]    For a given subject, a filter is initially selected from the filter bank. This selection can be done off-line by a clinician upon a study of archival wave forms. In the alternative, the selection can be completed on-line by applying all the filters in the filter bank individually to the input signals and selecting that filter that produces the greatest differentiation. 
         [0107]    If the input signal is given by {x j } j=1   n  and the FIR filter has m coefficients {b 0 , b 1 , . . . , b m−1 }, then the output (filtered) signal {Y j } j=1   n  is obtained from the formula 
         [0000]    
       
      
       Y 
       k+1 
       =b 
       0 
       x 
       k 
       +b 
       1 
       x 
       k−1 
       +b 
       2 
       x 
       k−2 
       + . . . +b 
       m−1 
       x 
       k−m+1  
      
     
         [0000]    where it is assumed that x j =0 f or all j&lt; 1. 
         [0108]    The output of this filter is then squared, and the evolution of the resulting Y k   2  values is monitored, comparing the most recent values (the “foreground”) to less recent values (the “background”), to detect relevant changes.  FIG. 5A  shows the graph of the Y k   2  values which result from the application of the FIR filter described above to the signal of  FIG. 4 , and then squaring the output. 
         [0109]    In the next step of the method, we shall refer to the present information as “foreground,” and compare it to the signal history or “background.” Once the raw signal has been filtered to extract and enhance its ictal part, the next step in the method is to use the {Y k   2 } sequence to create measures of the level of ictal activity in the most recent signal epoch, and compare it with that contained in the interictal signal. To compute a measure of ictal activity in the foreground, we apply a (nonlinear) median filter of order 480 (2 seconds) to the {Y k   2 } sequence, to obtain the sequence {F k } (240 values per second per channel), 
         [0000]        F   k =median{ Y   k−p+1   2   ,Y   k−p+2   2   , . . . ,Y   k−1   2   ,Y   k   2 } 
         [0000]    where p is the order of the median filter (e.g., p=480@240 Hz.). This step is used to monitor a change in central tendency of the distribution of the recent (foreground) Y k   2  values. The median (or other order-statistic is preferred for this step because of its ability to measure the central tendency of a distribution without being overly sensitive to outliers such as those which result from single or multiple spikes. 
         [0110]    To compute a measure of the ictal activity in the background, {B k }, which is used as a reference against which foreground changes are measured, we apply another median filter to the Y k   2 , values, with the following modifications: 
         [0111]    1. The order is increased (e.g., to 20 seconds, p=4800) to obtain a more stable background, 
         [0112]    2. The filter is delayed by a certain time (e.g., 1 second) from the current time to remove any possible effect of the most recent signal on the background value, B k , thus making a foreground change easier and faster to distinguish/detect, 
         [0113]    3. Updates of background, B k , are disabled during seizures or other anomalies (e.g., transient artifacts), and 
         [0114]    4. An exponentially forgetting time average (or a more general time- and state-weighted average) of this delayed median filter output is used to increase the period of signal history represented by the background sequence, {B k }, without increasing memory/storage requirements or computations. Use of this technique decreases the size and number of fluctuations in this background sequence, improving detection by allowing more sensitive thresholds to be set without significantly increasing false detections. Details regarding more general time- and state-weighted averaging techniques which may be employed in this step are presented in Appendix 2 which is incorporated as part of the disclosure hereof. 
         [0115]    To now be more precise, the background sequence, {B k }, is computed as follows. We begin by applying a delayed median filter of order h and delay d to the squared output of the FIR-filter, {Y k   2 } to obtain the output sequence, {W k } 
         [0000]        w   k =median{ Y   k−d−h+1   2   ,Y   k−d−h+2   2   , . . . ,Y   k−d−1   2   ,Y   k−d   2 } 
         [0000]    with, e.g., h=4800 (to use 20 seconds of data), and d=240+480=720 (i.e., this median filter is delayed 1 second from the end of the 2 sec. foreground window, i.e., 3 seconds from the current time), so that 
         [0000]        w   k =median{ Y   k−5519   2   , . . . ,Y   k−721   2   ,Y   k−720   2 } 
         [0000]    Then define 
         [0000]    
       
         
           
             
               B 
               
                 k 
                 + 
                 1 
               
             
             = 
             
               { 
               
                 
                   
                     
                       
                         λ 
                          
                         
                             
                         
                          
                         
                           B 
                           k 
                         
                       
                       + 
                       
                         
                           ( 
                           
                             1 
                             - 
                             λ 
                           
                           ) 
                         
                          
                         
                           w 
                           
                             k 
                             + 
                             1 
                           
                         
                       
                     
                   
                   
                     
                       
                         if 
                          
                         
                             
                         
                          
                         
                           r 
                           k 
                         
                       
                       &lt; 
                       
                         C 
                         2 
                       
                     
                   
                 
                 
                   
                     
                       B 
                       k 
                     
                   
                   
                     
                       
                         if 
                          
                         
                             
                         
                          
                         
                           r 
                           k 
                         
                       
                       ≥ 
                       
                         C 
                         2 
                       
                     
                   
                 
               
             
           
         
       
     
         [0000]    where λ is a “forgetting factor” which controls the rate of exponential forgetting (where this factor is between 0 and 1), r k  is the current ratio of the foreground “ictal index” to the background “ictal index,” given by 
         [0000]    
       
         
           
             
               r 
               k 
             
             = 
             
               
                 F 
                 k 
               
               
                 B 
                 k 
               
             
           
         
       
     
         [0000]    and C 2  is a threshold level used to disable updates of B k  when C 2  is exceeded by r k . For accurate, real-time detection of seizures, the ictal signal should not be allowed to affect the background signal from which the seizures are distinguished. Accordingly, to further improve the detection method, the constant, C 2 , above was introduced to disable updates of the background ictal index, B k , whenever the ratio, r k , is large (i.e., exceeding C 2 ). Failure to disable these updates would allow unwanted rapid growth in the background ictal index during a seizure, resulting in a loss of ability to measure seizure duration, and a degradation in the ability to detect latter seizures (or the regeneration of a single evolving seizure) when these events are closely spaced in time. This enhancement of the method is especially important when one wishes to detect the end (and hence the duration) of a seizure in addition to the onset time. 
         [0116]    A seizure detection is immediately signaled when the ratio, r k , exceeds C I , which is the detection threshold. When the foreground and background median filters are 1-2 sec, and 20 sec, respectively, nominal preferred values for the above defined constants are C 1 =20, C 2 =5, and λ=0.9997. Also note that because the ratio, r k , is dimensionless, the threshold may be set without regard for the units used in the particular signal being monitored.  FIGS. 5B and 6B  show the graph of this ratio, when the method is applied to the signal of  FIGS. 4 and 6A . In this example, the method detects the seizure 5 seconds prior to the electrographic onset (as determined independently by a trained epileptologist), 8 seconds prior to the clinical onset of the seizure (as determined by review of the videotape record by the same epileptologist), and 11 seconds prior to the patient&#39;s activation of an event button (signaling the beginning of the seizure according to the patient), as  FIG. 6B  illustrates. 
         [0117]    By varying the lengths of background and foreground, the accuracy and speed of detections may be adjusted to improve performance as desired for a particular application of the method. The preferred embodiment constitutes a substantial improvement in the state of the art in both speed and accuracy of detection. In addition, the adaptability of the system&#39;s parameters provide flexibility and improved performance for a variety of applications. For example, if the speed, but not the accuracy of detection is the overriding factor for success in seizure abortion, then a decrease in the foreground window length is one way to achieve this result. If, on the other hand, this method is to be used in a device to destroy the part of the brain from where the seizures originate, then maximal accuracy (and not detection speed) is needed to avoid damaging healthy tissue. This can be accomplished by increasing the length of the foreground window. 
         [0118]    The novel use of order-statistic filtering in this invention and, specifically, a median filter, to characterize the ictal activity in the foreground significantly improved the accuracy of seizure detection by enabling discrimination between ictally organized and non-organized epileptiform activity. The further additions of time- and state-weighted averaging, and the formation of a ratio comparing the level of ictal activity in the recent signal (foreground) to that which is normally present during interictal (non-seizure/background) periods, among other ideas (described below) have enabled the present invention to provide improved results not only in speed, but also in accuracy and adaptability. Additionally, the method allows for online learning and adaptation as discussed in later sections. 
         [0119]    As the signal from each individual sensor is monitored in the aforementioned manner for the detection of seizures, spatio-temporal correlations between the ratios simultaneously computed for multiple sensors which may be obtaining signals of the same class (e.g., all ECoG), or different classes (e.g., ECoG, EKG, and blood chemistry) can then be used, if necessary, to increase sensitivity and specificity of the algorithm, e.g., by allowing for sensor and signal dependent threshold settings and the use of multi-channel information in both seizure detection and artifact rejection. Those skilled in the art recognize that external sensors produce a lower signal to noise ratio than implanted sensors. This drawback is particularly prominent for sensors placed on the scalp for EEG monitoring due to volume conduction and low-pass filter effects on the cortical signal caused by the structures surrounding the brain. Furthermore, the signal recorded from the scalp may be delayed from that directly recorded from the brain. In order to compensate for these drawbacks, the following strategies have been adopted (individually, or in combination): 
         [0120]    1) Prefiltering of the scalp signal and other inputs to extract the useful signals (e.g., separate cortical voltage potentials from artifacts). 
         [0121]    2) Artifact pattern recognition. Artifacts, defined as signals that are not the direct product of cortical neuronal activity occur during normal activity and also during seizures. During their clinical component, seizures generate a host of artifact signals that, for a given individual, may be highly stereotypical in their spectral and spatio-temporal characteristics and as such are distinguishable from cortical seizure activity. These artifacts, which correspond to body, mouth, or eye movements, etc., are first recognized by comparison with artifacts that have been catalogued into a general library according to their characteristics. As these artifacts are identified, their temporal evolution is tested for conformance to a pattern of artifacts stereotypic of that individual&#39;s seizures. 
         [0122]    3) Use of other signals such as EKG, respiratory rate, magnetic fields, thermic potentials, concentrations of chemicals, recordings from a dynamometer or accelerometer attached to the patient or bed, etc. for use in seizure detection or prediction. 
         [0123]    Once a seizure has ended, there is usually a decrease in signal power in certain frequency bands. This decrease is dependent upon the intensity and duration of the seizure, among other factors. The method/device tests for and measures the duration of any loss of power following a large increase (such as that which occurs with seizures), and the results of these tests are used to retrospectively assess the accuracy of seizure detection. For instance, a large sustained increase in power, without a subsequent power decrease in certain bands, would be routinely subjected to off-line review. 
       The Adaptive and Evolutionary Nature of the Method 
       [0124]    Large scale validation studies have proven that the above-detailed embodiment for seizure detection is both highly sensitive and specific. However, to account for possible intra- or inter-individual signal variability, and to further improve performance as needed, a number of additional steps have been implemented which allow the system to learn and adapt on and offline. These steps can be grouped into the following categories: 
         [0125]    (1) adaptive signal acquisition methods, 
         [0126]    (2) intelligent parameter adjustment, and 
         [0127]    (3) adaptive use of detection and prediction information. 
         [0128]    The first step in adapting the method to a particular subject or application consists of selecting the appropriate set of signals to be monitored, and controlling the manner in which these signals are acquired. Although the detailed example above makes use of signals consisting of electrical potentials (EEG/ECoG) sampled at 240 Hz and digitized with 10 bits of precision, in some cases one may, as discussed earlier, vary the analog to digital conversion parameters, or use the analog signal itself, in order to ascertain various characteristics of the signal which may be important in the subsequent analysis. For example, sampling rate may vary continuously with the frequency content of the signal, increasing with the slope of the wave (differential sampling); the steeper the slope, the higher the sampling rate. In addition, online signal quality control methods can be used to detect various forms of signal degradation and warn the user or others. For example, the system can produce an output indicating the presence of a large quantity of 60 Hz activity, or abnormally high “clipping” in the analog to digital conversions, etc. Moreover, in many cases it is advantageous to record signals from other sites (or organs) in addition to the brain or its encasing structures, and to analyze biological signals other than EEG/ECoG, including, but not limited to, (1) other electrical potentials (AC or DC), (2) EKG, (3) EMG, (4) respiratory rate, (4) concentrations of glucose, free radicals, or other substances (e.g., neurotransmitters) in the brain, blood or other tissues, (5) magnetic fields, and (6) brain temperature. It is also important to note that while, for the sake of clarity, attention is primarily focused on data from a single sensor in the detailed example above, in practice the method can be applied to signals from a large number of individual sensors and combinations of sensors (e.g., a weighted sum of the electrical potentials between a given sensor and all other sensors) simultaneously (i.e., in parallel), monitoring spatio-temporal correlations of the resulting outputs. 
         [0129]    The parameters of the method may be adjusted as needed. Parameters such as foreground and background window length, filter shape and type, time-weight, and threshold settings may be adapted on or offline to the particular subject and application. For example, if data exists containing a prior seizure for a given subject, then one can process this data to realize a filter adapted to any known signal characteristics or seizure “fingerprint” of that subject. A filter with the spectral characteristics of its impulse response matching the typical PSD at seizure onset for this subject, can be used to initialize the adaptive filtering procedure, thereby improving the sensitivity and specificity of the algorithm for that subject. The FIR filter may also be adapted to the particular location of the sensor, or the type of signal being monitored. For example, when monitoring posterior electrodes (e.g. occipital), the preferred filter is designed to recognize and de-emphasize irrelevant signals in the alpha range (8-13 Hz with normal reactivity), when its power is below a given percentile. While spectral characteristics of seizures for a given subject may differ from those analyzed for the design of the generic filter, this method, by virtue of its adaptability, is well suited to prediction and detection of seizure patterns with a wide range of spectral and other relevant characteristics. 
         [0130]    To increase computational efficiency, one may also use a stable infinite impulse response (IIR) filter (also known as an auto-regressive moving-average or “ARMA” filter) in place of the FIR filter. Such filters use a linear combination of past filtered signal values in addition to present and past input signal values to compute each new filtered signal value. That is, given IIR filter coefficients 
         [0000]    A=[a 1  a 2  a 3  a 4  a n ], and B=[b 1  b 2  b 3  . . . b m ], and input signal {x 1 , x 2 , . . . , x N }, we compute the sequence {Y N } using the recursive formula: 
         [0000]    
       
      
       Y 
       N 
       =−a 
       1 
       Y 
       N−1 
       −a 
       2 
       Y 
       N−2 
       − . . . −a 
       n 
       Y 
       N−1 
       +b 
       1 
       x 
       N−1 
       + . . . b 
       m 
       x 
       N−m  
      
     
         [0000]    This feedback of the filtered signal allows the HR-filtered output to be produced with fewer computations and shorter delay time. 
         [0131]    The FIR filter step utilized in the preferred embodiment example is a special case of more general adaptive filtering methods which may be employed to decompose the signal, extracting and enhancing signal activity indicative of an ongoing or impending change of brain state. For example, one may allow the FIR filter coefficients (and order) mentioned above to vary with time as a function of the current brain state, to increase the accuracy of the method under certain conditions. The method can use a different filter when the subject is in slow-wave sleep, from that which is used during vigorous exercise, since the characteristics of the background signal and noise level/type, from which a change is detected, are markedly different in these two states. Those skilled in the art are aware of many known methods of digital signal processing which can be used to achieve such online adaptation (e.g., “active noise cancellation”). In the presently preferred implementation, one begins with a generic filter (as above), that allows for the detection of seizures which may begin in a wide range of frequency bands. As the input signal evolves over time in the non-seizure state, windowed power spectral density (PSD) estimates of the signal can be successively computed, and a PSD representative of the recent (or entire) signal history may be obtained, together with confidence intervals, a median, min, max, and other percentiles, etc. This representative PSD is then used to modify the current filter&#39;s impulse response, in accordance with the newly acquired subject-specific and state-representative “background” information to improve detection of subsequent state changes. Interictal PSD&#39;s which do not fit any predetermined ictal pattern, but which are sufficiently different from the background PSD, may be archived and reviewed; these and parameters which may be computed from the PSD (see Appendix 2), may be used as templates for detecting other state changes, precursors to state transitions, and for signal quality control. Archived seizure segments can also be used in the online adaptation of this filter, focusing attention on the frequency bands of past seizures which are maximally differentiated from their respective interictal segments. Those skilled in the art will further recognize that several methods exist for online filter design from a given PSD, e.g., the method of Parks-McClelland. In addition to filters whose design is mainly based on the PDS, phase, shape and other characteristics (e.g., neurally-based filters or other signal-shape filters) can be used to realize new filters as necessary. 
         [0132]    Parameters can be adjusted in this method, to detect ictal activity on a wide range of time scales and sensitivities. In particular, by reducing the length of the foreground window from the 2 second length used above to 0.2 seconds, individual spikes can be detected with this method. The detection of these spikes as they occur enables the creation of a biofeedback system in which the subjects are made immediately aware of epileptiform activity in their brain (e.g., by an auditory transduction of the abnormal signal activity for auditory pattern recognition). Such a system can be used to teach the subjects to control or eliminate their abnormal own discharges. 
         [0133]    The thresholds, C 1  and C 2 , can also be adjusted online, based on accumulated statistics and functionals of the computed ratios, {r k }, over long time periods, including the ratio values attained during seizures, together with the maximum and minimum values reached interictally. 
         [0134]    Finally, the ways in which the system uses detection and prediction information can be made adaptive as well. For example, a warning alarm could have a feedback mechanism to detect background noise, and adjust its output signal accordingly—from a vibration when in the library to a loud tone when on an airport runway. As another example, changes in stimulation parameters for intervention or seizure abortion can be made based on a history of therapeutic effectiveness. 
       Other Embodiments of the Seizure Detection Method 
       [0135]    The task of seizure detection requires near-simultaneous temporal-frequency localization of the signal. Real-time seizure detection imposes the additional demand of high processing speed. 
         [0136]    The use of adaptive filtering in the preferred embodiment is ideally suited to meet these demands. Those skilled in the art will appreciate that a variety of other methods can be used for nearly-simultaneous temporal-frequency localization, including the windowed Fourier (or Gabor) transform (WFFT), the wavelet transform, the Hartley transform, and the Wigner-Ville transform. Any of these methods can be used to extract or enhance the ictal part of the signal from the entire signal as in the first step of the adaptive filtering method. 
         [0137]    In addition, a number of other transforms can be used to accurately and rapidly extract and enhance the ictal portion of the signal. We give two examples:
       1. Windowed correlation integrals: Embed the original (windowed) signal in a higher-dimensional space using the method of time-delays, a standard technique in nonlinear dynamics and statistics. Then count the number of pairs of points whose separation is less than some critical distance (this is called the sample correlation integral). Monitor this statistic as a function of time. Ictal activity is indicated when the number of such pair falls by an order of magnitude or more. Higher order correlations can also be used.   2. The windowed “kinetic energy,” defined as follows: take the first difference of the time series represented by the signal, re-embed this derived time series with a suitable lag time, then choose a window size (time interval); in each window, and compute for each window the sum of the squared lengths of all the vectors, and monitor this statistic as a function of time.       
 
         [0140]    Both methods are robust against changes in the control parameters such as embedding dimension, delay time, and window length. In particular, both have been effectively employed with short window lengths and embedding dimensions as low as 3, enabling real-time monitoring, detection and prediction. Both of these methods measure what might be characterized as a relative dispersion, at a certain scale, of the points on the re-embedded trajectory. As such, they are remarkably insensitive to small fluctuations in the position of the points, which in turn means that these methods are extremely robust against the contamination of the signal by noise. For example, using method 1, only a slight decrease in sensitivity occurs when the signal is contaminated by sufficient Gaussian noise to reduce the signal-to-noise ratio to 5 dB. 
         [0141]    It should be noted that the transforms listed in this section are also useful for preprocessing signals when little is known a priori about the frequency bands of interest or the time scale of changes. In particular, these methods can be used as initial screening tools in determining frequency bands in which changes are correlated with particular changes in brain state. Additional background details regarding the Fourier and wavelet methods may be found in Appendix 2. 
         [0142]    Coherence analysis, and higher order spectra and cumulants, etc., also provide additional important information regarding signal frequency changes over time. 
         [0143]    The presently preferred computer program for seizure detection shown in Appendix 1 performs on-line median filtering, updating the moving foreground and background median filters at 240 Hz. For this task, the program makes use of circular doubly-linked lists. For certain applications (e.g., to conserve processing resources when a large number of signals are being monitored simultaneously), these computations may be performed less often using well known batch sorting algorithms (e.g., Quicksort), to compute the median in moving windows. One may also replace the median filter by a similar order-statistic filter, or with some other measure of central tendency (e.g., α-trimmed means). For computation of the background index described above in the case when a very large background window is desirable, one may instead compute the sequence, {B k } using the exponentially forgetting average of the median of periodically sampled foreground values. For example, the background value can be updated once per second by first computing the median of the foreground values that occurred at each of the last 300 seconds, then adding this result (properly weighted), to the previous background value. 
         [0144]    Another preferred embodiment of the above methodology consists of the analog implementation of the digital methods described herein. Those skilled in the art will appreciate that every step of the method presented herein can be implemented in analog. This fact is important in the context of miniaturization and the development of implantable devices, since analog devices generally require significantly less battery power to operate and, thus, last much longer. 
       An Application of the Seizure Detection Method to Imaging 
       [0145]    The seizure detection method applied to a signal recorded from a particular sensor produces a dimensionless ratio representing the current level of ictal activity present at that corresponding location. As part of the present invention, a new “seizure imaging” method was developed based on this seizure detection methodology. The seizure image is obtained using a contour plot of the brain regions which achieve the same seizure ratio (“equiictal”), and tracking the temporal and spatial evolution of this ratio; the contours are directly obtained by interpolating these ratios over both space and time. 
         [0146]      FIG. 7  illustrates the application of this seizure imaging method to a seizure recorded simultaneously from two implanted needles each containing 8 contacts. Contacts 1-8 recorded activity from the left, and contacts 9-16 recorded activity from the right amygdalo-hippocampal regions. The times of seizure detection (solid line, 107 sec. after an arbitrary initial zero time), electrographic onset (dashed line, 112 sec.), clinical onset (dot-dashed line, 115 sec), and event button press (dotted line, 118 sec.), are annotated. This graph illustrates that the seizure originates from contact 12, then weakens somewhat, followed by a more widespread resurgence at neighboring contacts, first in those more anterior (9-11), and then later involving the more posterior right temporal contacts (13,14). The onset of activity in the left hemisphere begins at 156 sec. on contact 4, but then spreads to contacts 1-3, and 5 within 3 sec, and to the posterior contacts 6-8 four seconds later. Ictal activity on the left is evident for 15 seconds after the cessation of right temporal involvement. This particular imaging technique can be very helpful to the clinician in spatio-temporal localization of seizure activity and, in particular, in localization of the site of origin of the seizure and characterization of the pattern of spread. 
         [0147]    It has been found as part of the present invention, through the application of this seizure imaging method, that seizures from the same subject usually have a high degree of spatio-temporal congruency of ratio intensity. Accordingly, such images and the pathways of ictal propagation which they depict, can be used in the analysis of spatial correlations in the outputs of the simultaneously evolving, single-channel detection ratios computed as described in the preferred embodiment of the method. Specifically, any detected seizure may be compared in terms of its spatial evolution, propagation speed, and intensity evolution (including, e.g., the trajectory of maximal absolute and relative intensities), with similar information from prior ictal events, and the degree of conformance can be quantified and used in assessing whether (a) the detection was a seizure, or (b) seizures originate from one or multiple sites. These methods may also allow therapeutic intervention at the sites to where the seizure spreads, when treatment at the site of origin is of limited efficacy. 
         [0148]    Those skilled in the art will appreciate that other quantities computed from the input signals (not just the above-mentioned ratios) can have their spatio-temporal evolution depicted via similar imaging techniques, and that a variety of different existing interpolation techniques may be employed. 
       A Method for Detection of Epileptiform Discharges or Spikes 
       [0149]    The method described herein for detection and classification of spikes, is based on a new method developed as part of this invention for computing relative sharpness of the signal as it evolves, and comparing it to the sharpness of other waveforms. In prior art methods, the sharpness is computed at each successive signal maximum or minimum using the numerical second derivative at that point, or by connecting adjacent signal minima and maxima with straight lines and measuring the resulting angles. These approaches, however, are inaccurate because they ignore signal characteristics near each peak, and rely too heavily on a small number of digital points approximating the underlying continuous signal, using too few points near the peak (the region of primary interest) and too many points far away from the peak. The present invention includes a new method for computing this sharpness using what we shall call a “least-squares acceleration filter” (LSA filter), which overcomes these limitations of prior art. This method can be used independently, or as an improvement to existing methods, many of which rely heavily on relative signal sharpness in their detection of spikes. 
         [0150]    This method consists of first fitting a function to the data surrounding the point at which the sharpness is to be computed, and then determining the sharpness of the fitted function. The preferred function for use in this fit is a parabola, and the preferred criterion for the fit is the minimization of mean-squared error of fit (least squares). The parabola is used because its second derivative can be obtained from the computation of a single value (its leading coefficient), and no function evaluations (which can be computationally expensive) are necessary. Other performance criteria for an optimal fit could also be used. The choice of least squares is relatively standard, highly effective, and has been made computationally feasible here. 
         [0151]    The computation of the sharpness (i.e., the acceleration) of the signal(s) at each data point has been reduced to applying a small order FIR filter to the data from that sensor. The output of this filter is equivalent to first computing the parabola which attains the optimal fit (in the least squares sense) to the data near the point in question, then computing the second derivative of this parabola, which is used as a measure of sharpness. 
         [0152]    One may then obtain an index ratio of relative sharpness at a particular point in the signal by dividing this computed peak sharpness by, e.g., the median sharpness of all waves occurring in a moving background window of the signal. If the absolute value of the resulting dimensionless relative sharpness exceeds a given threshold, C 3 , then the wave is classified as a potential spike. The preferred nominal value for C 3  is 50, but may be adjusted as needed. When a potential spike is detected, the polarity of the discharge may then be obtained from the sign of the computed acceleration. 
         [0153]      FIG. 8  shows a 10 second segment of the ECoG signal containing a number of spikes, along with the resulting detections (and their respective polarities) made using this method. Now spatio-temporal correlations may be used to (a) reject artifacts, (b) group detected “spikes” into complexes, and (c) detect the occurrence of discharge patterns which may serve as precursors to seizure. Source code useful in accordance with the present invention is included in the microfiche appendix. Those skilled in the art will appreciate that genetic algorithms alone or in conjunction with neural network or fuzzy logic may be effectively used to analyze the spatio-temporal correlations of detected potential “spikes” for artifact rejection. 
       Prediction of Seizures Through the Detection of Precursors 
       [0154]    It has been found as part of the present invention that many patients have precursor signals that consistently precede the onset of both the electrographic and clinical components of their seizures. Three examples described below illustrate such precursors, present detailed methods for detecting them in real-time, and demonstrate their utility in seizure prediction. 
       Example 1 
       [0155]    Often subjects have an onset of large energy, primarily low frequency, quasi-periodic epileptiform discharges which occur seconds to minutes prior to the electrographic component of a seizure. Such patterns are rare to non-existent in the interictal state. The following is a description of how the present invention may detect the occurrence of such a precursor: 
         [0156]    First, a linear combination of the signals from relevant sensors is formed in a manner that enables the preservation of the polarity of each discharge so that there is no cancellation through superposition of waves. Then a filter designed to extract precursor spikes with patient-individualized shape is applied to this composite signal. A generic choice of filter for use in this step (when the signal is sampled at 240 Hz), is an IIR filter with PSD as shown in  FIG. 9 . This filter was designed using a data base of these precursor signals from various patients in a manner similar to that described earlier for the generic seizure detection filter. An IIR filter is preferred here instead of an FIR filter because of its advantages in filtering into such low frequency bands as that required here. The output of this filter is then squared, and, as in the seizure detection method, a background signal is computed by applying a 20 second median filter to these squared values, and then exponentially forgetting (slowly) the result. The relevant spikes are then identified by detecting the instant that the ratio of the current filtered signal (squared) divided by the background signal value exceeds a threshold value, C 4 . Since these spikes are now individually detected, the method then tests for their occurrence in a particular rhythmic manner which is highly correlated with a later onset of the electrographic and then clinical components of seizure. Specifically, we impose “periodicity constraints” which test if there is at least t 1  seconds and at most t 2  seconds between spikes, and that at least N spikes occur in succession according to these spacings before a detection is signaled. The preferred nonadaptive settings of the above constants are C 4 =100, t 1 =1, t 2 =10, and N=2. Each of these parameters (and the filter employed) can be adapted to patterns which may known a priori, or learned on-line for a particular subject via retrospective analysis of previously detected seizures. 
         [0157]      FIG. 10  presents a graph of an ECoG segment recorded from one of the subjects that exhibits this particular precursor, and the time of precursor detection using this method is annotated, along with the onset times of the electrographic and clinical components of the seizure. This method has produced a prediction of clinical onset an average of 54 seconds prior to its occurrence, and a prediction of electrographic onset an average of 42 seconds prior to its occurrence. The detection of this precursor has been followed by a seizure within two minutes in 100% of cases analyzed to date. 
       Example 2 
       [0158]    As part of the present invention, it has been found that signal attenuation or “quieting” precedes, by up to tens of seconds, the onset of the clinical and electrographic components of seizure in many subjects. In those that exhibit this preictal quieting, the application of the following preferred method to detect the onset of this attenuation results in a prediction of the electrographic and clinical seizure components. 
         [0159]    For any signal {X t , t≧0} the average signal energy over the interval of time t 1 ≦t≦t 2  is given by 
         [0000]    
       
         
           
             
               A 
                
               
                 ( 
                 
                   
                     t 
                     1 
                   
                   , 
                   
                     t 
                     2 
                   
                 
                 ) 
               
             
             = 
             
               
                 1 
                 
                   
                     t 
                     2 
                   
                   - 
                   
                     t 
                     1 
                   
                 
               
                
               
                 
                   ∫ 
                   
                     t 
                     1 
                   
                   
                     t 
                     2 
                   
                 
                  
                 
                   
                     X 
                     s 
                     2 
                   
                    
                   
                       
                   
                    
                   
                      
                     s 
                   
                 
               
             
           
         
       
     
         [0000]    The average signal energy, E t , in a moving time window of length T seconds is given by 
         [0000]    
       
         
           
             
               E 
               t 
             
             = 
             
               
                 A 
                  
                 
                   ( 
                   
                     
                       t 
                       - 
                       T 
                     
                     , 
                     t 
                   
                   ) 
                 
               
               = 
               
                 
                   1 
                   T 
                 
                  
                 
                   
                     ∫ 
                     
                       t 
                       - 
                       T 
                     
                     t 
                   
                    
                   
                     
                       X 
                       s 
                       2 
                     
                      
                     
                         
                     
                      
                     
                        
                       s 
                     
                   
                 
               
             
           
         
       
     
         [0000]    which can be computed recursively and efficiently online using the formula 
         [0000]        E   t+Δt   =E   t   +A ( t,t+Δt )− A ( t−T,t+Δt−T ) 
         [0000]      or 
         [0000]        E   t+Δt   =E   t +( X   t+Δt   2   −X   t−T   2 )/Δ t    
         [0000]    The long-time average energy, H t  used as an adaptive background value against which energy changes are measured, is given (recursively) by 
         [0000]        H   t+Δt   =λH   t +(1−λ) E   t+Δt    
         [0000]    with the preferred value of lambda being slightly less than 1. The above recursions can be initialized using the formulae: 
         [0000]        E   T =∫ 0   T × s   2   ds , H t =E T    
         [0000]    Now a ratio, R t , is computed as 
         [0000]    
       
         
           
             
               R 
               t 
             
             = 
             
               
                 [ 
                 
                   
                     E 
                     t 
                   
                   
                     H 
                     t 
                   
                 
                 ] 
               
               
                 - 
                 1 
               
             
           
         
       
     
         [0000]    and a precursor detection is made the instant that this ratio exceeds a threshold value C 5 . Note that an increase in this ratio corresponds to a decrease in average signal energy. Preferred nominal values for the parameters in this method are T=5, and C 5 =5, but these again may be adapted to particular subjects. This method has produced a prediction of clinical onset an average of 23 seconds prior to its occurrence. 
         [0160]      FIGS. 11 and 12  present a graph of an ECoG segment recorded from a subject that exhibits this particular precursor, and indicates when the detection is made using this method relative to the clinical and electrographic onset times of the seizure. The detection is made on the graph 278 seconds after an arbitrary zero, which is 15 seconds prior to the independently determined electrographic onset, and 19 seconds prior to the time of clinical seizure onset. 
       Example 3 
       [0161]    It has been found as part of the present invention that, for some subjects, certain sudden changes in the power spectral density (PSD) of the signal may be used to predict an impending seizure onset. For example, a sudden significant drop in the median frequency of the signal (defined in Appendix 2) is a consistent precursor to seizure for some subjects. The following is a description of the preferred method for detecting the occurrence of such a precursor: 
         [0162]    Begin by computing the median frequency of the particular signal of interest in moving windows of length T 1  (as described in Appendix 2). Compute a background median frequency using an average of the median frequency values in a moving window of length T 2 . Then compute the ratio of the background median frequency divided by the median frequency in the current T 1  second window. If this ratio exceeds a threshold value C 6 , a detection of this precursor is immediately signaled. The preferred nominal/non-adaptive choices of parameters are T 1 =256/240 sec. (approx. 1.067 sec.), T 2 =60 sec., and C 6 =5. 
         [0163]      FIG. 13A  shows a 5 minute segment of ECoG data which contains a seizure in the last minute. The times of electrographic and clinical seizure onset, and the time at which the event button was pressed are annotated (dashed, dash-dot, and dotted lines, respectively).  FIG. 136  shows the graph of the ratio described above over this 5 minute segment, with a detection occurring 12 seconds prior to the electrographic onset, 15 seconds prior to the clinical onset, and 18 seconds prior to the patient&#39;s pressing of the event button. In the example used in  FIG. 13 , it should be noted that there is some signal energy attenuation as well (the precursor described in the previous example), but that this is not used in the detection of the precursor described now. 
         [0164]    Other precursors which may be relevant for predicting an impending seizure for a particular subject or group can be isolated using modern pattern recognition techniques. As mentioned previously, preictal or interictal patterns which are present in the output of our seizure imaging method (which uses spatio-temporal interpolation of the ratios or other relevant quantities computed at each sensor) are strong candidates for precursors. 
         [0165]    Another useful method for determining precursor signals for a given subject or group makes use of waveform classification and cluster analysis, followed by pattern recognition techniques applied to the resulting sequence of waveform “labels.” The following illustrates how this can be done. One begins by segmenting an arriving input signal into individual “waves.” This can be done in a variety of ways, for example, one could define a wave as 512 consecutive data points, or, more adaptively, as the number of data points between 2 successive baseline crossings of the signal. As each new waveform is segmented, it can be extensively analyzed and subsequently classified into a (possibly evolving) library of distinct waveforms or “cyma.” 
         [0166]    For example, the duration, amplitude, number of baseline crossings, arclength, maximal sharpness, number of local maxima and minima, area bounded between the waveform and a horizontal axis, total power, and the fraction of power in a particular frequency band (and any number of other quantities) could each be computed (and, if desired, statistically normalized), with the resulting n measures used to form a vector in n-dimensional space quantifying that particular waveform (in this example, n=9). The distances (either Euclidean or non-Euclidean) between this new “point” in n-dimensional space and a library list of other “points” can then be computed and analyzed to see which waveform or “cymeme” in the library most closely resembles the new waveform. In this way, the input signal can be labeled as a sequence of cymemes (or indices into a list of waveforms), and the resulting “cyma” can be analyzed as described above for the occurrence of patterns which may serve as precursors to a given change of state. Such waveform lists can be constructed from available data using currently known methods of cluster analysis, and neural networks can be employed in making online or offline decisions classifying a given waveform. Specifically, we have successfully used a competitive learning network trained with the Kohonen learning rule and an adaptive learning rate which decreases over time for this task of classifying the sequence of n-dimensional points into groups. These analyses can be performed consecutively where, in each step, a different analysis method can be used. 
       Correlation Detection and Automatic Precursor Identification and Isolation 
       [0167]    This section describes the preferred methods for automatic identification of signal characteristics which are significantly correlated with later changes of state in this subject&#39;s brain. This is based on correlational analysis and pattern recognition techniques applied to the signal recorded prior to each change of state. The transformations which apply to a given input signal or set of signals (e.g., FIR filtering, fast wavelet and Fourier transforms, etc.) decompose the input and present its information content in an organized and useable form. The original signal, and the product of these transformations are then automatically analyzed for the occurrence of patterns significantly correlated with detected changes of state. 
         [0168]    Signal analysis for correlation may occur on-line, or off-line from signals previously recorded and stored in memory. Further, the analysis can be done on the basis of predetermined patterns or patterns developed through correlation analysis, or both. One may select the segments of signal for analysis which precede these changes of state with “markers” in some externally controlled way, or one may simply let the software accumulate correlations between “major changes” and precursors in an inclusive fashion for eventual use. It is also important to note that the process can either be done off-line using data obtained from the subject or putative patterns, or on-line by automated systems installed as part of the device. 
         [0169]    The following is an example describing the use of correlations for determining average signal power. Let b ik  be the I th  time coefficient in the k th  wavelet basis expansion (see next section for more details), using a fundamental wavelet time scale dt. Let the average value of b ik  over an interval, chosen for illustration to be one minute, be denoted &lt;b k (t)&gt;. This is an average over roughly I max =2 −k/dt  values of I. The interval begins one minute prior to time t. Let &lt;p(t)&gt; be the average power in the signal over the same time interval, and &lt;p&gt; be the average power over many previous intervals, such as 100. Form the running deviation of coefficients from the average, b ik −&lt;b k (t)&gt;. 
         [0170]    Form the running deviation of the power from its long term average, &lt;p(t)&gt;−&lt;p&gt;. A correlation matrix C lt (k) is formed by multiplying 
         [0000]        C   lt ( k )=(&lt; p ( t )&gt;−&lt; p &gt;)( b   lk   −&lt;b   k ( t )&gt;) 
         [0171]    This matrix depends on the level, k, the time step within the interval, I, and the interval start time t. If there is no correlation between the signal and the power in a particular level k, then the matrix for that k value will be a random variable in the index I. If a persistent correlation begins at time t+I*dt, at some level k*, then the product will rise at point I* and stay large, up to statistical fluctuations. 
         [0172]    Applying this procedure over many intervals of “normal” or background state, typical values of C lt (k) will be fairly independent of I and t, and only depend on the level k. Distributions of these values are formed and evaluated. When C lt (k) rises well above a statistically likely value it represents a correlation between b lk  and the power, &lt;p(t)&gt;, in that interval. In one application, restricting the analysis first to intervals marked t* where &lt;p(t*)&gt; rises well above the background, one identifies the region of the seizure. Only the C lt (k) values for the immediately preceding interval need to be kept in this case. Then by examining the correlations C lt .(k) as a function of level k and time I, the level or levels k* where large correlations occur for I&gt;I* can be determined automatically. The time for the precursor to predict in advance the seizure is found by computing (I max −I*)dt. These values of k* and I* can be output and stored, leading to automatic recognition of precursors. 
         [0173]    Another similar method is to train any assembly consisting of a number of logic elements with connected threshold rules (such as a neural network) to recognize correlations between the precursor signals, and the macroscopic change of state. In this case the correlations between precursors and state change may be automatically registered and analyzed without the intermediate step of forming correlation matrices. 
         [0174]    The same technique can be applied to linear combinations of the signal after application of various signal filters, e.g., considering simultaneously derived wavelet coefficients from different levels of resolution after application of the discrete wavelet transform. One could also project the input signal(s) into various other bases (i.e., apply other signal decompositions) and monitor the resulting signal components as they evolve over time (“pattern recognition”). 
         [0000]    The Use of Genetic Algorithms and Genetic Programming in the adaptation and evolution of the methods for seizure, Spike, and Precursor Detection 
         [0175]    Genetic algorithms (GA) and genetic programming (GP) may be used as part of the overall strategy of algorithm adaptation and evolution in the methods for seizure and spike detection, and seizure prediction. The problem of detection and prediction of seizures is a highly complex one, due to the large intra- and inter-individual variability of brain signals interictally and ictally. The problem of selecting parameters such as filter coefficients, thresholds, window lengths, type of signals, etc. to optimize a particular performance criteria is ideally suited for the use of GA. In this method, parameter sets are assembled into chromosome-like strings which are interchangeable and form the “first generation.” This first generation is evaluated by a fitness function which will assign a score to each element of the generation. After the scoring is completed, the “best” elements are saved and reproduced for the next generation, possibly combined together (“cross-over”), and/or new elements (“mutations”) are introduced. This process of generation, reproduction and testing is repeated, until elements of the resulting generation achieve the desired level of performance for the particular application. 
         [0176]    The following example illustrates how GA may be utilized to choose a time-invariant FIR that maximizes performance. The first generation consists of a group of bandpass filters, each with 2 Hz. bandwidth, of varying orders (but less than 240 Hz.), centered at odd integral frequencies between 1 Hz. and 119 Hz., and designed according to the Parks-McClelland method. The resulting sensitivity and specificity are measured when each filter is used in the seizure detection method presented herein (e.g., by computing the mean squared time between detection and the electrographic onset as independently scored by an electroencephalographer), and the best filters are saved and “reproduced” for the next generation. These filters are also combined together via cascading (“cross-over”), and new “mutation” filters of different bandwidths are added at random frequencies. Mutations may also involve randomly decreasing or increasing the order of certain filters from one generation to the next, but staying below the upper limit of 240, and/or using another filter design methodology. This evolution is continued until some stabilization is reached, or until the resulting performance achieves a high enough degree of sensitivity and specificity for the given data base. 
         [0177]    Genetic programming, a form of program induction, enables the method/system to evolve (without external inputs or re-programming) based on internal fitness functions. GP may enable the method to self-learn and extract the most relevant and useful characteristics of the signal. 
         [0178]    Having thus described the preferred embodiments of the present invention, the following is claimed as new and desired to be secured by Letters Patent: 
       APPENDIX 2 
     Some Background Information on Mathematical Methods 
       [0179]    This Appendix presents some background detail helpful in understanding the preferred methods of the present invention. 
       The Discrete Fourier Transform 
       [0180]    It is well known that every discrete signal defined on evenly spaced discrete time points {t 0 , t 1 , . . . , t N−1 }, where t k =2πk/N, can be interpolated by a trigonometric polynomial which can be written as 
         [0000]    
       
         
           
             
               
                 f 
                  
                 
                   ( 
                   t 
                   ) 
                 
               
               = 
               
                 
                   ∑ 
                   
                     j 
                     = 
                     
                       
                         - 
                         M 
                       
                       + 
                       1 
                     
                   
                   
                     M 
                     + 
                     θ 
                     - 
                     1 
                   
                 
                  
                 
                   
                     c 
                     j 
                   
                    
                   
                      
                     ijt 
                   
                 
               
             
             , 
             
               ( 
               
                 1 
                 = 
                 
                   
                     - 
                     1 
                   
                 
               
               ) 
             
           
         
       
       
         
           where 
         
       
       
         
           
             { 
             
               
                 
                   
                     
                       
                         
                           θ 
                           = 
                           0 
                         
                         , 
                         
                           M 
                           = 
                           
                             
                               ( 
                               
                                 N 
                                 - 
                                 1 
                               
                               ) 
                             
                             / 
                             2 
                           
                         
                       
                     
                     
                       
                         if 
                          
                         
                             
                         
                          
                         N 
                          
                         
                             
                         
                          
                         is 
                          
                         
                             
                         
                          
                         odd 
                       
                     
                   
                   
                     
                       
                         
                           θ 
                           = 
                           1 
                         
                         , 
                         
                           M 
                           = 
                           
                             
                               ( 
                               
                                 N 
                                 - 
                                 2 
                               
                               ) 
                             
                             / 
                             2 
                           
                         
                       
                     
                     
                       
                         if 
                          
                         
                             
                         
                          
                         N 
                          
                         
                             
                         
                          
                         is 
                          
                         
                             
                         
                          
                         even 
                       
                     
                   
                 
                  
                 
                   
 
                 
                  
                 and 
                  
                 
                   
 
                 
                  
                 
                   c 
                   j 
                 
               
               = 
               
                 
                   1 
                   N 
                 
                  
                 
                   
                     ∑ 
                     
                       k 
                       = 
                       0 
                     
                     
                       N 
                       - 
                       1 
                     
                   
                    
                   
                     
                       f 
                        
                       
                         ( 
                         
                           t 
                           k 
                         
                         ) 
                       
                     
                      
                     
                        
                       
                         - 
                         
                           ijt 
                           k 
                         
                       
                     
                   
                 
               
             
           
         
       
     
         [0181]    This discrete. Fourier transform (DFT) represents a given signal (or “time series”) as a superposition of sine and cosine waves with different frequencies and amplitudes. The number of Fourier coefficients is equal to the number of data points in the signal and reproduces (in some sense) the information contained in the original signal. In practice, the DFT is ccomputed using the fast Fourier transform (FFT). Once the signal is decomposed into these fundamental frequencies, one may analyze the signal&#39;s components in separate frequency ranges (bands), and examine the coefficients for dominant frequencies. One generally computes an estimate of the power spectral density (PSD) from the Fourier coefficients in order to determine the dominate modes of the system. The simplest such estimator is the periodogram, which is a graph of the squares of magnitude of each of the Fourier coefficients, in order to see dominant modes of the system. As used herein, PSD means any of the estimators commonly employed in signal analysis. 
         [0182]    The PSD of the signal {f(t 0 ), f(t 1 ), . . . , f(t N−1 )} is obtained from the Fourier coefficients {C j } as 
         [0000]    
       
         
           
             
               ρ 
               j 
             
             = 
             
               { 
               
                 
                   
                     
                       
                          
                         
                           c 
                           j 
                         
                          
                       
                       2 
                     
                   
                   
                     
                       
                         if 
                          
                         
                             
                         
                          
                         j 
                       
                       = 
                       0 
                     
                   
                 
                 
                   
                     
                       2 
                        
                       
                         
                            
                           
                             c 
                             j 
                           
                            
                         
                         2 
                       
                     
                   
                   
                     
                       
                         if 
                          
                         
                             
                         
                          
                         0 
                       
                       &lt; 
                       j 
                       &lt; 
                       
                         M 
                         + 
                         θ 
                         - 
                         1 
                       
                     
                   
                 
                 
                   
                     
                       
                          
                         
                           c 
                           
                             M 
                             + 
                             θ 
                             - 
                             1 
                           
                         
                          
                       
                       2 
                     
                   
                   
                     
                       
                         if 
                          
                         
                             
                         
                          
                         j 
                       
                       = 
                       
                         M 
                         + 
                         θ 
                         - 
                         1 
                       
                     
                   
                 
               
             
           
         
       
     
         [0183]    Here p j  may be interpreted as the total power at frequency w j  in the segment of signal which was transformed. There are M+θ different frequencies, w j , at which signal power is computed, and these frequencies are evenly spaced between w 0 =0 Hz, and w M+θ−1 =F/2 (the so-called Nyquist frequency) which is half of the sampling frequency, F 5 , of the signal (240 Hz above). The PSD contains precise frequency information about the given signal (“frequency localization”), but contains no information about the particular times at which a given frequency occurred. However, in the preferred applications, the time of a particular frequency change is important. 
         [0184]    The windowed fast Fourier transform (WFFT) was created to address the lack of temporal resolution of the discrete Fourier transform; the signal is partitioned into successive segments or windows and the PSD in each window is computed, allowing the user to track changes in the frequency content of the signal window-by-window, i.e., in time. It must be understood, however, that the temporal resolution of the time of frequency changes in the signal is only on the order of the length of the window. Also, due to the discrete nature of the data, there is a degradation in the ability to accurately compute the full frequency content of a signal as the size of window is decreased since the number of frequency coefficients returned by the DFT is equal to the number of data points transformed (the window length). 
         [0185]    An important application of Fourier methods in the present invention involves the analysis of the temporal evolution of various parameters associated with the frequency domain representation of the signal (i.e., the Fourier transformed signal). To accomplish this, one first computes the windowed fast Fourier transform (WFFT) of the signal obtained from a single sensor in a moving window of current data values and then the corresponding PSD estimate for each window. Then each PSD curve is converted to a probability density function (pdf) via normalization, and the resulting densities are treated as if they were characterizations of a non-stationary random frequency. To be more precise, suppose p(x) is a non-negative function defined on the interval, [0, L],(0&lt;x&lt;L). Without loss of generality, one may assume that the area under the graph of p(x) is equal to one, i.e., one may treat p as a pdf. If ∫ 0   L p(x)dx≠1, then one may simply redefine p via normalization, as 
         [0000]    
       
         
           
             
               
                 p 
                  
                 
                   ( 
                   x 
                   ) 
                 
               
               
                 
                   ∫ 
                   0 
                   L 
                 
                  
                 
                   
                     p 
                      
                     
                       ( 
                       x 
                       ) 
                     
                   
                    
                   
                      
                     x 
                   
                 
               
             
             . 
           
         
       
     
         [0186]    Considering p(x) as a pdf, one can compute statistics of the signal frequency distribution using probabilistic methods. In doing so, we obtain a number of parameters from the pdf in each window of time and monitor their absolute and relative temporal changes along with the time evolution of various relations between them. Some of the parameters computed are measures of central tendency in the PSD, including order statistics such as the median frequency (w.r.t. PSD), various moments of the pdf (e.g., the mean frequency), modal frequencies (i.e., the frequency with maximum power); and other parameters measure fluctuations in frequency in each window (e.g., the frequency variance, skewness, and kurtosis). Precise formulae are now presented for some of these measures which are most commonly used. If p(x) is a continuous p.d.f. (defined discretely in this case) which is zero for x&lt;0 and x&gt;L, then the mean of the distribution (also known as the “first moment,” or “expected value”) is given by 
         [0000]    
       
         
           
             μ 
             = 
             
               
                 ∫ 
                 0 
                 L 
               
                
               
                 
                   xp 
                    
                   
                     ( 
                     x 
                     ) 
                   
                 
                  
                 
                    
                   x 
                 
               
             
           
         
       
     
         [0000]    the n th  moment is given by 
         [0000]    
       
         
           
             
               μ 
               n 
             
             = 
             
               
                 ∫ 
                 0 
                 L 
               
                
               
                 
                   x 
                   n 
                 
                  
                 
                   p 
                    
                   
                     ( 
                     x 
                     ) 
                   
                 
                  
                 
                    
                   x 
                 
               
             
           
         
       
     
         [0000]    The variance of the distribution is given by μ 2 −μ 2 . The median, m, of the distribution is defined by the equation 
         [0000]    
       
         
           
             
               
                 ∫ 
                 0 
                 
                   m 
                   f 
                 
               
                
               
                 
                   p 
                    
                   
                     ( 
                     x 
                     ) 
                   
                 
                  
                 
                    
                   x 
                 
               
             
             = 
             
               
                 1 
                 2 
               
               = 
               
                 50 
                  
                 % 
               
             
           
         
       
     
         [0000]    Note that one may also define other percentiles (order statistics) in this manner. The median frequency of a signal in a given window of data is the frequency which divides the area under the PSD in half. The mode, M f , of the p.d.f. is given by 
         [0000]        M   f =arg max{ p ( x )} 
         [0000]    The modal frequency of the PSD (i.e., the frequency at which the maximum power occurs) is thus defined.  FIG. 14A  presents a signal comprised of 1024 points of ECoG data (about 4.267 sec.) recorded from a subject during an interictal (non-seizure) period.  FIG. 146  illustrates the corresponding power spectral density (PSD) of the signal, showing the modal frequency, median frequency, and mean frequency of the signal, computed according to the above definitions. 
         [0187]    One can use the modal frequency and variants of this concept to test the signal for rhythmicity, i.e., to detect segments of data which are nearly periodic. When this quasi-periodicity of the signal occurs, the power in the signal is concentrated at a few resonant modal frequencies. Many useful measures capable of detecting hypersynchronous patterns of neuronal firing often found in the recruitment and entrainment associated with seizures can be derived using a combination of measures such as those defined above. 
         [0188]    For example, to detect hypersynchronous behavior of neurons focusing attention near 15 Hz activity, one can compute a frequency-biased functional of the modal frequency such as 
         [0000]    
       
         
           
             
                
               
                 
                   - 
                   
                     
                       ( 
                       
                         
                           M 
                           f 
                         
                         - 
                         15 
                       
                       ) 
                     
                     2 
                   
                 
                 10 
               
             
              
             
               p 
                
               
                 ( 
                 
                   M 
                   f 
                 
                 ) 
               
             
           
         
       
     
         [0000]    where p is the PSD of the signal in, for example, a moving window of 256 points, and M f  is the modal frequency for that window. One may then monitor the evolution of this measure for significant increases relative to background to produce a rapid detection of this type of signal activity. 
         [0189]    This method for detecting rhythmic discharges in the signal can be further enhanced by weighing a measure such as that above by other measures of quasi-periodicity that can be computed from the signal itself (without first applying the FFT). For example, the reciprocal of the standard deviation of ten successive inter-zero-crossings (or interpeak intervals) increases dramatically in the event of hypersynchrony. The product of this measure with the one mentioned in the last paragraph provides an excellent method for the detection of this type of phenomena. 
         [0190]    A number of other nonlinear functions based on these quantities (e.g., the product of the average energy and the inverse of the median frequency) can also be utilized as a means to obtain precursor information regarding an imminent change of brain state. 
       The Discrete Wavelet Transform 
       [0191]    While the Fourier transform described above gives precise frequency localization of a particular signal, the discrete wavelet transform (DWT) has recently gained popularity because of its ability to provide useful temporal and frequency information simultaneously. The DWT expresses a given signal in terms of a basis consisting of translations and dilations of a single “mother wavelet,” W(j). To be more precise, a given signal {X j } j−1   N  is expressed as 
         [0000]    
       
         
           
             
               x 
               j 
             
             = 
             
               
                 ∑ 
                 
                   l 
                   , 
                   k 
                 
               
                
               
                 
                   b 
                   lk 
                 
                  
                 
                   
                     W 
                     lk 
                   
                    
                   
                     ( 
                     j 
                     ) 
                   
                 
               
             
           
         
       
       
         
           here 
         
       
       
         
           
             
               
                 W 
                 lk 
               
                
               
                 ( 
                 j 
                 ) 
               
             
             = 
             
               
                 2 
                 
                   
                     - 
                     l 
                   
                   2 
                 
               
                
               
                 W 
                  
                 
                   ( 
                   
                     
                       
                         2 
                         
                           - 
                           l 
                         
                       
                        
                       j 
                     
                     - 
                     k 
                   
                   ) 
                 
               
             
           
         
       
     
         [0000]    The wavelet coefficients are defined by 
         [0000]    
       
         
           
             
               b 
               lk 
             
             = 
             
               
                 ∑ 
                 
                   j 
                   = 
                   1 
                 
                 N 
               
                
               
                 
                   x 
                   j 
                 
                  
                 
                   
                     W 
                     lk 
                   
                    
                   
                     ( 
                     j 
                     ) 
                   
                 
               
             
           
         
       
     
         [0192]    The first “dilation” index of the coefficient controls the level of resolution of information, while the second “translation” index controls the temporal information contained in the coefficient. Representing a given signal in terms of wavelet coefficients rather than in the usual time domain is analogous in many ways to representing a musical composition as sheet music rather than looking at the graph of the sound waves through an oscilloscope as the piece is played. Each chord on the sheet music contains information about both the frequencies that are played and the time at which they occur. 
         [0193]    As with the DFT, fast, efficient algorithms exist to compute the wavelet coefficients {b ik }. The fast wavelet transform (FWT) which is based on the pyramid algorithm developed by Mallat makes the FWT even easier to compute than the FFT. 
         [0194]    The FWT is applied to a given signal in windows of data of length 2 n  points, for some prescribed value of n (e.g., n=6). The window size may vary based on a particular application and implementation. Use of the FWT may be desirable if one wishes to monitor signal changes in multiple frequency bands simultaneously and these desired frequency bands match those obtained by dilations of a particular mother wavelet. One may then group the wavelet coefficients by “level,” i.e., by like dilation factor, ordered in each level according to their progression in time. The time between level I wavelet coefficients is 2 t dt, where dt is the sample interval of the original signal. Hence, the level 1 coefficients contain the finest resolution (i.e., the highest frequency) information contained in the signal, and each lower level provides signal information at increasing time scales and decreasing frequency ranges. Level 1 corresponds to the smallest scale of resolution, and contains twice as many coefficients as level 2, which contains twice as many as level three, and so on. Recall that the EEG signal used in illustrating the preferred seizure detection embodiment described above was sampled at 240 Hz, so that a new data point appears roughly every 0.004 seconds. Computing the FWT using, e.g., 64 data points (0.267 sec.) results in 32 level 1 coefficients, 16 level 2 coefficients, 8 level 3 coefficients, etc. Thus for each level, there is a corresponding time series of wavelet coefficients representing the temporal evolution of signal power in a number of frequency bands, each higher frequency level “covering” a frequency band of width twice that of the next lower frequency level.  FIG. 15  shows (the absolute value of) these series for levels 1-4 for a typical interictal segment of 512 data points (about 2 seconds) together with the original signal. 
       A Least Squares Acceleration Filter 
       [0195]    In the method described earlier herein for computing the sharpness of a given waveform at a particular point, one first obtains an optimal parabolic fit to the data near the point in question. One then may use the second derivative (i.e., the acceleration) of the resulting parabola as a measure of sharpness at the peak. The criterion of minimizing the mean square error of this fit may be applied to obtain the best fitting parabola (in a least squares sense). This subsection provides the necessary mathematical details for accomplishing this step. 
         [0196]    If {(x i , y i ), j=1, . . . , n} are data points to be interpolated by the parabola, p(x)=a 2 x 2 +a 1 x+a 0 , then the optimal coefficients a 2 , a 1 , and a 0  which minimize the mean square error 
         [0000]    
       
         
           
             
               ∑ 
               
                 j 
                 = 
                 1 
               
               n 
             
              
             
               
                 ( 
                 
                   
                     y 
                     j 
                   
                   - 
                   
                     p 
                      
                     
                       ( 
                       
                         x 
                         i 
                       
                       ) 
                     
                   
                 
                 ) 
               
               2 
             
           
         
       
     
         [0000]    over all choices of such coefficients, are obtained by solving the equation 
         [0000]      [ a   2   a   1   a   0 ] t =( X*X ) t ( X*Y ) 
         [0000]    where X ij =x i   3−j , for 1≦I≦n, 1≦j≦3, Y=[y 1 . . . y   n ] t , and X* denotes the Moore-Penrose pseudoinverse of the matrix X. If we let A=X*X and B=X*Y, then we have 
         [0000]    
       
         
           
             
               
                 A 
                 ij 
               
               = 
               
                 
                   ∑ 
                   
                     k 
                     = 
                     1 
                   
                   n 
                 
                  
                 
                   x 
                   k 
                   
                     6 
                     - 
                     i 
                     - 
                     j 
                   
                 
               
             
             , 
             
               1 
               ≤ 
               i 
             
             , 
             
               j 
               ≤ 
               3 
             
             , 
           
         
       
     
         [0000]    and the column vector 
         [0000]    
       
         
           
             
               
                 B 
                 i 
               
               = 
               
                 
                   ∑ 
                   
                     k 
                     = 
                     1 
                   
                   n 
                 
                  
                 
                   
                     x 
                     k 
                     
                       3 
                       - 
                       i 
                     
                   
                    
                   
                     y 
                     k 
                   
                 
               
             
             , 
             
               i 
               = 
               1 
             
             , 
             2 
             , 
             3. 
           
         
       
     
         [0000]    Once one solves this equation to obtain the optimal value for the leading coefficient, a 2 , the second derivative of the parabola is equal to twice this optimal coefficient. The sign of this second derivative indicates the polarity of the potential spike as well, e.g., a negative second derivative indicates that the peak of the spike is a local maximum for the signal. The above formulae for computing a 2  may be simplified using the symbolic pseudo-inverse of the 3×3 matrix and subsequent matrix multiplication, resulting in the following formulae for a “least squares acceleration filter” which have been implemented to compute this sharpness measure in real time (i.e., the computation of the second derivative at a given point requires only p(p−1) floating point operations): 
         [0000]        a ( p,dt )= dt   4   p ( p− 1)( p− 1)(3 p   2 −3 p− 1)/30 
         [0000]        b ( p,dt )= dt   3   p   2 ( p− 1) 2 /4, 
         [0000]        c ( p,dt )= dt   2   p ( p− 1)(2 p− 1)/6 
         [0000]        d ( p,dt )= dt p ( p− 1)/2 
         [0000]        e ( p )= p,    
         [0000]        A=c e−d   2 , 
         [0000]    
       
      
       B=c d−b e,  
      
     
         [0000]        C=b d−c   2 , 
         [0000]        D=a A+ 2 b c d−e b   2   −c   3 , 
         [0000]    
       
      
       E=[A B C]/D,  
      
     
         [0000]        f=[ 0 dt   2 (2 dt ) 2 (3 dt )2 . . . (( p− 1) dt ) 2 ], 
         [0000]        g=[ 0 dt 2 dt  . . . ( p− 1) dt],    
         [0000]        h=[ 1 1 1 . . . 1], 
         [0000]        F= 2  E[f   t   g   t   h   t ] t , 
         [0000]      and 
         [0000]        a   2 ( k −[[( p− 1)/2]])= F ( p ) x ( k )+ F ( p− 1 x ( k− 1)+ . . .  F (2) x ( k−p+ 2 F (1) x ( k−p+ 1), 
         [0000]    where {x k , k=1, 2, . . . } is the signal being analyzed, p is the number of points used in the parabolic fit (e.g. p=7), and dt is the time step of the signal being analyzed. Note that, for a fixed value of p, the filter coefficients F may be computed once and stored for later use in the computation of a 2  from the above FIR filter. The delay in computing a 2  at a given point, which is instilled by using [[(p−1)/2]] (i.e., the greatest integer less than or equal to (p−1)/2) future data points, is only (p+1)*dt/2 seconds. For example, with p=7 and dt=1/240, the delay is 1/60 sec. 
       Time-Weighted Averaging 
       [0197]    In the methods described above, there are many cases in which it is desirable to compute some background or reference value for a particular signal. By accurately representing the history of the signal, one may improve the method&#39;s ability to identify relevant changes which standout from this background. 
         [0198]    In this invention, time-weighted averaging is preferred. A subset of these techniques are able to determine a suitable long time-average of any desired functional of the input signal in a very computationally efficient manner, taking into account the entire recorded history of the signal and using only a minimal amount of computer memory. A particular example of the more general method is that of exponential forgetting, in which the recent signal information is weighted more heavily that the distant past. 
         [0199]    The general form referred to as a time-weighted average of a continuous-time signal {X t , t&gt;0} with time-weight {f t, s , t≧0, 0≦s≦t} is given by {m t , t≧0}, where 
         [0000]    
       
         
           
             
               M 
               T 
             
             = 
             
               
                 
                   ∫ 
                   0 
                   t 
                 
                  
                 
                   
                     f 
                     
                       t 
                       , 
                       s 
                     
                   
                    
                   
                     x 
                     s 
                   
                    
                   
                      
                     s 
                   
                 
               
               
                 
                   ∫ 
                   0 
                   t 
                 
                  
                 
                   
                     f 
                     
                       t 
                       , 
                       s 
                     
                   
                    
                   
                      
                     s 
                   
                 
               
             
           
         
       
     
         [0000]    The discrete version of this time-average is obtained by simply replacing the integrals in the above definition by the corresponding summations over the index variable s. For certain time-weights, the above formula may be written recursively, in particular, this may be achieved for the case when f is independent of t. If the time-weight f t, s =e λs , then a version of this time-weighted average can be simplified to the exponentially forgetting method that are employed in some of the embodiments of the invention described herein. 
         [0200]    Variants on this choice may be useful for certain applications. For example, by making λ a periodic function of s with a period of one day, the time-weighted average may be used to weight signal information at a particular time of day more heavily than at other times. This may be particularly important for an individual who may commonly have seizure events only during certain times of day. 
         [0201]    Also note that the choice of time-weight f t, s =X [t,t−δ ] gives rise to the usual moving average 
         [0000]    
       
         
           
             
               m 
               t 
             
             = 
             
               
                 1 
                 δ 
               
                
               
                 
                   ∫ 
                   
                     t 
                     - 
                     δ 
                   
                   t 
                 
                  
                 
                   
                     x 
                     s 
                   
                    
                   
                      
                     s 
                   
                 
               
             
           
         
       
     
         [0000]    Where X denotes the indicator function. 
         [0202]    In the more general case of “time and state weighted averaging,” the weight function, f, may also depend upon the signal X itself. This additional generalization incorporates the case in which the historical average not only depends on the epoch length over which the signal value is averaged, but also upon the signal value over this epoch. This technique may be useful when one desires to allow certain signal characteristics to, by their existence, modify the desired signal background average.