# Patent

## Title
Method and software to determine probability of sleep/wake states and quality of sleep and wakefulness from an electroencephalogram

## Abstract

Method and software are provided to format a probability index that reflects where an electroencephalogram (EEG) pattern lies within the spectrum of wakefulness to deep sleep, which employs a computer/microprocessor that performs frequency domain analysis of one or more discrete sections (Bins) of the EEG to determine the EEG power at specified frequencies, optionally calculates the total power over specified frequency ranges, assigns a rank to the power at each frequency, or frequency range, assigns a code to the Bin that reflects the ranking of the different frequencies or frequency ranges, and determines an index that reflects where said EEG pattern within said Bin(s) lies within the spectrum of wakefulness to deep sleep by use of a reference source, such as a look-up table or other suitable decoding instrument. The reference source is obtained by calculating the probability of Bins with different codes occurring in epochs scored as awake or asleep in reference files scored by one or more expert technologists or by an automatic scoring software.

## Background
FIELD OF THE INVENTION
The invention relates to the determination of the probability of sleep/wake states and quality of sleep and wakefulness from an electroencephalogram.
BACKGROUND TO THE INVENTION
Determining whether a patient/individual is awake or asleep is an essential first step in the analysis of sleep records obtained during investigation of sleep disorders. In some cases such investigations require only knowledge of whether the patient was awake or asleep. An example would be home monitoring for the diagnosis of sleep apnea. Here, if a patient does not show evidence of sleep apnea (e.g. dips in oxygen saturation, interrupted snoring) a diagnostic dilemma arises in that one does not know whether the negative study was because the patient did not sleep. In other cases, it is necessary to have a more comprehensive description of sleep, such as amount of time spent in each of the different sleep stages, which reflect the type rapid edge movement (REM vs. non-REM) and depth (stages N1, N2, N3) of sleep. This information is needed to evaluate the quality of sleep and is particularly useful in cases of excessive somnolence and insomnia. In the latter cases, distinguishing a sleep state from an awake state is a first step towards determining which stage the patient is in. Typically, once it is clear that the patient is asleep, decisions as to what sleep stage the patient is in is based on the presence of specific features in an electroencephalogram (EEG), Eye movements (EOG), intensity of chin muscle activity (chin EMG), among other findings.
Apart from analysis of formal sleep records, it is of considerable importance to be able to determine the level of vigilance in situations that require a high level of alertness such as during driving long distances, operating heavy machinery or equipment of critical nature such as air-traffic control. It is well known that decreased alertness, for example, as a result of boredom, alcohol, drugs, or sleep deprivation, are responsible for numerous driving and occupational accidents. There are different levels to what is considered as wakefulness. These range from fully alert to drowsy to having periods (a few seconds) of micro-sleep. Cognitive and motor performance is impaired as level vigilance decreases even if the subject is still technically awake. To my knowledge, there are currently no methods that identify different levels of wakefulness.
The present invention deals with a method for developing a continuous quantitative scale that describes the level of vigilance/consciousness across the whole spectrum from full alertness to the deepest sleep. When embedded in appropriate equipment this method can be used to a) evaluate the level of vigilance in situations requiring alertness, b) determine whether a subject is awake or asleep, c) determine the quality of sleep in sleep studies and, d) as an initial step in detailed sleep scoring with the subsequent steps relying on identification of the additional features using any of well described approaches in prior art. The current method does not cover steps to classify sleep into its various conventional stages. Rather, the current process generates a value (Probability of being awake (PW); Odds Ratio Product (ORP)), which reflects the probability of any given section of the EEG record falling in a period that would be staged as awake by experienced scorers or by validated automatic scoring systems. I have established the presence of a clear negative correlation between this value (PW, ORP) and depth of sleep as measured by conventional visual criteria. As such, P PW/ORP can be used as a continuous scale that describes the quality of wakefulness or sleep in certain sections of the record or as a lumped average for the whole night. Every sleep technologist recognizes that within any given conventional sleep stage there is a continuum of sleep quality. For example, an EEG pattern that is now classified as stage N1 according to conventional criteria could be very close to an awake pattern on one end of the spectrum or very close to the deeper stage 2 on the other end. Likewise, there is a huge range of patterns in what is now classified as an awake state, ranging from full wakefulness to quite wakefulness, to wakefulness interrupted by mini-sleep periods, and so on. The use of this index (PW ORP) allows an expression of the quality of sleep on a continuous scale regardless of the conventional classification. It also can be used to reflect the overall quality of sleep in one number. This is much easier to understand and interpret than the conventional histogram of the different stages vs. time (the Hypnogram).
The current accepted practice for scoring sleep records is manual scoring by expert technologists. This is time consuming, and by extension, quite expensive. Manual scoring is also highly subjective with different experts producing different results. As indicated above, the EEC; pattern in many of the epochs (usually 30 seconds in length) are on the border between two stages (e.g. awake vs. N1). Some may score these epochs one way while others may score it another way. Also, there are large differences in how experts interpret the guidelines, which are often vague. Manual scoring is also an extremely tedious task and is often associated with gross errors related to inattention. Automation, accordingly, has many potential advantages, if it can be shown to be accurate.
Manual scoring of sleep relies primarily on visual appreciation of the different EEG patterns. There have been many attempts at automating EEG scoring but the results have not been up to what is required for acceptance. Virtually all automated methods rely on frequency analysis of the EEG. This analysis produces the power in different frequencies. The relevant frequency content of the EEG is 0.3 to 40 Hz. Any EEG pattern can be accurately described by the power spectrum of the EEG, namely the power in each of the relevant frequencies. Many previous approaches have been described that exploit the power spectrum of the EEG to arrive at sleep stages. These approaches typically use various complex signal analysis models. The problem is that there is a huge number of frequency spectra that could be called awake and another huge number of patterns that could fall in what the eye perceives as sleep, and so many patterns that could be called either by eye. A high power in the beta range (>14 Hz) may be present in full wakefulness or in the deepest sleep. Likewise, a high alpha power (7 to 14) could be present in wakefulness or in any of the other sleep stages. Thus, the interpretation of power in a given frequency must take into account the power in other relevant frequencies. Yet, as indicated earlier, the various combinations of powers that can be encountered during wakefulness or sleep are enormous and do not lend themselves to a unitary quantitative model. Hence in this invention we use an empiric approach by assigning codes to thousands of EEG frequency patterns and simply determining how often each code is found in epochs that expert scorers score as awake or asleep. Once a reference resource is established (probability of each code to be scored awake or asleep), scoring of un-scored files simply entails determining the spectral code of selected EEG intervals and determining the probability of Sleep/Wake state by use of the reference resource.
SUMMARY OF THE INVENTION
1) The present invention takes a radically different approach to scoring the EEG for determining the level of vigilance or sleep. It starts by performing frequency analysis of the EEG on discrete time intervals (Bins; e.g. 3 seconds, but clearly other intervals may be used). Also, as done with other methods, the power or amplitude in certain ranges of frequency is combined to reduce the number of variables to a manageable level. For example, the total power in frequencies between 0.3 and 2.5 is added, giving the power in the slowest range of waves (generally called Delta power). The ranges need not conform to any conventional classification (e.g. Delta, Theta, alpha, sigma, beta1, beta 2) and may or not be overlapping. Clearly, the more ranges are used, the greater the resolution. But, this greatly affects the number of combinations to be rated and, by extension, processing time and number of files to be expertly scored to produce the reference resource (look-up table, equation . . . etc). In our preferred embodiment, we have selected four frequency ranges (0.3 to 2.33 Hz (Delta); 2.67 Hz to 6.33 Hz (Theta); 7.33 Hz to 14.00 Hz (Alpha/Sigma); and >14 Hz (Beta)). The frequency range from 6.67 to 7.00 was not included in the Theta power as some alpha waves in clearly awake regions can occasionally be seen in this range in some patients.
2) The next step is to assign the power or amplitude in each frequency range in each Bin a rank (expressed as a number, letter or symbol) that reflects its relative magnitude. This is basically a normalization process that takes into account the entire range of powers or amplitudes observed in the relevant frequency range across as many sleep studies as possible. For this step, a number of EEG studies (files) that represent the full spectrum of relevant clinical conditions are scored manually or by a validated automatic system. The power or amplitude in each frequency range (selected in step 1), is then determined in Bins of equal length in these reference files. For example, we used initially 40 files, each about 8 hours long or 9600 3-sec Bins (8*60*20), for a total of approximately 400,000 bins. These values were then sorted in ascending order. The entire range was broken into smaller ranges of equal number. Clearly any number of ranges can be used. In the extreme, the actual power in each Range may be used as the rank. The larger the number of ranges the better the resolution but the more processing power and time are required. We used 10 ranges and each range was assigned a rank (we used numerical rank, 0 to 9). Thus, we divided the entire range of Delta power in the 400,000 samples into 10 equal ranges, the lowest range (Rank 0) includes all values in the lowest 10 percentile and Rank 1 includes all values between the 10th and 20th percentile, and so on until Rank 9 which includes all values above the 90th percentile. The same was done for the other frequency ranges. The result was a table (e.g. Table 1) that can be looked up to determine a Rank to assign to the power in each frequency range in the Bin being examined.











TABLE 1





Rank
Delta
Theta
Alpha/Sigma
Beta



















0
5.85
4.55
3.0
0.95


1
9.38
6.97
4.6
1.3


2
13.67
9.63
6.2
1.68


3
19.48
12.9
8.1
2.11


4
28.01
17.15
10.4
2.63


5
41.93
22.98
13.3
3.33


6
66.76
31.37
17.3
4.36


7
117.71
44.64
23.5
6.19


8
258.26
70.84
36.1
10.91


9
258.27+
70.85+
36.08+
10.92+









This Table is a fixed look-up table in the software. It is based on our results analyzing 40 files obtained from two academic sleep laboratories. Clearly other tables can be used with different frequency groupings, different ranking procedure or different Bin widths. Also, in some laboratories, extrinsic noise or other technical differences can result in somewhat different table values if a large number of files from that laboratory were subjected to the same ranking procedure. An optional feature is therefore to have the ranking table used in a certain laboratory developed specifically from files generated by that laboratory to allow for the technical differences. A variety of Ranking tables can then be available in the library and the appropriate
one is selected when scoring files from laboratories that do not subscribe to recommended guidelines for data acquisition or which have specific noise issues. However, we have found the above table to be satisfactory when used to score files from a variety of laboratories.
Optionally, a similar table can be developed if other (than spectral power) features of the EEG in the specified frequency ranges are used (e.g. amplitude, Mean Absolute Amplitude (MABs), Total Variation (TV) . . . etc). In this case, the reference files are processed to generate the feature selected, and the total range of the feature in the reference files is broken into a number of sub-ranges for use in assigning Bin Codes.
The software determines the power (or amplitude . . . etc) in each of the selected frequency ranges (4 ranges in the preferred embodiment) in consecutive Bins (3 seconds in the preferred embodiment). Each Bin is then assigned a 4-digit Code based on the value of the feature (power, amplitude . . . etc) in each frequency range and the corresponding ranks in the look up table. For example, by use of numerical ranks, as in the preferred embodiment, if the powers in the Delta, Theta, Alpha/Sigma and Beta ranges in a given Bin were 52, 10, 17, and 7, the Bin Code would be 6368. This Code then indicates that the power spectrum in this Bin is composed of moderate Delta, relatively low Theta, moderate Alpha/Sigma and High Beta. If letters or symbols are used instead of numbers, the Code is a series of letters and/or symbols that reflect the ranks in the different ranges. From the above description, it is clear that a large number of Bin Codes would result. By using 10 ranks in each of 4 frequency ranges, there results 10,000 different Bin Codes, representing 10,000 different frequency spectra. Clearly this number can be expanded or reduced by different manufacturers of the software. However, we found that this combination provides satisfactory resolution.
3) Determining the Awake/Sleep probability for each Bin Code (PW, ORP): A large number of sleep files, which could be the same files used to develop the ranking tables, are scored manually, or by a validated automatic system, according to conventional criteria (e.g. the 2007 American Academy of Sleep Medicine guidelines). Each file is divided into consecutive bins of the same duration used to develop the ranking table. The Bin Code for each Bin is calculated from the Ranking table. For each Bin Code the fraction of occurrences of this Code in periods scored as awake by the expert technologists, or by the validated automatic system, is determined. For example, if there were 280 instances of Bin Code 1422 in the entire reference dataset and only 20 occurred in epochs staged as awake, the probability of Bins with this Code occurring in awake periods is given a value of 20/280, or 0.07 (or 7%). On the other hand, a Bin number that occurred only in epochs staged as awake by experts would be assigned a probability of 1.0 (or 100%).
In the preferred embodiment, we obtained conventional manual scoring of 40 files from two academic institutions. The scorer was a very senior certified technologist. She was asked to score each 30-sec epoch as carefully as possible, with no time constraints, using the latest scoring guidelines (AASM 2007 guidelines). The scoring of sleep stages and arousals was reviewed by the inventor and a consensus was reached in epochs where there were differences. The files were broken into 3-sec Bins for an approximate total of 400,000 Bins. Bin Codes were assigned as per step 2. The probability of each of the Bin Codes occurring during epochs scored manually as awake or within scored arousals was determined for each Bin Code. The average number of occurrences of any Bin Code in this data set was 400,000/10,000 or 40. However, as may be expected, there were some Bin Codes that were very frequent (e.g. Bin Codes 0000 and 9999, which occurred several thousand times) and others that were absent or extremely rare. 6200 Bin Codes occurred >10 times in the dataset and their probability could be determined directly (# awake/total #), while 1000 Bin Codes were completely absent and 2800 Codes occurred only 1-10 times. For these, arbitrary probability values were assigned manually based on their spectral pattern (BIN Code) and the probability of fairly similar Bin Codes that have directly determined probabilities. For example, Bin Codes 1190, 1191, 1192 and 1193 were very poorly represented in the data set (0 to 8 Bins out of 400,000). However, the immediately following bin code (1194) with only slightly higher beta power had good representation (209) and its ORP was 2.5 (PW=100%). Furthermore, Bin codes with the same beta rank (0, 1, 2 and 3) but slightly lower alpha rank (namely 1180, 1181, 1182, and 1183) also had a very high ORP values thereby indicating that Bins with very low Delta and Theta powers and high Alpha power occur almost invariably in awake epochs, regardless of Beta rank. Accordingly, the four Bin Codes with little or no representation were assigned a probability of 95%. Clearly with time, the number of files subjected to this process can be increased to obtain a much larger dataset in which fewer Bin Codes are poorly represented. It must be pointed out that because these Bin Codes are quite rare, errors in the assigned arbitrary probabilities would have minimal consequences. Thus, as an alternative to assuming ORP values in poorly represented bin codes, it may be reasonable to not assign any ORP value to such bin codes or to assign a default value that would indicate that this 3-sec epoch should not be considered in any subsequent analysis.
From the above steps, a table was generated that contained the probability of being awake for each of the 10,000 Bin Codes. Although the probability values can be used as such (0 to 1.0 or 0 to 100%), we elected to use a different scale where a probability of 40% is assigned a value of 1.0 and other probabilities are assigned a value of (Probability %)/40. This was because we found that 40% of all 30-second epochs in the reference files were scored awake. So, the odd of being correct if awake is scored at random is 40%. We arbitrarily decided to express all probability values as a ratio (ORP). Thus, a probability of 100% of being awake is given an ORP of 2.5 and a probability of 10% of being awake is given an ORP of 0.25. Clearly which of the 3 scales to use (fraction, percent, or ORP) is optional as they all reflect the same thing.
10015) A table was developed that contained the ORP value for each of the 10,000 Bin Codes (ORP table; FIG. 14). Table 2 below shows the ORP values for the first and last 300 bin codes. Clearly the higher the ORP value the greater the likelihood of the Bin occurring in an epoch that would manually be scored as awake, and vice versa. Further, the ORP (or probability) value should reflect the depth of sleep. For example, an ORP value of 1.25 (probability of falling in an epoch scored awake=50%) means that a Bin with such a spectral pattern occurs equally in epochs scored as awake or asleep. Such Bin Code must, therefore, reflect very light sleep because sleep depth is typically a gradual process. It is true that in some 30-second epochs deep sleep can suddenly change to awake. However, these instances are quite infrequent when viewed within the context of several hundred thousand Bins in representative files. Conversely, an ORP that is close to zero indicates that such a spectral pattern is only seen in sleep and, hence, occurs only in very stable sleep, which is typically deep sleep.
Once the Bin Codes are assigned as per step 2, the software converts the Codes into probabilities by use of the Probability Look-up table. An example of such conversion for bin code 0126 is shown in Table 2. It is theoretically possible to express the results of Table 2 as a mathematical formula through complex regression analysis. In such case, the formula can be used to convert the Code into probability instead of the look-up table. We have found that such an exercise of attempting to fit the data of Table 2 by a formula is not warranted in view of the ease and speed of utilizing a look-up table. However, use of formulae or other decoding instruments to convert the Codes into probabilities is covered by the present invention.
The ORP table given here is unique to the reference files we used, the scorers who scored these files, the frequency bands and frequency domain analysis used, bin width (3-seconds), the ranking method used (Table 1), and the output form (ORP). We have obtained excellent results using this combination of techniques and look-up tables (Kuna S T, Benca R, Kushida C A, Walsh J, Younes M, Staley B, Hanlon A, Pack A I, Pien G W, Malhotra A. Agreement in Computer-Assisted Manual Scoring of Polysomnograms Across Sleep Centers. SLEEP 36:583-589, 2013). However, and as mentioned earlier, a software manufacturer may choose to apply the general method described here using other reference files, other scorers, other methods of frequency domain analysis, other frequency bands, another ranking system or output form (e.g. % awake) and generate their own look-up tables. In such cases the Ranking and Probability tables should be constructed from reference files that were analyzed using the same methods (i.e. frequency ranges, bin width, frequency domain analysis . . . etc). Such different applications of the general method fall within the scope of this invention.







