Sleep plots


source

get_legend_colors

 get_legend_colors (cmap='muted')

source

format_xticks

 format_xticks (ax, format='%m/%d %H:%M')

format datestrings on x axis


source

plot_channels

 plot_channels (channels:pandas.core.frame.DataFrame,
                array_index:Optional[int]=None,
                y_filter:Optional[Iterable[str]]=None,
                ax:matplotlib.axes._axes.Axes=None,
                discrete_events:Optional[Iterable[str]]=['sleep_stage',
                'body_position'], time_col='collection_timestamp',
                height=1.5, resample='1s', cmap='muted',
                rename_channels={'actigraph': 'Actigraph',
                'body_position': 'Body Position', 'heart_rate': 'Heart
                Rate', 'heart_rate_raw': 'Heart Rate Raw', 'pat_infra':
                'PAT Infra', 'pat_amplitude': 'PAT Amplitude', 'pat_lpf':
                'PAT LPF', 'respiratory_movement': 'Respiratory Mov.',
                'spo2': 'SpO2', 'snore_db': 'Snore dB', 'pat_view': 'PAT
                View', 'sleep_stage': 'Sleep Stage'}, **kwargs)

plot channels data for a given participant and array_index


source

plot_events

 plot_events (events:pandas.core.frame.DataFrame,
              array_index:Optional[int]=None,
              x_start:str='collection_timestamp', x_end:str='event_end',
              y:str='event', color:str='channel', cmap:str='muted',
              set_xlim:bool=True, xlim:Iterable[float]=None,
              figsize:Iterable[float]=[10, 4],
              y_include:Optional[Iterable[str]]=None,
              y_exclude:Optional[Iterable[str]]=None,
              ax:matplotlib.axes._axes.Axes=None,
              add_events:Optional[pandas.core.frame.DataFrame]=None,
              rename_channels:dict={'PAT Amplitude': 'PAT', 'PulseRate':
              'Heart Rate'}, rename_events:dict={})

plot an events timeline for a given participant and array_index


source

plot_sleep

 plot_sleep (events:pandas.core.frame.DataFrame,
             channels:pandas.core.frame.DataFrame,
             array_index:Optional[int]=None,
             trim_to_events:Optional[bool]=True,
             add_events:Optional[pandas.core.frame.DataFrame]=None,
             event_filter:Optional[Iterable[str]]=None,
             channel_filter:Optional[Iterable[str]]=['actigraph',
             'pat_infra', 'body_position', 'snore_db', 'heart_rate',
             'spo2'], event_height:float=2, channel_height:float=0.45,
             width:float=10, aspect:float=0.2, style:str='whitegrid',
             xlim:Iterable[float]=None, **kwargs)

Plot sleep events and channels data.

Args:

events (pd.DataFrame): A pandas dataframe containing sleep events data.
channels (pd.DataFrame): A pandas dataframe containing raw channels data.
array_index (int, optional): The index of the array. Defaults to None.
trim_to_events (bool, optional): Whether to trim the plot to the start and end of the events. Defaults to True.
add_events (pd.DataFrame, optional): Additional events data to include in the plot. Defaults to None.
event_filter (Iterable[str], optional): A list of events to include in the plot. Defaults to None.
channel_filter (Iterable[str], optional): A list of channels to include in the plot. Defaults to DEFAULT_CHANNELS.
event_height (float, optional): The height of the event plot in inches. Defaults to 2.
channel_height (float, optional): The height of each channel plot in inches. Defaults to 0.45.
width (float, optional): The width of the plot in inches. Defaults to 10.
aspect (float, optional): The aspect ratio of the plot. Defaults to 0.2.
style (str, optional): The seaborn style to use. Defaults to 'whitegrid'.
xlim (List[float], optional): The x-axis limits of the plot. Defaults to None.
**kwargs: Additional arguments to be passed to plot_channels().

Returns:

None