Bedside ZeoViewer Compatible with SleepyHead

General Discussion on any topic relating to CPAP and/or Sleep Apnea.
User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Thu Nov 06, 2014 8:02 am

For Zeo Bedside Models only

Woody (woodinblack) has up upgraded his excellent ZeoViewer (v0.2.7) to include a CSV file export preference for SleepyHead. Ted (wilsonintex) and I have assisted Woody with formatting and testing of the export, if there are questions.

The ZeoViewer may be downloaded here: ZeoViewer. See at the bottom for how to get started.

Below are screenshots demonstrating the export in use.

Overnight View

Image



A 46 second zoom from the night above

Image


To get started:

Download and install the viewer from ZeoViewer
See Woody's thread here: QuantifiedSelf

Once the viewer is installed, set the Preferences under File. To display in SleepyHead, The Export Format must be US Date and Trim Hypnogram. For a Negative (conventional) display, as in the examples above, select Invert Hypnogram and change the SleepyHead Sleep Stage Y axis to display negative (Right click over the Y axis of Sleep Stage); Otherwise, the display will be positive.

Select the dates to export by dragging, highlighting and right clicking in the date tree or select export under File. In both cases, select CSV as the file type and choose a name and location for the file (desktop is handy).

In SleepyHead, go to Data, Import Zeo Data, navigate to the location chosen in the preceding step and open the CSV file. When the import is complete, go to Daily view.


ZeoViewer Preference Settings
Image

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video
Last edited by Jay Aitchsee on Thu Nov 06, 2014 12:35 pm, edited 1 time in total.

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Thu Nov 06, 2014 8:08 am

Placeholder for additional screenshots and detail.

Bug
It appears there is a bug in SleepyHead such that any new sleep records (CSV file) uploaded to an existing Zeo file will display but not be retained on exit from SleepyHead.