TABLE 2







Representative ORP Values For the First and Last 300 Bin Codes



























Bin






















Code
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19






























0000
0.92
1.80
1.88
1.95
2.05
2.13
2.27
2.39
2.50
2.50
1.33
1.72
2.02
2.14
1.97
2.08
2.26
2.42
2.43
2.50


0020
1.81
2.21
2.28
2.24
2.32
2.24
2.30
2.39
2.46
2.50
2.30
2.30
2.31
2.39
2.37
2.39
2.34
2.41
2.45
2.50


0040
1.98
2.38
2.40
2.47
2.44
2.42
2.45
2.41
2.46
2.49
2.50
2.39
2.46
2.46
2.48
2.50
2.49
2.45
2.49
2.50


0060
2.30
2.27
2.50
2.49
2.49
2.47
2.49
2.49
2.48
2.49
2.30
2.37
2.41
2.50
2.50
2.47
2.49
2.48
2.49
2.50


0080
2.30
2.50
2.43
2.44
2.50
2.49
2.49
2.50
2.50
2.50
2.30
2.30
2.30
2.50
2.50
2.50
2.50
2.50
2.50
2.50


0100
0.26
0.52
0.78
0.78
1.03
1.38
1.64
1.93
2.20
2.50
0.48
0.80
0.78
0.95
0.97
1.15
1.63
1.97
2.32
2.50


0120
1.10
1.11
1.34
1.51
1.68
1.52
1.85
2.13
2.32
2.50
1.50
1.60
1.71
1.85
2.08
1.94
2.18
2.21
2.39
2.41


0140
1.60
1.60
1.90
2.24
2.28
2.27
2.25
2.24
2.30
2.47
2.00
2.00
2.16
2.40
2.29
2.48
2.34
2.45
2.42
2.50


0160
2.20
2.20
2.32
2.39
2.42
2.43
2.33
2.44
2.48
2.50
2.30
2.30
2.50
2.47
2.44
2.43
2.45
2.49
2.47
2.49


0180
2.50
2.50
2.50
2.50
2.47
2.50
2.49
2.49
2.48
2.50
2.50
2.50
2.50
2.50
2.50
2.50
2.50
2.48
2.50
2.50


0200
0.19
0.28
0.35
0.66
0.63
0.46
0.80
1.60
2.00
2.20
0.24
0.28
0.37
0.62
0.48
0.58
0.80
1.80
2.35
2.50


0220
0.50
0.56
0.81
1.00
1.15
1.30
1.45
1.60
2.15
2.30
0.80
0.80
0.80
1.04
1.28
1.52
1.76
1.96
2.03
2.50


0240
1.28
1.40
1.52
1.64
2.04
1.97
1.81
2.00
2.31
2.50
1.55
1.65
1.75
1.85
2.19
2.29
2.11
2.21
2.30
2.50


0260
1.82
1.90
1.98
2.08
2.34
2.29
2.23
2.42
2.47
2.47
2.09
2.15
2.21
2.20
2.43
2.39
2.45
2.37
2.48
2.48


0280
2.36
2.40
2.44
2.37
2.44
2.46
2.46
2.44
2.47
2.50
2.50
2.50
2.50
2.50
2.50
2.50
2.50
2.47
2.49
2.50


0300
0.16
0.30
0.15
0.31
0.16
0.80
1.00
1.19
1.38
1.57
0.14
0.25
0.32
0.18
0.24
0.36
1.17
1.35
1.52
1.69







Example: ORP for Bin Code 0126 = 1.85



























9700
0.00
0.00
0.00
−0.14
0.02
0.18
0.34
0.51
0.67
0.83
0.00
0.00
0.00
0.00
0.08
0.24
0.41
0.57
0.74
0.91


9720
0.00
0.00
0.00
0.00
0.00
0.30
0.47
0.64
0.81
0.99
0.00
0.00
0.00
0.10
0.00
0.35
0.54
0.71
2.22
2.50


9740
0.00
0.00
0.00
0.00
0.00
0.16
0.28
0.78
2.13
2.50
0.00
0.00
0.00
0.00
0.04
0.05
0.14
0.85
1.04
2.47


9760
0.00
0.00
0.00
0.00
0.12
0.04
0.16
0.50
1.11
2.44
0.00
0.00
0.00
0.10
0.15
0.00
0.17
0.47
1.18
2.40


9780
0.80
0.00
0.00
0.00
0.06
0.04
0.19
0.40
1.19
2.44
0.00
0.00
0.13
0.00
0.53
0.13
0.28
1.13
1.49
2.44


9800
0.00
0.13
0.00
0.00
0.00
0.00
0.11
0.28
0.44
0.60
0.00
0.00
0.00
0.12
0.00
0.00
0.18
0.34
0.51
0.68


9820
0.00
0.00
0.04
0.00
0.00
0.21
0.17
0.41
0.58
0.75
0.00
0.00
0.00
0.02
0.07
0.04
0.05
0.48
0.66
2.35


9840
0.00
0.00
0.04
0.00
0.00
0.21
0.17
0.55
0.73
0.91
0.00
0.00
0.00
0.02
0.07
0.04
0.05
0.62
0.80
2.35


9860
0.00
0.00
0.00
0.00
0.03
0.04
0.10
0.11
0.65
2.35
0.00
0.00
0.00
0.02
0.01
0.08
0.11
0.14
0.58
2.34


9880
0.00
0.00
0.00
0.00
0.05
0.04
0.04
0.10
0.46
2.28
0.00
0.00
0.00
0.00
0.03
0.03
0.09
0.15
0.63
2.38


9900
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.05
0.21
0.37
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.11
0.28
0.45


9920
0.00
0.00
0.00
0.00
0.00
0.00
0.01
0.18
0.35
0.52
0.00
0.00
0.00
0.02
0.04
0.00
0.05
0.19
0.43
0.60


9940
0.00
0.00
0.01
0.01
0.03
0.02
0.03
0.26
0.50
0.68
0.00
0.00
0.00
0.00
0.00
0.04
0.06
0.16
0.64
2.26


9960
0.00
0.00
0.00
0.00
0.00
0.02
0.03
0.13
0.50
2.23
0.00
0.00
0.00
0.00
0.01
0.01
0.03
0.07
0.29
1.98


9980
0.00
0.00
0.00
0.01
0.01
0.01
0.03
0.07
0.16
1.94
0.00
0.00
0.00
0.02
0.00
0.03
0.04
0.12
0.17
2.35









