yasa.Hypnogram.to_json#

Hypnogram.to_json(fname)[source]#

Save the Hypnogram to a JSON file.

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

This method delegates to to_dict for serialization.

Added in version 0.7.0.

Parameters:
fnamestr or path-like

Output file path. By convention, use a .json extension.

See also

to_dict

Return the same representation as an in-memory dictionary.

from_json

Reload the Hypnogram from a JSON file.