Actigraphic Polysomnography

     

         

        Source  Code

        This is a polysomnographic computer program. Its utility is in the detection and diagnosis of multiple sleep disorders. I refer to this as a "poor man's" sleep study. A formal nocturnal polysomnogram (Sleep Study) performed in a sleep lab/center usually costs over $1000.00 to perform and perhaps $250.00 or more to be interpreted by a certified sleep specialist. The cost of the equipment in a sleep lab is over $15,000.00 and usually includes EEG, ENG, Oximetry, EKG, Respitrace, PLM monitor and other varied devices depending on the indications and if it is a sleep lab or center. My alternative requires only a personal computer (Windows XP, >= 1024x768 & 24 bit color -recommended-), an optical mouse, a Webcam or Firewire Digital Video Camera (allows infrared recording) and a microphone.

        The concept is quite simple. An actigraph is a device which measures "movement". When someone is sleeping, they generally move very little. Thus sleep onset, sleep time and arousals can be detected using actigraphy. Likewise, arousals associated with "Restless Leg Syndrome" or "Periodic Limb Movement Disorder", often resulting in insomnia, can be quantitated with actigraphy. Although medical studies suggest that actigraphy is inadequate to diagnose sleep disorders alone, when used in conjunction with other modalities, it is complimentary.     

        My "poor man's" actigraph is fashioned by putting an optical (wireless or wired) mouse inside of white socks worn on a limb or affixed to the body. (See the diagram/picture) By allowing movement of the mouse within the white socks, changes in the X/Y axis values reflect movement. By adjusting the mouse sensitivity and acceptance parameters, actigraphy is performed.    

        When a sleeper arouses, the cause of the event is important. By triggering video with movement, the event will be recorded and an experienced examiner can determine the cause. Motion detection is based on the actigraph and not the actual video motion thus low light levels do not hinder the study. Using an infrared camera (commonly found on Sony consumer camcorders) is of additional value. 

        The program also uses the Microsoft Speech Recognition control to trigger an audio-video recording (voice/sound activation and not speech recognition). The event of interest is snoring, especially snoring of an obnoxious quality associated with arousal. Obstructive Sleep Apnea (OSA) is a common cause of sleep disruption and results in a sundry of medical maladies. The sine qua none of OSA is "excessive daytime sleepiness" with non-restorative sleep. The snoring is loud and often heard in other rooms, driving bed-partners away. The quality of the snoring is also quite characteristic, as it starts loud and then there are periods of quiet (associated with airway obstruction) followed by arousal and gasps. 

        The limitations of this study include the fact that a person's sleep is not "staged" (1-4 and Stage REM). Heart rate and ekg aren't monitored nor is pulse oximetry. (The addition of pulse oximetry to this study would be quite simple and invaluable, albeit, somewhat expensive.) Furthermore, nocturnal penile tumescence cannot be directly quantitated although one could position the camera for this display ;).

        The audio and video is recorded in AVI, uncompressed files. I suggest using the smallest video format possible, such as 160x120 and perhaps audio at 8 bit, 8000 and monaural to limit the size of the files which can be consumptive over 8-9 hours. This program is limited to 32000 seconds which is about 8.9 hours. This allows graphic representation of the data in the Microsoft Chart Control which is limited to 32K of data points. The actigraph is also plotted in real-time and in 5 minute increments which can be saved and reviewed. 

        One may adjust the video parameters from within the program or by using the Control Panel applets. The audio and video require a combined input (eg. camera with microphone) for recording. The program cannot record audio without video at present although webcams are fairly ubiquitous.

        The final caveat is that this data requires some expertise to interpret. No algorithms have been applied to the data as of yet. Therefore clinical correlation is essential. By using this software, you agree to hold the author harmless for any errors in the code and in any clinical context that this information is applied. This program has NOT been tested or evaluated in a clinical setting as of yet. Its only value at present may be for screening purposes. Until controlled studies of this utility are performed in a sleep lab, other diagnostic modalities are needed.

        The required dependencies include:

        1. The Visual Basic 6.0 Runtime Files (SP6) are NOT provided as they are standard on WIndows 2000/NT/XP. For Windows 9X, they may need to be installed. (www.microsoft.com)
           
        2. SAPI 4.0 Microsoft Direct Speech Recognition(www.microsoft.com) Here is the installation".exe.": (http:\\www.moosenose.com\actcnc.exe)
           
        3. GpCapture.OCX 1394 by Genghis Khan
          (
          http:\\www.moosenose.com\Actigraphics-OCXs.zip)
           
        4. ezVidCap Component by Ray Mercer
          (
          http:\\www.moosenose.com\Actigraphics-OCXs.zip)
           
        5. Microsoft Chart Control 6.0 (OLEDB)
           
        6. Microsoft Windows Common Controls 6.0 (SP6)
           
        7. ActiveMovie control type library (quartx.dll)
           
        8. The program and source code:
          http:\\
          www.moosenose.com\Actigraphics_with-OCXs.zip

        9. Support Documentation Files:
           
        10. http:\\www.moosenose.com\SupportDocs.zip

         

        References to borrowed code and support documentation is included in the SupportDocs.zip file included in the archive as are the source code and activeX OCXs.

        Screen Shots

         


        The form is locked and accepts no input from the mouse except a double click. After a double-click, the right click context button (below) is available and all data logging ceases. Adjusting the mouse sensitivity (movement and double-click) can now be selected from the menu as well (below).


        A 30 second delay has been added to fascilate settling in to bed.


        The program may be restarted from this menu or by Clicking "Start". A new data set will be created within a new directory (..\Actigraphics\Actigraphics) and the old directory is renamed. When "NO Audio/VIdeo Capture" is checked, both the webcam and DVcam are disabled.


         
        A variety of 2D and 3D plots are available for the 3 data series. Some may take longer than others to plot. I find the 2D Bar or 2D line to be most useful.


        The Legend displays actig video & audio and clicking the  square to the left selects the data points which when clicked, show the time in the caption. Then by scrolling the captured video, one can correlate arousals with movement and noise. Thus one can easily identify movement with sound and video.

        The form can be resized and the chart can also be resized and moved. All text (except the legend and labels) and tool bars can be moved as well.
        No data files are over-written and every time the program starts/re-starts a new directory is created. You may scroll these directories and rename them to patient names if you like. The numbering corresponds in 2 number sequences to day, month, year, hour, minute and second.


        The video will be displayed automatically:
         
        The file sizes can be limited by adjusting the format video and audio settings. 40 seconds at 160x120, 24 bit video, 11.025 kHz and 8 bit Mono audio, results in an avi file of about 25MB (8000kHz and 8 bit mono yields 10MB).


        One may peruse the every 5 minute realtime actigraphy here:

        Menu options were added to adjust the mouse and disable the screen saver.

        One probably should adjust the mouse sensitivity to the fastest double click possible so the program isn't inadvertently ended with movement:

        This will likely be remedied when I figure out a global hook to the keyboard that works.
        The screen saver should be disabled despite the fact that intermittent mouse movement would likely keep it at bay.
         

        The remainder of the program aspects are featured in the animation above. This is a work in progress and hopefully this document will keep up with improvements.

        Future additions will be dictated by convenience and perhaps request:

        • Demographics, history and physical.
        • Sleep Questionarre
        • Epworth Sleepiness Score
        • Restless Leg Criteria
        • Patient Filing and Database
        • Incorporate Pulse Oximetry
        • Incorporate EKG and Heart Rate
        • Respiratory Rate
        • Output to printer and CD/DVD
        • Scanning of Sleep Studies and Patients' pictures
        • Body Mass Index
        • Cephalometrics...