This Patent application is about generating a probability estimate of an electroencephalogram interval (Bin) falling in an epoch that would be scored independently, by expert scorers or systems, as awake. Clearly, rather than estimating the probability of being awake, one may choose to estimate the Probability of the epoch being scored as asleep. (this would simply be (2.5-ORP), or (100 Probability %)).
The probability value generated by the current invention can be used in many different ways:

    
    
        A) The average Probability Estimate (e.g. ORP) for the entire file can be displayed in the scoring report, and used as a measure of overall sleep quality.
        B) The average Probability Estimate for periods scored as specific sleep stages (manually or automatically) can also be displayed in the scoring report. It is generally recognized that a given sleep stage is not homogeneous. Within each sleep stage there is a spectrum of EEG patterns with some being closer to awake patterns while others are closer to deep sleep. Stage N2 in one patient may, for example, have a predominance of deeper sleep Bins or epochs while in another patient lighter steep epochs predominate. These differences are not currently captured by conventional scoring, which classifies sleep into 4 stages only. By reporting the quality of sleep within each of the four stages, it may be possible to explain why some patients symptoms (fatigue, sleepiness) are not in keeping with the results of conventional scoring. We have found that the PW in stage N1 sleep ranges from 24% to 72% (ORP 0.6 to 1.8) among different subjects, for N2 the range was 7% to 55% (ORP 0.17 to 1.4), and for N3 it was 2% to 28% (ORP 0.04 to 0.7). It is thus clear that within the same stage defined by visual criteria, there is a wide range of ORP values that reflect different levels of sleep quality.
        C) Likewise, within what is conventionally scored as awake time, the average PW can range from 62% to 96% (ORP 1.55 to 2.40), thereby reflecting different degrees of vigilance during what is conventionally called awake. It can be easily envisioned that a limited EEG monitoring device, attached to the forehead for example, can be equipped with the current software and be used to monitor PW or ORP in real time in subjects engaged in critical activities. Such a system can also sound an alarm or notify monitoring stations when PW or ORP falls below a specified level (e.g. 2.2).
        D) The probability estimates can be averaged over periods on and off therapy and the averages reported to show the effect of therapy on sleep quality.
        E) The probability estimate can be used on its own to score sleep if all that is required is to determine whether the epoch(s) being scored are simply awake or asleep. For example, the average probability estimate for all Bins within a 30-second interval can be calculated. I have found that by using the simple rule of scoring an epoch awake when average ORP is >1.6 (probability >64%), and vice versa, the scoring is accurate in 95% of epochs. This is acceptable accuracy for that purpose.
        F) Alternatively, the distribution of probability estimates within an epoch (e.g. 30 seconds) can be utilized to improve accuracy, particularly in epochs in which the average ORP is equivocal. For example, a 30-second epoch that contains four 3-second Bins with an ORP <1.0 and six 3-second Bins with an ORP >2.0 might have an ambivalent average ORP of 1.4. However, it would be scored as awake since this was clearly an epoch split between a longer period with a dominant awake pattern (ORP>2.0) and a shorter period with sleep pattern. Several other algorithms that examine the pattern of ORP values within a 30-second epoch can clearly be utilized to improve the accuracy of distinguishing between awake and asleep in an epoch. While we prefer that the software make a decision in every 30-sec epoch, one option is to not score epochs where it is difficult to decide. For example, if all ORP values within an epoch are in the mid-range (1.2 to 1.8) and the average is also equivocal (e.g. 1.2 to 1.6), one may elect to identify the epoch as un-storable by the current system. This would affect only a small minority of epochs.
        G) The current invention can be used as an accessory to the current manual scoring systems. Thus, the file would be run first with the software of the current invention to automatically classify epochs as awake or asleep, to be followed by manual scoring of the different sleep stages.
        H) The probability estimate can be incorporated within software that performs comprehensive sleep staging. Here, after the overall status of an epoch (sleep vs. awake), epochs scored as sleep are further identified as one of the standard four stages (Rem, N1, N2, N3) using additional algorithms to detect features used for classifying sleep stages (e.g. eye movements, spindles, K complexes, chin EMG). Such steps that aim to further identify the different stages of sleep are not part of this invention.
        I) The current invention can be incorporated in portable devices that measure the EEG. The results can be displayed or transmitted (wirelessly or through cable) in real time. In this way the results can help evaluate the state of vigilance of the subject being monitored.
    
    


Accordingly, in one aspect of the present invention, there is provided a method method for generating a Probability index (Index) that reflects where an electroencephalogram (EEG) pattern lies within the spectrum of wakefulness to deep sleep, which employs a computer/microprocessor that performs frequency domain analysis of one or more discrete sections (Bins) of the EEG to determine the EEG power at specified frequencies, optionally calculates the total power over specified frequency ranges (Ranges), assigns a rank to the power at each frequency, or frequency Range, assigns a code to the Bin that reflects the ranking of the different frequencies or frequency ranges (Bin Code), and determines an index that reflects where said EEG pattern within said Bin(s) lies within the spectrum of wakefulness to deep sleep by use of a Reference Source, such as a look-up table or other suitable decoding instrument, where such Reference Source is obtained by calculating the probability of Bins with different Codes occurring in epochs scored as awake or asleep in reference files scored by one or more expert technologists or by an automatic scoring software.
In that method, material of calculating power, frequency domain analysis is used to calculate signal amplitude, or other measure of signal strength, in the specified frequency ranges and where the Ranking method and the Reference Source are based on use of the method of calculating signal strength.
In another aspect of the present invention, there is provided software for estimating the Probability that the electroencephalogram (EEG) pattern reflects a sleeping or awake state, said software executing the following functions performing spectral analysis of one or more discrete sections (Bins) of the EEG to determine the EEG power at different frequencies, optionally calculating the total power over specified frequency ranges (Ranges), assigning a rank to the power at each frequency, or frequency Range, assigning a code to the Bin that reflects the ranking of the different frequencies or frequency ranges (Bin Code), and determining the probability of the EEG pattern within said Bin(s) of reflecting an awake or sleep state by use of a reference source, such as a look-up table or other suitable decoding instrument, where such reference source is obtained by calculating the probability of Bins of different Codes occurring in epochs scored as awake or asleep in reference files scored by one or more expert technologists or by a properly validated scoring software.
. . . claim 9.
In a further aspect of the present invention, there is provided a device for carrying out the method and utilizing the software.



BRIEF DESCRIPTION OF DRAWINGS
FIG. 1 is a block diagram of the major components of software and the data flow in the analysis of processing records to determine ORP;
FIG. 2 is a block diagram showing various pre-processing options;
FIG. 3 is a block diagram of the algorithm for removing the R-wave artifact;
FIG. 4 is a block diagram showing the steps used for Frequency domain analysis;
FIG. 5 is a flow chart of the step of “Calculate Summary Powers”;
FIG. 6 is a block diagram showing the assign Bin Code;
FIG. 7 is a flow chart showing the step of assigning the ORP values
FIGS. 8a-b shows the typical results of ORP values over several hours of recording for two patients with the results of conventional sleep scoring into five stages (awake, N1, N2, N3, REM);
FIG. 9 is a flow chart showing the processing of streaming data for ORP determination;
FIG. 10 is a block diagram of the components of a mobile device that implements the present invention;
FIGS. 11a-d shows details of the Front End Analog Circuitry of the instrument of FIG. 10;
FIGS. 12a-c shows details of the micro-controller and associated circuitry of the instrument of FIG. 10;
FIGS. 13a-d shows details of the power supply and associated circuitry for the instrument of FIG. 10; and
FIGS. 14a-q is the ORP Table.