The temporary fix is to first open the viewer, import the sleep.dat file and then export the entire CSV file: File>Export Records> choose CSV and Export.
(if the same name and location is used for subsequent exports, the file can be overwritten, which simplifies the process.

Before opening SleepyHead go to the profile folder and delete or rename any existing Zeo Folder. Located by default at
Documents\ SleepyHeadData-testing\Profiles\name\Zeo_xxxxxxxx

Start SleepyHead and Import all data normally.

Ted (wilsonintex) and I are working on the exact behavior of this bug so it can be reported to jedimark.

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video
Last edited by Jay Aitchsee on Tue Nov 11, 2014 7:06 am, edited 3 times in total.

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Fri Nov 07, 2014 6:53 am

Using Zeo with SleepyHead
Below is a combination of snips with SleepyHead on the top and the ZeoViewer on the bottom.
The 3rd graphic, Sleep Stage, in SleepyHead is the CSV export from the ZeoViewer.
Sleep Stages are defined as 1=Red=Wake, 2=Green=REM. 3=Grey=Light, 4/6=Blue=Deep
Notice the correlation of data in the Events, Flow Rate, and Sleep Stage graphics.
Particularly evident are those about 01:00, 02:15, and the cluster about 03:50.
With the aid of Zeo, it seems likely that those events around 03:50 are Sleep-Wake-Junk (SWJ).
Image

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

wilsonintexas
Posts: 406
Joined: Thu May 24, 2012 7:15 am

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by wilsonintexas » Fri Nov 07, 2014 3:21 pm

Here are some additional screen plots thatwere ment for thesecond post. jay, I can not edsit your post, so I had to do anew one.

Before I talk about how the preferences in ZeoViewer change how the data is SleepyHead, I want to cover one other unique feature of the ZEO sleep monitor.

ZEO scores deep sleep in 2 separate stages. Deep sleep is scored as either stage 4 or stage 6. The Sleepyhead default scale does not show the Stage 6 sleep. In order to see this additional stage you need to change the Sleepyhead Y scale to a maximum of 6.

Default display

Image


Scale changed to show stage 6

Image


Now to the “Invert Data” preference.

The normal SleepyHead display shows the actual sleep score. As a result the Deep sleep (4 and 6) are the tallest and wake (1) is shortest. The ZEO displays and the new ZeoViewer adjust the scale so that Wake as tallest and deep as shortest.

When working on the new export, we were looking for a way to “invert” the data and to fool SleepyHead into displaying wake as tall and deep as short. The result is the “Invert the Data” preference. When this option is selected sleep scores are negated in the CSV. So on the output the stages have the following values:

Wake -1
REM -2
Light -3
Deep -4 and -6

Now Wake is tallest and deep(s) are shortest.

To see these negative values you change the Y scale. Enter -6 in the first section and 0 in the second. When I have done this, I sometimes have a hard time seeing the -6 data. WE have found that by making the range -8 to 0, the scale is acceptable and the data is very clear.



Image


Background on “Trim Hypnogran”
When ZEO stores data it adds 0s to the front of the detailed sleep data to back it up to an even 5 minutes. For some reason ZEO can add anywhere from 8 to as much as 30 minutes to the front of the data. ZEO also added a LOT of 0s at the end, sometimes this was 1/3 as long as the real data. The original ZeoViewer exported both the leading and training 0s. When SleepyHead imported this data it had to compress the scale to show all of the data. But there was not any data for the last 1/3 of the display, it was all 0s.

The “Trim Hypogram” was created to remove these leading and trailing 0s. It looks like the latest software update removes the trailing 0s. One 0 may be left at the beginning it helps align the data block to the nearest whole minute.

WARNING WHEN LOOKING AT AN EVENT IN SLEEP STATE REMEMBER THAT THE "REAL WORLD EVENT" MAY HAVE STARTED IN THE LAST HALF OF THE PREVIOUS30 SECOND EPOCH OR LATE IN THE ONE CURRENT ONE. DO NOT TRY TO LOOK AT A BREATHING EVENT THAT IS TIMED TO THE .001 OF A SECOND AND SAY THAT HAPPENED JUST AS WENT INTO REM THAT IS A 30 SECOND WINDOW. In the example in the first post it appears to line up, but it can be off for the following reasons.



1) ZEO actually scores and records finer detailed timing, but it then averages the data within a 30 second window that they call an EPOCH, So a 30 second time is scored as REM, it is most of the data in the 30 second window was REM. The first 14 seconds could have been wake and the final 16 REM. But the whole 30 seconds is scored as REM.
2) The original CSV format only contained a start time to the minute. The time format did not include the seconds. The Sleepyhead viewer had to adapt to this limitation. So now not only is the data averaged over 3 0seconds, but we have to adjust it to start at a whole minute.
3) If you look at the TXT file output, you will see a start of night value that is to the second. But we cannot use that time because in the CSV file we can only give it to whole minute.
4) ZEO does not start recording sleep stages as soon as you put on the headband. It needs time to establish a connection through the sensor pads. It only starts collecting data when the “bar” to the “ZEB Indicator” (the head like thing) . You have no control over when this happens. It depends a lot on the state of your sensors. The better shape that they are in the less time it takes. The Start of Night in the TXT file is the time to the second that the first sleep stage is captured. Even if we had this, remember that ZEO averages the data within a 30 second window. So even if the data collection starts at 23:55:58 there is only 2 seconds worth of data to average for the 30 second epoch starting at 22:55:30 to 22:56:00. So there may not be enough data collected to be averaged until the 22:56:00 to 22:56:30 epoch. The result of all of this is that we only see a change in sleep stage at the whole minute or at 30 seconds…… nature never works this way….. You do not wait for the whole minute or 30 second interval to start REM.
5) Sync errors between different clocks. . I have tried to sync the time of both my ZEO and my CPAP to a clock radio controlled clock. It is good to within a second. Since neither ZEO nor the S9 display seconds, the closest you get it to wait for the minute to flip and see how close the clock is. This is made worse because the clock is not started until you exit the time set mode. It takes time to do this. I cannot get either of my machines better that machine better than within 2-3 seconds of my master clock. Most of the time I am lucky to get them within 15 seconds.
6) Clock drift: My cpap clock drifts badly. I have repaired and tinkered with a 200 year old grandfather clock. I have it keeping time within 3 seconds a week, when I have to rewind it. The CPAP is not even close. It is losing about a minute a week. So, even if it is write today, it is off tomorrow.

