mesa
Classes
MesaSleepStage
MESA sleep stages
MesaDataset
MESA dataset
Parameters:
-
target_rate
(int
, default:128
) –Target rate. Defaults to 128.
Source code in sleepkit/datasets/mesa.py
Attributes
subject_ids
property
Functions
uniform_subject_generator
uniform_subject_generator(
subject_ids: list[str] | None = None, repeat: bool = True, shuffle: bool = True
) -> SubjectGenerator
Yield Subject IDs uniformly.
Parameters:
-
subject_ids
(list[str]
, default:None
) –Array of subject ids. Defaults to None.
-
repeat
(bool
, default:True
) –Whether to repeat generator. Defaults to True.
-
shuffle
(bool
, default:True
) –Whether to shuffle subject ids. Defaults to True.
Returns:
-
SubjectGenerator
(SubjectGenerator
) –Subject generator
Source code in sleepkit/datasets/mesa.py
load_signal_for_subject
load_signal_for_subject(
subject_id: str, signal_label: str, start: int = 0, data_size: int | None = None
) -> npt.NDArray[np.float32]
Load signal into memory for subject at target rate (resampling if needed) Args: subject_id (str): Subject ID signal_label (str): Signal label start (int): Start location @ target rate data_size (int): Data length @ target rate Returns: npt.NDArray[np.float32]: Signal
Source code in sleepkit/datasets/mesa.py
extract_sleep_events
Extract sleep apnea events for subject Args: subject_id (str): Subject ID Returns: list[tuple[int, float, float]]: Apnea events (apnea, start_time, duration)
Source code in sleepkit/datasets/mesa.py
extract_sleep_apneas
Extract sleep apnea events for subject Args: subject_id (str): Subject ID Returns: list[tuple[int, float, float]]: Apnea events (apnea, start_time, duration)
Source code in sleepkit/datasets/mesa.py
extract_sleep_stages
Extract sleep stages for subject Args: subject_id (str): Subject ID Returns: list[tuple[int, float, float]]: Sleep stages (stage, start_time, duration)
Source code in sleepkit/datasets/mesa.py
get_subject_duration
Get subject duration in seconds
Source code in sleepkit/datasets/mesa.py
sleep_stages_to_mask
sleep_stages_to_mask(sleep_stages: list[tuple[int, float, float]], data_size: int) -> npt.NDArray[np.int32]
Convert sleep stages to mask array Args: sleep_stages (list[tuple[int, float, float]]): Sleep stages data_size (int): Data size Returns: npt.NDArray[np.int32]: Sleep mask
Source code in sleepkit/datasets/mesa.py
apnea_events_to_mask
apnea_events_to_mask(apnea_events: list[tuple[int, float, float]], data_size: int) -> npt.NDArray[np.int32]
Convert apnea events to mask array Args: apnea_events (list[tuple[int, float, float]]): Apnea events data_size (int): Data size Returns: npt.NDArray[np.int32]: Apnea mask
Source code in sleepkit/datasets/mesa.py
download
Download STAGES dataset from the NSRR website.
Parameters:
-
num_workers
(int | None
, default:None
) –parallel workers. Defaults to None.
-
force
(bool
, default:False
) –Force redownload. Defaults to False.