yasa.Hypnogram.to_dict#

Hypnogram.to_dict()[source]#

Return the Hypnogram as a JSON-serializable dictionary.

All metadata is preserved: epoch duration, start datetime (including timezone), scorer name, and stage probabilities. Stage probabilities (proba) are rounded to 6 decimal places.

The dictionary has the following keys: "values", "n_stages", "freq", "start", "scorer", "proba". It can be passed to from_dict to reconstruct the Hypnogram.

Added in version 0.7.0.

Returns:
ddict

A JSON-serializable dictionary representing the Hypnogram and all its metadata.

See also

from_dict

Reconstruct a Hypnogram from a dictionary.

to_json

Save the Hypnogram to a JSON file on disk.