The effect of all of this is:
DO NOT TRUST THE EDGE OF THE EVENT AS THE ACTUAL TRANSITION.
1) Sleep Stage is averaged over a 30 second window
2) There is a difference between the clocks

(Almost done beating this dead horse)

So the best you can do:
The best you can do is to try and sync the clock on the CPAP and the clock on the ZEO to within a few seconds. In general the ZEO time is easier to change than the CPAP time. If you need to change your CPAP time, try to do it in the afternoon rather than in the evening. The machines seem to like it better. You will have more trouble backing up the clock on your CPAP than moving it forward. Backing up can cause duplicate data which the CPAP machines do not like.


SO REMEMBER THAT TRANSITION THAT LOOKS IT HAPPENED EXACTLY AT 23:50 MAY HAVE ACTUALLY STARTED IN THE LAST 14 SECONDS OF THE PREVIOUS EPOCH OR IN THE LAST 16 SECONDS OF THE EPOCH IT SHOWS UP IN….. AND THAT IS IF THE CLOCKS ARE THE SAME…. THEY NEVER ARE.


(Done beating the horse….. off my soap box, I think you get the idea by now, or you stopped reading my rant long ago)


Late Entry:
At least two people have had problems with Sleepyhead losing the sleep data when they exit and restart it. It looks like this happens when you add data additional data. The work around that has been suggested (and is still being verified) is pretty easy:
1) Before you start SleepyHead to into the profile you use and delete the folder named ZEO_XXXXXX. This is where the detailed data is stored. If the folder is not there ZEO will created a new one when you import the data.
2) In the ZeoViewer simply export all of the data. This is the default mode. So it is easier.
3) When you load the data into Sleepy head all of the data is loaded, and it is kept when you shut it down and start it up again.

User avatar
jagzoo
Posts: 340
Joined: Tue Jan 15, 2013 7:14 pm
Location: Nh

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by jagzoo » Fri Nov 07, 2014 10:06 pm

Great Jay and Ted , I am finally really being able to see possible correlations between events and sleep stages ( taking into consideration the different ways my CPAP and ZEO measure the time and show events/ sleep stages, without trying the copy, paste and alignment routine.

Thanks for all the great work.

And Ted, thanks for all your help via email.

All the explanations are really informative and helpful!,

Thanks again

_________________
Mask: AirFit™ P10 For Her Nasal Pillow CPAP Mask with Headgear
Additional Comments: Heated Tubing; mask sometimes is TAP PAP mask; now P10 nasal pillows; use Sleepyhead software
APAP 9-12

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Sat Nov 08, 2014 8:53 am

Thanks jagzoo.
And just to clarify a bit: 30 second epochs are a standard of polysomnography.
Here are some definitions from the American Association of Sleep Technologists: Technical Guidelines 2012
AAST Guidelines
3.3.3.1 Sleep Stage Parameters
Total Recording Time (TRT) is defined as the time from “lights out” to “lights on”. Total Sleep Time (TST) is
the total time asleep after sleep onset. To determine the how well the patient slept, the Sleep Efficiency (SE) is
calculated by dividing the TST by the TRT and multiplying by 100.

Sleep studies are recorded on 30 second “epochs”. Sleep onset is defined as the first epoch scored as any stage
other than stage W. Sleep Latency (SL) is the time from “lights out” to the sleep onset. Latencies to sleep
stages are determined from sleep onset to the first epoch of that sleep stage.

Wake after Sleep Onset (WASO) is the time awake after sleep onset until “lights on”. To determine the
percentage time spent in each of the sleep stages during the sleep study, the total minutes of the sleep stage is
divided by the TST and multiplied by 100.

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

woodinblack
Posts: 1
Joined: Sat Nov 08, 2014 5:59 pm

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by woodinblack » Sat Nov 08, 2014 6:51 pm

wilsonintexas wrote: 1) ZEO actually scores and records finer detailed timing, but it then averages the data within a 30 second window that they call an EPOCH, So a 30 second time is scored as REM, it is most of the data in the 30 second window was REM. The first 14 seconds could have been wake and the final 16 REM. But the whole 30 seconds is scored as REM.
That is similar to what happens in other stages, but not with wake. Wake is more important in the Zeo than the other states, so if 1 second of the epoch is wake and 29 seconds is REM, it will score as wake, ie, any wake in an epoch makes the whole epoch wake. This is the same as the 5 minute view / export, where 9 epochs could be light sleep and 1 wake, and it will show as wake.
wilsonintexas wrote: The result of all of this is that we only see a change in sleep stage at the whole minute or at 30 seconds…… nature never works this way….. You do not wait for the whole minute or 30 second interval to start REM.
You don't, but by the same token, you don't fall asleep in a second.

