Hypno plot errors
PhD-GOAT opened this issue · 1 comments
PhD-GOAT commented
import pandas as pd
import yasa
hypno = pd.read_csv("yasa_example_night_young_hypno.csv")
yasa.plot_hypnogram(hypno)
AssertionError Traceback (most recent call last)
[<ipython-input-2-b11aab9cd069>](https://localhost:8080/#) in <cell line: 4>()
2 hypno = pd.read_csv("yasa_example_night_young_hypno.csv")
3 import yasa
----> 4 yasa.plot_hypnogram(hypno);
[/usr/local/lib/python3.10/dist-packages/yasa/plotting.py](https://localhost:8080/#) in plot_hypnogram(hyp, lw, highlight, fill_color, ax)
68 from yasa.hypno import Hypnogram # Avoiding circular import
69
---> 70 assert isinstance(hyp, Hypnogram), "`hypno` must be YASA Hypnogram."
71
72 # Work with a copy of the Hypnogram to not alter the original
AssertionError: `hypno` must be YASA Hypnogram.
raphaelvallat commented
Hi @PhD-GOAT,
Thanks for reporting on this issue. I have just submitted a fix here, but I might wait for a few weeks before releasing a new version of YASA on PyPI. In the meantime, the following code should work:
import pandas as pd
import yasa
hypno = pd.read_csv("yasa_example_night_young_hypno.csv")
# Convert to the new Hypnogram format, assuming that the hypnogram is at 30-seconds resolution
hyp = yasa.Hypnogram(yasa.hypno_int_to_str(hypno), freq="30s")
yasa.plot_hypnogram(hyp)
Let me know if that worked for you,
Thanks,
Raphael