We use cookies and other tools to enhance your experience on our website and to analyze our web traffic.
For more information about these cookies and the data collected, please refer to our Privacy Policy.

Casting (Moon)light on NSRR data

Want to be an early adopter of two new web-based tools (Moonlight & Moonbeam) for sleep signals, specifically designed to view NSRR data? If so, 1) read on, 2) head to https://remnrem.net/ to play with them and 3) please do give us any feedback.

What is Moonlight?

Moonlight is an interactive viewer for polysomnographic data. It is built on top of the command-line Luna package (https://zzz.bwh.harvard.edu/luna/), written using R and the Shiny library. As well as visualization, Moonlight supports manipulations of sleep data (filtering, subsetting, resampling, referencing, etc), a range of summary statistics, and hypnogram-based analyses including automated staging using POPS. You can learn more about Moonlight by following this tutorial.

What is Moonbeam?

Moonlight was originally designed for use with data located on your own, local machine. Moonbeam is a new extension, to directly pull web-based datasets into Moonlight. For NSRR users, you can click on the Moonbeam button (on the left panel of the main Moonlight page) and it will bring up this type of dialog box:

As an NSRR user, you can obtain your personalized token by visiting http://sleepdata.org/token. (This is the same token you’d use for the NSRR Ruby download gem, which is fixed but specific to each NSRR user.) After pasting in your token and clicking Authenticate, you will see a list of available cohorts. The exact list will depend on which NSRR cohorts you have permission to access.

After selecting the cohort, the rightmost menu will be populated with the IDs of all recordings. Select one and click Import and after a little while the EDF and annotation data will be imported into Moonlight. As below, a new Moonbeam panel shows any covariate data for that individual, taken from the associated .csv files, in a searchable table that also lists the definitions of each variable:

By selecting the Signals tab, you can view the raw signals, aligned to any annotations:

Moonlight supports numerous other visualization and data manipulation options. For example, here is a whole-night visualization of some signals based on epoch-level Hjorth parameters, which shows drop-out of the ECG for the middle part of the night:

See the Luna website for a more detailed description of the various functions.

Uploading your own data

As well as viewing NSRR data, Moonlight can also be used to view your own EDF/annotation files:

  • upload files directly from your local machine (top left menu item from the main page)

  • the “User URLs” option on the Moonbeam tab allows you to enter two links (HTTP URLs), for an EDF and (optionally) an annotation file (NSRR XML format, or Luna .annot/.eannot format). This can be handy, for example, if you have files stored on Dropbox or a similar cloud-based service that allows you to create shareable links to files. This can be quicker than uploading a large file from your own machine, particularly if you have a slow local internet connection. It can also be used to allow others to view your data easily, by simply sharing the links rather than having to share the original files.

Three ways to use Moonlight/Moonbeam

The easiest way to use Moonlight/Moonbeam is via our AWS-hosted instance, by visiting https://remnrem.net/. This has the advantage of not needing any installation, but may entail slower upload speeds to the cloud, and a limited number of instances will be available at any one time.

Alternatively, you can pull our Dockerized version, which runs on all platforms that can support Docker Desktop (see here). Once Docker is installed, to obtain/update the container, run this on the command-line:

docker pull remnrem/moonlight 

To run Moonlight, first type:

docker run -it --rm -p 3838:3838 remnrem/moonlight 

and then point your web browser to

Third, the most flexible and typically fastest option is to run Moonlight directly from R, using the lunaR library, although this requires the ability to install R and lunaR locally.

Notes & Caveats

  • Both Moonlight and Moonbeam are newly developed/developing packages: as such, you should expect a few rough edges.

  • Moonbeam is specifically designed to view single recordings: it is not the right tool for downloading entire cohorts.

  • Downloads typically take roughly 5-15 seconds, but this may vary depending on the recording, current load on the server and your own web connection. If the remnrem.net host is busy, you are likely to get better performance by using the local (Docker) version. If downloading a file fails (i.e. the page grays out with a spinning wheel that lasts for much longer than 20 or so seconds), close out the page and restart the app to try again. If the issue persists, please contact us.

  • This first release of Moonbeam does not include all NSRR datasets. All datasets (that have signal data) will be incorporated in the near future. Please contact us if a desired dataset if currently missing, we can upload it sooner rather than later.

  • Luna recognizes lights_off and lights_on annotations and calculates hypnogram statistics appropriately. However, lights on/off times are not currently integrated into NSRR annotations, so take care when interpreting metrics such as SOL and TIB.

  • We will monitor usage and interest in Moonlight/Moonbeam and potentially expand capacity of the AWS-hosted instance at https://remnrem.net


Please e-mail us at luna.remnrem@gmail.com with any feedback or questions.


By shaunpurcell on May 9, 2023 May 9, 2023 in Tools
no comments
· sorted by
Write a Reply