You have to guard against the viewing the Zeo being 'exact science'. The transition between wake and sleep is very hard to work out by brain waves, even worse between sleep and REM. Having looked at the raw serial port data that the Zeo provides, the actual brainwaves, I suspect the reason that the medical world uses 30 second epochs (apart from to reduce the amount of data) is that the transition doesn't occur on a second boundary. Inside the Zeo there is a second that the transition occurs which is based on a mathematical change of alpha and delta waves - this is calculated some time after that second, but I don't believe you can really say eg: 'they went to sleep at 23:52:12' - I think in real life a 30 second transition is probably about as accurate as you can get.

So I wouldn't worry too much about the exact time of the transition between states within an epoch, because states are a way of viewing the data, they don't actually exist as an absolute.

One thing that still bugs me in the export is that it would probably be good to have a way to swap the magnitude of 4 and 6, as 6 appears to be a lighter state of sleep than 4 (and in fact 6 is not even transmitted as separate state from the serial port - it appears as 3). Maybe there could be a preference for that. If you look at the sleep state in sleepyhead with your export you will see it shows this state in a different way than the viewer shows it. If you look at Jays comparison, you see his blue sections have a high part and a low part, in sleepyhead they will show the other way round.

You are right about the timing though. I am not sure how bad the CPAP machines are but the Zeo clock is remarkably inaccurate. I am not sure how you can actually make an inaccurate digital clock these days, but they certainly managed it!

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Mon Nov 10, 2014 6:58 am

Using Zeo with SleepyHead II
Here's a snip of a recent night. A quick look would seem to indicate that most Events occur during REM and most Large Leaks during Deep.
Interestingly, Large Leaks occurred with two different masks, Simplus before the break and F10 after.
It seems to have been a restless night with Zeo scoring many wakes with corresponding spikes in Flow Rate.

Image

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

wilsonintexas
Posts: 406
Joined: Thu May 24, 2012 7:15 am

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by wilsonintexas » Thu Nov 13, 2014 10:09 pm

WOOD IN BLACK. Thanks for the additional information. I am still learning about this stuff, and I appreciate your insight.

I always suspected that wake should have more weight.... and maybe it is my strange brain waves.... but ........ I find that most nights the beginning of the noght is way off. I know I am awake. I watch te display, and it is blinking wake...... but in the morning I find out that it thinks I was in REM, Light, or deep. Sometimes the deep that shows up at the beginning of the noght is 50% ofthe deep that it records.


Lately I have been having problms fallign asleep, so I have been thinking about how to make a replacement headband..... and it is all recorded as rem. Maybe I simply day dreaming.....

I am NOT saying you are wrong. It makes to much since, and sound like it is how it works.. I wish I saw it working that way for me.

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Fri Nov 14, 2014 7:13 am