DESCRIPTION OF PREFERRED EMBODIMENTS
1) Analysis of Pre-Existing Records:
This form of implementation is particularly suitable when this invention is used on pre-existing files or when the generation of the Probability Value is a preliminary step to be followed by more detailed analysis of the EEG that require examination of large sections of the file (e.g. as an aid to scoring sleep stages). This form of implementation is preferably done on standard computers.
The software of the preferred embodiment was developed in C# (C sharp) on a standard desktop computer with the following specifications:
1) Processor: 3.4 GHz
2) RAM: 4 GB
3) Operating System: Windows XP, 32-bit
4) Development Environment: Visual Studio 2008
5) Hard Drive Size: 1.00 TB
FIG. 1 is a block diagram of the major components of the software and the data flow. The file is loaded in memory (1). The next step involves optional pre-processing (2) (See FIG. 2). The file is then split into 3-sec bins (3) with a total number, M, corresponding to 1⁄3 file length in seconds. Beginning with the first bin (4) frequency domain analysis is performed (5) (sec FIG. 4) followed by calculation of total power in different frequency ranges (6) (see FIG. 5). From this, bin code is assigned (7) by reference to lookup table 1, which is stored in memory. This is followed by determination of ORP for the 3-sec bin (8) (see FIG. 7), by reference to the stored ORP lookup table. The ORP value is stored (9). Bin number is increased by one and the process repeats until the end of the file.
FIG. 2 shows the various pre-processing options (2). One or more of these is executed depending on the pre-existing properties of the file. These properties are inputted into the computer along with the file.
The hand-pass filter (0.3-35.0 Hz) option (10) is applied if the file in memory is not pre-filtered. This is to comply with recommended standards for processing of the EEG. The current software operates on the assumption that the sampling frequency in the file is 120 Hz. If the sampling frequency is <120 Hz, the file is rejected. If >120 Hz, the data is re-sampled at 120 Hz (11) using the “Nearest Neighbor Approximation” (the value of the data point nearest the time required for 120 Hz is used). This is followed by a 0.05 high-pass filter (12). Finally, if the R wave artifact of the electrocardiogram (EKG) has not been filtered out in the stored file, an R-wave artifact removal algorithm is applied to the EEG signal (13). This requires the presence of an EKG channel in the file.
Details of this R-wave artifact removal algorithm are shown in FIG. 3. Briefly, the times of R wave peaks (Pi) are located for each cardiac beat in the file (14). Any of a number of standard R wave detection algorithms can be used. For this embodiment, a 5-point derivative of the EKG signal is obtained and then squared. An 11-point integral is performed on the squared derivative (IFRDi). A 10-sec integral of the IFRD is obtained (IFRD10s) and the difference between IFRDi and IFRD10s is calculated. Peak R wave is identified as the highest point in a transient in which IFRDi >IFRD10s for >100 ms. Subsequent steps are performed on the EEG channel from which the R wave artifact is to be removed. EEG data in the interval Pi±35 points (≈0.6 sec) of each R wave are stored (15). These stored values are then broken into consecutive blocks, each containing 100 beats (16). The average of the 100 sets of 71 points is then obtained for each block and this 71-point average replaces all 100 sets in the block (17). This process is performed for each block in the file. Finally, the stored averages are subtracted from the original EEG data (18).
FIG. 4 shows the steps used for Frequency domain analysis (5). Our software, which uses a variation of the Fourier transform, calculates the power X[k] at frequency k as:



  
    
      [
      
        
          A
          ⁡
          
            [
            k
            ]
          
        
        =
        
          
            ∑
            
              n
              =
              0
            
            
              n
              -
              1
            
          
          ⁢
          
            xn
            ⁢
            
              
            
            ⁢
            
              cos
              ⁡
              
                (
                
                  
                    
                      2
                      ⁢
                      π
                    
                    N
                  
                  ⁢
                  
                    (
                    
                      k
                      +
                      1
                    
                    )
                  
                  ⁢
                  
                    (
                    
                      n
                      +
                      1
                    
                    )
                  
                
                )
              
            
          
        
      
      ]
    
    ⁢
    
      

    
    [
    
      
        B
        ⁡
        
          [
          k
          ]
        
      
      =
      
        
          ∑
          
            n
            =
            0
          
          
            n
            -
            1
          
        
        ⁢
        
          xn
          ⁢
          
            
          
          ⁢
          
            sin
            ⁡
            
              (
              
                
                  
                    2
                    ⁢
                    π
                  
                  N
                
                ⁢
                
                  (
                  
                    k
                    +
                    1
                  
                  )
                
                ⁢
                
                  (
                  
                    n
                    +
                    1
                  
                  )
                
              
              )
            
          
        
      
    
    ]
  




  
    
      X
      ⁡
      
        [
        k
        ]
      
    
    =
    
      
        (
        
          
            
              (
              
                A
                ⁡
                
                  [
                  k
                  ]
                
              
              )
            
            2
          
          +
          
            
              (
              
                B
                ⁡
                
                  [
                  k
                  ]
                
              
              )
            
            2
          
        
        )
      
      /
      
        N
        2
      
    
  



For integer values of k,





  k
  =
  
    [
    
      1
      ,
      
        N
        2
      
    
    ]
  








  k
  =
  
    [
    
      1
      ,
      
        
          N
          2
        
        -
        1
      
    
    ]
  




Where;

fs=Sample Rate of the EEG window=120 Hz

N=Length of input EEG window, in samples=3fs=360

n=Current sample index in EEG window

xn=Value of the EEG signal for sample n

k=Index of the frequency we are examining. The actual frequency is:





  
    f
    k
  
  =
  
    
      
        (
        
          k
          +
          1
        
        )
      
      3
    
    ⁢
    Hz
  








  
    f
    k
  
  =
  
    
      
        (
        
          k
          +
          1
        
        )
      
      3
    
    ⁢
    Hz
  




X[k]=The power at a frequency index of k

C=Scaling coefficient, equal to





  
    1
    N
  
  =
  
    1
    360
  




To save computation time, since the following two terms



  
    cos
    ⁡
    
      (
      
        
          
            2
            ⁢
            π
          
          N
        
        ⁢
        
          (
          
            k
            +
            1
          
          )
        
        ⁢
        
          (
          
            n
            +
            1
          
          )
        
      
      )
    
  




  
    sin
    ⁡
    
      (
      
        
          
            2
            ⁢
            π
          
          N
        
        ⁢
        
          (
          
            k
            +
            1
          
          )
        
        ⁢
        
          (
          
            n
            +
            1
          
          )
        
      
      )
    
  



