Luna: software for the analysis of sleep signal data
Luna is an open-source C/C++ software package for manipulating and
analyzing polysomnographic recordings, with a focus on the sleep EEG.
Originally oriented around command-line scripting
(lunaC), we are developing various extensions,
including the Python module
lunapi and the lunaR library
for the R statistical package. The
current release is v1.3.4 (27-Feb-2026): see here for
a list of changes/additions. Please direct any questions to luna.remnrem@gmail.com. For
background on the project itself, see About.
LunaScope
LunaScope is a new interactive GUI for Luna, built on top of lunapi. It provides a more full-featured point-and-click environment for visual review and interactive analysis.
A family of Luna tools

The Luna package comprises a number of related components, all of which are oriented around the same core C/C++ library. The core library implements all the commands for working with sleep signal data. There are three main ways to use the library, all of which provide fundamentally the same basic functionality:
-
via LunaScope, an interactive point-and-click GUI built on top of lunapi: this is often the easiest entry point for visual review and exploratory analysis
-
via scope, an interactive viewer for JupyterLab using lunapi: this is a lighter-weight embedded viewing option inside Python notebooks
-
via the lunaC command-line tool: this is the original interface, and is still the best approach for working with large datasets, ideally with scripted analyses and using a Unix-like cluster-computing environment
-
via the lunapi Python package: this is the best approach for interactive analyses and for those familiar with Python
-
via the lunaR R library: users more familiar with R may prefer this option, although current development emphasis is on the Python interface and related GUI tools
These tools can either be installed individually or they can be accessed via prebuilt Docker containers
Note
In this documentation, we often refer to lunaC simply as
Luna. Also, luna is the filename of both the actual command line
executable and the R package, and so we use the terms lunaC to disambiguate it from
lunapi or lunaR where necessary. Most material is
common to all packages, as they are based on the same basic C/C++ Luna
library.
Getting started
For the recommended newcomer route through the documentation, start with Path. That page lays out the suggested order through the tutorial, concepts, walk-through, and reference pages for command-line Luna, lunapi, and LunaScope.
Things Luna aims to do
The Commands pages list all supported functionality; main areas are summarized below.
Primary use cases
- Read, manipulate and write large sets of EDF and EDF+ signals
- Filter, resample and re-reference signals
- Generate a variety of (per-epoch) summary statistics
- Statistical artifact detection for EEG channels
- Annotate and mask/filter epochs
- Estimate key features of sleep macro-architecture
- Automated sleep staging
- Spectral analyses
- Spindle and slow oscillation detection
- Coherence and cross-frequency coupling
- Multi-channel, topographical analyses
- Interval-based analyses of event timing
- Sample-level linear association models
- Manipulating annotation data and meta-data
- Visual data exploration via LunaScope or scope
Areas of ongoing development
- Multi-day recordings and actigraphy metrics
- HRV metrics
- Automated PSG QC
- Predictive modeling, including biological age
Things Luna doesn't aim to do
Luna was originally designed to work with the large number of polysomnograms at the NSRR, with a focus on intersecting sleep EEG signals with other annotations. As such, some areas are not well supported, or effectively outside of Luna's scope.
Areas outside of Luna's primary focus
-
Methods development platform: although the Python/R extensions can support methods development, other tools (including general purpose Matlab packages such as EEGLAB) will be better suited for expert users interested in flexibly altering and developing new analyses
-
Analyses of cardiac and respiratory events: most of Luna's specialized sleep analyses are currently focused on EEG signals (e.g. spindles and slow oscillations)
-
Online signal processing: Luna is set up for all analyses being done offline, i.e. on the entire recording
-
Support for multiple formats: currently, Luna is mainly based around EDF and EDF+ files (as well as plain text)