Ted, I think part of the problem could be that the Bedside Viewer display is not in real time. I think it is delayed, I don't know how much, but I would guess at least 5 minutes. Remember, the Bedside display is in 5 minute epochs while the Base display that we're using in the ZeoViewer and SleepyHead is in 30 second epochs. Each 5 min epoch of the Bedside display is the average (again with the exception of wake) of the 30 second epochs that occurred during that 5 minute epoch. Another place this might be evident is at end of night. If you're watching the Bedside display when you put the headband on the dock, you will notice that the display sometimes seems to "catch up" by adding one or two more 5 minute epochs.
Further, Zeo doesn't score "start of night" until it senses continuing sleep stages that are uninterrupted by wake or undefined for at least 10 minutes. And, as humans themselves do, Zeo sometimes has difficulty distinguishing between Wake and REM. Maybe it does score that period, while you are lying there quietly reflecting, as REM in error; or maybe, you are drifting off to sleep for a bit.
And lastly, Zeo doesn't write the record to the card until it has encountered a trigger that signals "End of Night".
I think this means that resulting base hypnogram and perhaps the final display hypnogram itself could be different that that perceived by watching the beside display while awake.
BTW, if you haven't seen it, I think you might be interested in this paper which compares Zeo's sleep staging score accuracy to that of standard polysomnography (PSG), Assesment of Wireless... and this one, which compares Zeo favorably with human scorers, Validation of Wireless... In my opinion, and seemingly agreed to by the authors of the papers, Zeo is reasonably accurate, but it's best use is probably in establishing trends in sleep stages over time, not necessarily precisely defining the moment of change in each sleep stage nightly.

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Thu Jan 01, 2015 10:43 am

Woody has just posted ZeoViewer v 0.3.0 at his site. This version cleans up a few things from previous versions and allows the import of CSV files previously downloaded from the Zeo Web site. This is a cool feature for those that have the old data. See Woody's Quantified Self forum posting here.

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Thu Jun 25, 2015 1:10 pm

I see Woody is working on software for Zeo mobile devices. See his thread, post, and website for more info.

https://forum.quantifiedself.com/thread ... 79#pid5279
https://forum.quantifiedself.com/thread ... 26#pid7326
http://www.alienrat.net/software/zeomonitor.html

Sounds like he wouldn't mind having access to more Zeo mobile data for verification purposes.

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

User avatar
Sir NoddinOff
Posts: 4190
Joined: Mon May 14, 2012 5:30 pm
Location: California

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Sir NoddinOff » Thu Jun 25, 2015 1:37 pm

I wish I had the guts (and time) to jump on the Zeo bandwagon but since things are going so well for me (right now anyway) I'm afraid I might find out that I'm missing some important sleep stage and jinx things. Call me cowardly lion, I guess. Thanks for the work anyway, maybe some day I'll try it since I always bookmark these interesting posts.

_________________
Mask: AirFit™ F10 Full Face Mask with Headgear
Additional Comments: Sleepyhead software v.0.9.8.1 Open GL and Encore Pro v2.2.
I like my ResMed AirFit F10 FFM - reasonably low leaks for my ASV therapy. I'm currently using a PR S1 AutoSV 960P Advanced. I also keep a ResMed S9 Adapt as backup. I use a heated Hibernite hose. Still rockin' with Win 7 by using GWX to stop Win 10.

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Sun Apr 17, 2016 1:01 pm

Those with a mobile type Zeo may want to check out this thread over at Quantified Self: https://forum.quantifiedself.com/t/zeoc ... o-pro/2197
I don't have a mobile Zeo, but this looks like it might work pretty well on android tablets.

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video

User avatar
Jay Aitchsee
Posts: 2936
Joined: Sun May 22, 2011 12:47 pm
Location: Southwest Florida

Re: Bedside ZeoViewer Compatible with SleepyHead

Post by Jay Aitchsee » Thu May 19, 2016 1:29 pm

See the thread: https://forum.quantifiedself.com/t/zeoc ... -pro/2197/
It looks like CyberMike's app for Zeo Mobile is now compatible with SleepyHead

_________________
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear
Additional Comments: S9 Auto, P10 mask, P=7.0, EPR3, ResScan 5.3, SleepyHead V1.B2, Windows 10, ZEO, CMS50F, Infrared Video