are independent of xn, and as shown in the top of FIG. 4 (19), they are calculated ahead of time and stored in memory.

FIG. 5 is a flow chart describing the step “Calculate Summary Powers” (6). In this step the sum of powers in specified frequency ranges is calculate in each 3-sec bin. The frequency ranges used in this embodiment were (6):

    
    
        0.3-2.3 Hz (k=0-6): corresponding to conventional delta range (20);
        2.7-6.3 Hz (k=7-18): corresponding to conventional delta range, excluding frequencies 6.7 and 7.0 Hz (21);
        7.3-12.0 Hz (k=21-35): corresponding to conventional alpha range (22),
        12.3-14.0 Hz (k=36-41): corresponding to conventional sigma range (23),
        14.3-20.0 (k=42-59): corresponding to conventional Beta1 range (24), and
        20.3-35.0 (k=60-104): corresponding to conventional Beta2 range (25).
    
    


For the sake of ORP determination, alpha and sigma powers were combined (alpha/sigma power (26)) and beta 1 and beta 2 powers were also combined (beta power (27)), resulting in 4 frequency ranges.
FIG. 6 shows the approach used to assign Bin Codes (7). The algorithm checks the delta power in the 3-sec bin against the thresholds for the 10 ranks in the delta column of the stored Table 1 and assigns the appropriate rank to the delta power. The same process is repeated for theta, alpha/sigma and beta power, assigning a rank to each. Finally a 4-digit number is generated having the delta rank, followed by the theta rank, followed by the alpha/sigma rank and finally the beta rank. The process is repeated for each 3-sec bin.
FIG. 7 shows the step of assigning the ORP value (8). This simply consists of checking the ORP code in the ORP table and obtaining the ORP value associated with the code.
FIG. 8 shows results of ORP values (generated according to the preferred embodiment) over several hours of recording in two patients along with the results of conventional sleep scoring into five stages (awake, N1, N2, N3, REM). By conventional criteria, the main difference between the two patients was a somewhat greater awake time in patient 1 (Table 3 below). However, by looking at the ORP values in FIG. 8, it is clear that even when patient 1 was technically staged asleep, the ORP was highly unstable, reflecting extensive and frequent intrusion of awake features within the EEG, and that the average ORP (white line within the ORP panel) was substantially higher inpatient 1 than in patient 2 for all sleep stages (see also Table 3). Thus, not only was there more awake time in patient 1 but, when he slept, his sleep quality was quite poor. FIG. 8 also shows that during awake periods in both patients ORP was not fixed at 2.5 (the highest level) but there were frequent decreases in ORP, reflecting intrusion of sleep features during awake time. Thus, the awake state is not a constant but incorporates different levels of vigilance that can be reflected by the ORP value.









TABLE 3








Patient 1
Patient 2












Time (min)
ORP
Time (min)
ORP














Awake
155
2.28
85
2.28


N1
59
1.84
16
0.86


N2
147
1.39
195
0.42


N3
24
0.72
55
0.18


REM
52
1.59
29
1.00


Total Sleep
282
1.46
294
0.45


Total Recording Time
436
1.75
378
0.86









2) Generation of the Probability Index from Streaming Data (i.e. in Real Time):
The same procedure, with minor modifications, is used to generate the probability index on a continuous basis by analyzing short segments of recording and outputting the result as the data flows in. It is particularly suited for applications that require rapid feedback about the patient's sleep state or state of vigilance. It can also be utilized as a preliminary step in other software that performs simultaneous scoring of sleep stages concurrently with data acquisition. This application can be implemented on standard desktop computers, laptops or other mobile computing devices depending on the clinical indication. With all such devices the EEG output of the data acquisition system is channeled to the computer via a USB port or other suitable means. The data is then streamed into memory using existing or custom software.
FIG. 9 is a flow chart showing the processing of streaming data. Here, each specified interval (bin; for example 3 seconds) is treated as a separate file. When data for such interval has been received, the software goes through the same process described in FIGS. 1 to 7, including preprocessing (2, FIG. 2), frequency domain analysis (5, FIG. 4), Calculate Summary Powers (6, FIG. 5), Determine Bin Code (7, FIG. 6), and finally Determine ORP value (8, FIG. 7). A single ORP value is generated and displayed. The process repeats until the end of the study.
FIG. 10 is a block diagram of the components of a mobile device that implements the present invention. A data acquisition chip (Texas Instruments ADS1299; 28) is used for collecting up to eight channels, any of which can be an EEG channel. The output is conveyed, via an SPI communication Bus, to a micro-controller (29) that incorporates Atmel ATmega256RFR2 (U1A and U2B) microcontroller (30) and a radio receiver/transmitter (BALUN; 31). The system is powered by a Lithium ion battery (32) with associated battery and power management circuitry (33).
FIG. 11 shows details of the Front End Analog Circuitry (28) associated with Texas Instruments ADS1299 chip comprising:

    
    
        Analog front end for biopotential measurements
        Low noise delta sigma analog to digital converter
        8 channels, simultaneous sampling
        24-Bit analog precision
        Sample rates from 250SPS (samples per second) to 16 kSPS
    
    


FIG. 12 shows details of the micro-controller (29) and associated circuitry comprising:
Atmel ATmega256RFR2 (U1A and U2B)(30) with:

    
    
        8-bit Microntroller at 16 MHz
        256 KB Flash Memory
        32 KB Program RAM (random access memory)
        Fully integrated RF Transceiver for the 2.4 GHz ISM Band (industrial, scientific and medical)
        RF Data rates from 250 kb/s up to 2 Mb/s
        ZigBee and IEEE 802.15.4 RF compliant
    
    


Wurth Electronics—732-2230-1-ND (BALUN) (31)

    
    
        BALUN—Balanced to unbalanced converter
        blocks common mode waves and allows only differential mode waves to the antenna.
    
    


Microchip—MCP102T (32)

    
    
        Micropower voltage supervisor
        Prevents unnecessary microcontroller resets due to brown out conditions
    
    


FIG. 13 shows details of the power supply (33) and associated circuitry comprising:
Lithium ion battery (32)
Microchip—MCP73831T (34)

    
    
        Li-Polymer Charge Management Controller
        Employs battery charging algorithms and measurement logic
    
    


Maxim Integrated—MAX1704 (35)

    
    
        Battery fuel gauge and low battery alert
        Provides battery data to the microcontroller
        Alerts the microcontroller in case of low battery percentage
    
    


Texas Instruments—TPS27082L (36)

    
    
        PFET Load Switch
        Provides Fast Transient Isolation and Hysteretic control
    
    


Linear—I.T3971-3.3 (37)

    
    
        38V, 1.2 A, 2 MHz Step Down Regulator
        Switching power supply for the system
        Converts battery power to 3.3V for microntroller and analog front end power supply
    
    


FTDI—FT230XQ (38)

    
    
        USB to UART (serial) converter
        Allows for data transfer between computer and onboard micro-controller.
    
    


SYSTEM OVERVIEW


    
    
        Power is applied to system
        Microcontroller enters bootloader which loads the firmware
        Firmware initializes all system settings to allow for operation between the ADS1299 and itself
        Firmware initializes radio connection between receiver and itself
        START command issued to ADS1299 to start sampling 2 to 8 channels
        Analog signal is converted to digital via the ADS1299
        Digital data is sent over a serial protocol interface (SPI) to the microcontroller
        This process repeats until a STOP command is issued
        Appropriate signal conditioning and data analysis: As per steps 2, 5, 6, 7, and 8 (FIGS. 2, 4, 5, 6, and 7)
        Algorithm output is sent over a wireless radio link
    
    


SUMMARY OF DISCLOSURE
In summary of this disclosure, the present invention provides a method of generating a probability index that reflects where an electroencephalogram (EEG) pattern lies within the spectrum of wakefulness to deep sleep, which employs a computer/microprocessor that performs the steps of method. Modifications are possible within the scope of the invention.

## Claims

1. A method for determining the probability of an electroencephalogram (EEG) pattern within an EEG test record of a subject having occurred in sections of reference EEG records scored previously as awake or EEG arousals, said method employing a computer/microprocessor that:
performs frequency domain analysis of one or more discrete sections of the EEG test record to determine EEG test record power at specified frequencies,
calculates EEG test record power over specified frequency-bands,
assigns, for each specified frequency band, a rank to the calculated power-in each discrete section of the specified frequency band, each rank being determined based on values of power encountered in a plurality of the previously scored reference EEG records,
assigns a code to each discrete section that reflects the ranking of the calculated powers in different frequency bands,
incorporates a database/lookup table constructed from previously scored reference EEG records that indicates the probability of each code to occur in sections of said reference EEG records scored previously as awake or EEG arousals,
determines, for each assigned code, the probability indicated in the database/lookup table that corresponds to the assigned code, and
reports the determined probabilities that reflect the probability of the electroencephalogram (EEG) pattern within the EEG test record of the subject having occurred in sections of reference EEG records scored previously as awake or EEG arousals.

2. The method of claim 1 wherein probabilities of codes assigned to more than one discrete section are averaged over specified intervals.

3. The method of claim 1 further comprising using the reported probabilities as a component of another system that determines stages of sleep, respiratory events, arousals, cardiac arrhythmias, or motor events during sleep.

4. The method of claim 1 further comprising outputting the probabilities after the EEG test record has been analyzed.

5. The method of claim 4 wherein the probabilities are outputted in real time as streaming data and loaded in computer memory.

6. A non-transitory computer readable medium embodying program code that when executed by a computer or microprocessor, performs the operations of:
performs frequency domain analysis of one or more discrete sections of the EEG test record to determine EEG test record power at specified frequencies,
calculates EEG test record power over specified frequency bands,
assigns, for each specified frequency band, a rank to the calculated power in each discrete section of the specified frequency band, each rank being determined based on values of power encountered in a plurality of the previously scored reference EEG records,
assigns a code to each discrete section that reflects the ranking of the calculated powers in different frequency bands,
determines, for each assigned code, a probability indicated in a database/lookup table that corresponds to the assigned code, the database/lookup table being constructed from previously scored reference EEG records that indicates the probability of each code to occur in sections of said reference EEG records scored previously as awake or EEG arousals, and
reports the determined probabilities that reflect the probability of the electroencephalogram (EEG) pattern within the EEG test record of the subject having occurred in sections of reference EEG records scored previously as awake or EEG arousals.

7. The non-transitory computer readable medium of claim 6 wherein the operations further comprise averaging probabilities of codes assigned to more than one discrete section over specified intervals.

8. The non-transitory computer readable medium claim 6 wherein the operations further comprise using the determined probabilities as a component of another system that determines stages of sleep, respiratory events, arousals, cardiac arrhythmias, or motor events during sleep.

9. The non-transitory computer readable medium of claim 6 wherein the operations further comprise outputting the determined probabilities after the EEG test record has been analyzed.

10. An apparatus comprising:
memory embodying computer executable code; and
a microprocessor configured to communicate with said memory and to execute said code to cause said apparatus to:
perform frequency domain analysis of one or more discrete sections of an EEG test record of a subject to determine EEG test record power at specified frequencies,
calculate EEG test record power over specified frequency bands,
assign, for each specified frequency band, a rank to the calculated power in each discrete section of the specified frequency band, each rank being determined based on values of power encountered in a plurality of reference EEG records scored previously as awake or EEG arousals,
assign a code to each discrete section that reflects the ranking of the calculated powers in different frequency bands,
determine, for each assigned code, a probability indicated in a database/lookup table that corresponds to the assigned code, the database/lookup table being constructed from previously scored reference EEG records that indicates the probability of each code to occur in sections of said reference EEG records scored previously as awake or EEG arousals, and
report the determined probabilities that reflect the probability of an electroencephalogram (EEG) pattern within the EEG test record of the subject having occurred in sections of reference EEG records scored previously as awake or EEG arousals.

11. The apparatus of claim 10 wherein the apparatus is further caused to average probabilities of codes assigned to more than one discrete section over specified intervals.

12. The apparatus of claim 10 wherein the apparatus is further caused to use the determined probabilities as a component of another system that determines stages of sleep, respiratory events, arousals, cardiac arrhythmias, or motor events during sleep.

13. The apparatus of claim 10 wherein the apparatus is further caused to output the determined probabilities after the EEG test record has been analyzed.

14. The apparatus of claim 13 wherein the determined probabilities are outputted in real time as streaming data.

15. The apparatus of claim 10 wherein said apparatus is a portable device that measures EEG activity of the subject.