Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hypno plot errors #159

Open
PhD-GOAT opened this issue Feb 6, 2024 · 1 comment
Open

Hypno plot errors #159

PhD-GOAT opened this issue Feb 6, 2024 · 1 comment
Assignees
Labels
bug 💥 Something isn't working

Comments

@PhD-GOAT
Copy link

PhD-GOAT commented Feb 6, 2024

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 💥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants