본문 바로가기
Somnology/BioPsyKit

[BioPsyKit] 수면 분석 (관성 측정 장치)

by goatlab 2023. 6. 25.
728x90
반응형
SMALL

import

 

from pathlib import Path
import pandas as pd
import numpy as np
from fau_colors import cmaps
import biopsykit as bp
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline
%load_ext autoreload
%autoreload 2

plt.close("all")

palette = sns.color_palette("Set2")
sns.set_theme(context="notebook", style="ticks", font="sans-serif", palette=palette)

plt.rcParams["figure.figsize"] = (8, 4)
plt.rcParams["pdf.fonttype"] = 42
plt.rcParams["mathtext.default"] = "regular"

palette

 

데이터셋 다운

 

# Example dataset
data, fs = bp.example_data.get_sleep_imu_example()

### Alternatively: Load your own dataset
# data, fs = bp.io.nilspod.load_dataset_nilspod("<path-to-imu-file>") # or any other way to load a file containing IMU data
data.head()

 

plot

 

fig, ax = bp.sleep.plotting.sleep_imu_plot(data, downsample_factor=5 * fs, palette = palette)

 

 

수면 종점 계산

 

sleep_results = bp.sleep.sleep_processing_pipeline.predict_pipeline_acceleration(
    data, sampling_rate=fs, epoch_length=60
)

sleep_endpoints = sleep_results["sleep_endpoints"]
sleep_endpoints.keys()
dict_keys(['date', 'sleep_onset', 'wake_onset', 'total_sleep_duration', 'net_sleep_duration', 'bed_interval_start', 'bed_interval_end', 'sleep_efficiency', 'sleep_onset_latency', 'getup_latency', 'wake_after_sleep_onset', 'sleep_bouts', 'wake_bouts', 'number_wake_bouts'])
fig, ax = bp.sleep.plotting.sleep_imu_plot(data, sleep_endpoints=sleep_endpoints, downsample_factor=5 * fs)

 

https://biopsykit.readthedocs.io/en/latest/examples/_notebooks/Sleep_IMU_Example.html

 

Sleep IMU Example — BioPsyKit 0.9.0 documentation

Note: An inertial measurement unit (IMU) is a sensor that measures a body’s acceleration (using accelerometers) and angular rate (using gyroscopes). In medical and psychological applications IMUs are commonly used for activity monitoring, movement analys

biopsykit.readthedocs.io

 

728x90
반응형
LIST

'Somnology > BioPsyKit' 카테고리의 다른 글

BioPsyKit  (0) 2023.06.22