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

Question about REM density #175

Open
laura-hainke opened this issue Jul 3, 2024 · 3 comments
Open

Question about REM density #175

laura-hainke opened this issue Jul 3, 2024 · 3 comments
Assignees
Labels
question 🙋 Further information is requested

Comments

@laura-hainke
Copy link

Hello, how is rapid eye movement density calculated with YASA? After using rem_detect() and summary(), the parameter "Density" is shown, but what is the unit? Thank you!

@raphaelvallat
Copy link
Owner

Hi @laura-hainke,

The density parameter is the number of events per minute:

yasa/yasa/detection.py

Lines 220 to 233 in b1e866c

# Calculate density (= number per min of each stage)
if self._hypno is not None and grp_stage is True:
stages = np.unique(self._events["Stage"])
dur = {}
for st in stages:
# Get duration in minutes of each stage present in dataframe
dur[st] = self._hypno[self._hypno == st].size / (60 * self._sf)
# Insert new density column in grouped dataframe after count
df_grp.insert(
loc=df_grp.columns.get_loc("Count") + 1,
column="Density",
value=df_grp.apply(lambda rw: rw["Count"] / dur[rw["Stage"]], axis=1),
)

Thanks,
Raphael

@raphaelvallat raphaelvallat added the question 🙋 Further information is requested label Jul 4, 2024
@laura-hainke
Copy link
Author

Thanks for clarifying, Raphael!

@remrama
Copy link
Collaborator

remrama commented Oct 7, 2024

Probably worth adding this quickly to the documentation before closing the issue. (I'll do it.)

@remrama remrama self-assigned this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🙋 Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants