SWS Detection and Stimulation Overview
ZMax can be used to detect slow wave sleep in real time and stimulate the patient for targeted memory reactivation
or closed loop acoustic stimulation.
Slow wave sleep detection can happen in a completely automatic way, or with a training example which provides superior results.
Stimulation can happen without much attention to the timing, which is easier, or according to a precise low latency algorithm supplied by the user/researcher as
an external executable program.
ZMax offers two types of SWS detection (only with the pro versions of HDScorer and HDRecorder):
|WITH TRAINING||NO TRAINING|
|More precise SWS/non-SWS partitioning||Scattered SWS/non-SWS indicators|
|Requires partial scoring of an existing night (explained below)||No preparation needed|
The following image illustrates the difference in results between the two methods on three different EEG phenotypes.
- The blue segments indicate SWS detection and the yellow ones indicate non-SWS.
- The top segmentation is the result of the method using training. The bottom segmentation is obtained with no training.
As you can see the results using training are far superior.
Training SWS Profiler
Training the SWS Profiler takes only a few minutes, but it does require you to have an existing night recorded for the subject.
- Open the file in HDScorer
- Mark at least 30 epochs as SWS (either N2 or N3, the algorithm does not care)
- Mark at least 30 epochs as non-SWS (either WAKE or REM, the algorithm does not care)
- Choose the number of epochs to use for detection (usually 5 works best as shown in the examples above)
- You can test the results right within HDScorer. Once you are happy with the results, you can save the SWS Profiler file
- The SWS Profiler file is loaded into HDRecorder prior to a real time recording session
Notes on "with training mode"
Please be aware of these notes and limitations:
- The algorithm allows you to configure the detection window between 2 to 5 epochs. In practice, 5 epochs are almost always required for good results, unless
the subject's EEG produces a very regular and smooth spectrogram
- Because of this detection window, SWS detection is not immediate, but can be expected to lag 5 epochs
- For the same reason, rapid shifts from and to SWS will not be detected properly
Notes on "without training mode"
Please be aware of these notes and limitations:
- The first time you use "without training mode", the first half an hour of signal is used for training, therefore no detection is possible during this time
- Subsequent trials for the same subject can shorten this time and begin detecting right away if the phenotype file produced from the first night is loaded
- Because the algorithm is trying to minimize false positives, there will be many small 'gaps' in SWS detection. This is a direct consequence of the fact
that spectral characteristics aren't perfectly constant throughout the night
- Gaps will occur most often in recordings in which the spectrogram (specifically the X-Ray spectrogram viewable in HDScorer) appears more unstable and messy
- However, you can configure your stimulation algorithm to ignore small gaps according to your preferences. The SWS detection is
parsed by your program before stimulation occurs. It is your program that actually stimulates. This enables you to deal with these 'gaps' as you see fit.
- The phenotype file produced by the "no training method" is not equivalent to the SWS profile manually created with the "with training method".
However, it is possible to run the first night in "no training" mode, and then create a SWS Profile (manually) based on that data to switch to "with training mode" for
- If false positives are still present for certain subjects, you may use the 'peak strength' parameter to restrict detection to when the alleged SWS peak is
stronger. However since that requires verifying an existing night, there is no reason not to switch to "with training" mode which is much more robust.
Targeted Memory Reactivation & Closed-loop Acoustic Stimulation
Once the SWS detector has detected that the ZMax wearer is in slow wave sleep it is up to you what actions you want to take.
If you do not care about the precise stimulation point, you could play an audio file randomly or at given intervals throughout SWS. This can be done with
However if you care to obtain a specific stimulation point (for instance a particular time in the production of a delta wave) you must code a real time algorithm
to examine the data. This algorithm will probably include some sort of fourier analysis.
HDRecorder (the monitoring software that parses and saves real-time ZMax data, and detects SWS) keeps a shared memory buffer that
any Windows program can access. In Windows lingo this is called a "memory mapped file". Any language that can read a memory mapped file can be used to examine
the incoming waveform with low latency (~4-6 ms). Such languages include C#, C++ and Python.
- HDRecorder exposes a memory mapped file containing real time EEG data
- Any program of your choice can read this memory mapped file to output a stimulation command at the appropriate time
- We welcome researchers to share code for others to reuse and expand on. If you wish to submit your TMR/CLAS code please contact us.