Timeseries plots


source

filter_df

 filter_df (df:pandas.core.frame.DataFrame, participant_id:int=None,
            array_index:int=None, time_range:Tuple[str,str]=None,
            x_start:str='collection_timestamp',
            x_end:str='collection_timestamp', unique:bool=False)

*Reformat and filter a time series DataFrame based on participant ID, array index, and date range.

Args: df (pd.DataFrame): The DataFrame to filter. participant_id (int): The participant ID to filter by. array_index (int): The array index to filter by. time_range: The date range to filter by. Can be a tuple of two dates / times or two strings. x_start (str): The name of the column containing the start time. x_end (str): The name of the column containing the end time.

Returns: pd.DataFrame: The filtered DataFrame*


source

format_xticks

 format_xticks (ax:matplotlib.axes._axes.Axes, xticks:Iterable=None,
                format:str='%d/%m\n%H:%M', **kwargs)

format datestrings on x axis


source

TimeSeriesFigure

 TimeSeriesFigure (figsize:tuple=(10, 6), padding:float=0.05)

*Initialize a TimeSeriesFigure instance. This class is used to create and manage a figure with multiple axes for time series data.

Args: figsize (tuple): Size of the figure (width, height) in inches.*


source

get_color_map

 get_color_map (data:pandas.core.frame.DataFrame, hue:str, palette:str)

*Get a color map for a specific column in the data.

Args: data (pd.DataFrame): The data to get the color map from. hue (str): The column name to use for the color map. palette (str): The name of the colormap to use.

Returns: pd.DataFrame: A DataFrame with the color map.*


source

get_events_period

 get_events_period (events_filtered:pandas.core.frame.DataFrame,
                    period_start:str, period_end:str, period_name:str,
                    col:str='event', first_start:bool=True,
                    first_end:bool=True, include_start:bool=True,
                    include_end:bool=True,
                    x_start:str='collection_timestamp',
                    x_end:str='event_end')

*Get the period of time between the start and end events.

Args: events_filtered (pd.DataFrame): The events DataFrame. period_start (str): The label of the start event. period_end (str): The label of the end event. period_name (str): The label to assign to the period. col (str): The column name for the event labels. Default is ‘event’. first_start (bool): If True, get the first start event. Default is True. first_end (bool): If True, get the first end event. Default is True. include_start (bool): If True, include the start event in the period. Default is True. include_end (bool): If True, include the end event in the period. Default is True. x_start (str): The column name for the start time of the event. Default is ‘collection_timestamp’. x_end (str): The column name for the end time of the event. Default is ‘event_end’.

Returns: pd.DataFrame: The period of events in the same format as the input DataFrame.*


source

prepare_events

 prepare_events (events:pandas.core.frame.DataFrame, x_start:str,
                 x_end:str, hue:str, label:str, participant_id:int,
                 array_index:int, time_range:Tuple[str,str],
                 y_include:Iterable[str], y_exclude:Iterable[str],
                 add_columns:Iterable[str]=None, palette='muted')

*Prepare events for plotting.

Args: events (pd.DataFrame): The events dataframe. x_start (str): The column name for the start time of the event. x_end (str): The column name for the end time of the event. hue (str): The column name for the color of the event. label (str): The column name for the label of the event. participant_id (int): The participant ID to filter events by. array_index (int): The array index to filter events by. time_range (Iterable[str]): The time range to filter events by. y_include (Iterable[str]): The list of values to include in the plot. y_exclude (Iterable[str]): The list of values to exclude from the plot. add_columns (Iterable[str]): Additional columns to include in the plot. palette (str): The name of the colormap to use for coloring events.

Returns: Tuple[pd.DataFrame, pd.DataFrame]: The filtered events dataframe and the color map.*


source

plot_events_fill

 plot_events_fill (events:pandas.core.frame.DataFrame,
                   x_start:str='collection_timestamp',
                   x_end:str='event_end', hue:str='channel',
                   label:str=None, participant_id:Optional[int]=None,
                   array_index:Optional[int]=None,
                   time_range:Optional[Tuple[str,str]]=None,
                   y_include:Optional[Iterable[str]]=None,
                   y_exclude:Optional[Iterable[str]]=None,
                   legend:bool=True, palette:str='muted',
                   alpha:Optional[float]=0.5,
                   ax:Optional[matplotlib.axes._axes.Axes]=None,
                   figsize:Iterable[float]=[12, 6])

*Plot events as filled regions on a time series plot.

Args: events (pd.DataFrame): The events dataframe. x_start (str): The column name for the start time of the event. x_end (str): The column name for the end time of the event. hue (str): The column name for the color of the event. label (str): The column name for the label of the event. participant_id (int): The participant ID to filter events by. array_index (int): The array index to filter events by. time_range (Iterable[str]): The time range to filter events by. y_include (Iterable[str]): The list of values to include in the plot. y_exclude (Iterable[str]): The list of values to exclude from the plot. legend (bool): Whether to show the legend. palette (str): The name of the palette to use for coloring events. alpha (float): The transparency of the filled regions. ax (plt.Axes): The axis to plot on. If None, a new figure is created. figsize (Tuple[float, float]): The size of the figure (width, height) in inches.*


source

plot_events_bars

 plot_events_bars (events:pandas.core.frame.DataFrame,
                   x_start:str='collection_timestamp',
                   x_end:str='event_end', y:str='event',
                   hue:str='channel', participant_id:Optional[int]=None,
                   array_index:Optional[int]=None,
                   time_range:Optional[Tuple[str,str]]=None,
                   y_include:Optional[Iterable[str]]=None,
                   y_exclude:Optional[Iterable[str]]=None,
                   legend:bool=True, palette:str='muted',
                   alpha:Optional[float]=0.7,
                   ax:Optional[matplotlib.axes._axes.Axes]=None,
                   figsize:Tuple[float,float]=(12, 6))

*Plot events as bars on a time series plot.

Args: events (pd.DataFrame): The events dataframe. x_start (str): The column name for the start time of the event. x_end (str): The column name for the end time of the event. y (str): The column name for the y-axis values. hue (str): The column name for the color of the event. participant_id (int): The participant ID to filter events by. array_index (int): The array index to filter events by. time_range (Tuple[str, str]): The time range to filter events by. y_include (Iterable[str]): The list of values to include in the plot. y_exclude (Iterable[str]): The list of values to exclude from the plot. legend (bool): Whether to show the legend. palette (str): The name of the colormap to use for coloring events. alpha (float): The transparency of the bars. Default is 0.7. ax (plt.Axes): The axis to plot on. If None, a new figure is created. figsize (Tuple[float, float]): The size of the figure (width, height) in inches.*