Annotations#

brainmaze_utils.annotations.create_day_indexes(df: ~pandas.core.frame.DataFrame, hour: int | float = 12, tzinfo: ~dateutil.tz._common._tzinfo = <class 'dateutil.tz.tz.tzlocal'>)#

Creates a day index for each epoch within the annotations, given the day-time hour supplied as input parameter. The format of start and end has to be an integer or a float in a form representing a timestamp, or a timezone aware datetime or Timestamp object. If the start and end format do not include timezone, the local timezone will be used.

brainmaze_utils.annotations.create_duration(dfHyp)#

Creates duration for each epoch within the annotations. (Faster on timestamp)

brainmaze_utils.annotations.filter_by_duration(dfAnnotations: DataFrame, duration: int | float)#

Keeps only epochs of the duration given by the input.

brainmaze_utils.annotations.filter_by_key(dfAnnotations: DataFrame, key: str, value: int | float)#

Keeps only annotations given by the key and value within the pandas DataFrame

brainmaze_utils.annotations.load_CyberPSG(path, tile=None, verbose=True)#
brainmaze_utils.annotations.load_NSRR(path)#
brainmaze_utils.annotations.merge_annotations(df: DataFrame)#

Merges epochs with the same annotation and end[i-1] == start[i]

Updated on 2025-03-27 by F. Mivalt for pandas in Python 3.12

Parameters:
  • df (pd.DataFrame) – DataFrame with ‘start’, ‘end’, and ‘annotation’ columns representing merged annotations.

  • dur_threshold (int) – The desired size of each chunk in seconds.

Returns:

DataFrame with tiled annotations.

Return type:

pd.DataFrame

brainmaze_utils.annotations.save_CyberPSG(path, df)#
brainmaze_utils.annotations.tile_annotations(df: DataFrame, dur_threshold: int | float = 30)#

Optimized tile_annotations using vectorized operations. Tiles epochs to the max duration given by dur_threshold in seconds. Reverse to the ‘merge annotations’.

Parameters:
  • df (pd.DataFrame) – DataFrame with ‘start’, ‘end’, and ‘annotation’ columns representing merged annotations.

  • dur_threshold (int) – The desired size of each chunk in seconds.

Returns:

DataFrame with tiled annotations.

Return type:

pd.DataFrame

brainmaze_utils.annotations.time_to_local(dfHyp)#

Converts the time into the local timezone. Default by python and PC. Does not enter the timezone explicitely. Cannot be used for creating a annotations figure.

brainmaze_utils.annotations.time_to_timestamp(dfHyp)#

Converts the annotations time to timestamp.

brainmaze_utils.annotations.time_to_timezone(dfHyp, tzinfo)#

Converts the annotations into a timezone. The timezone has to be from a python library dateutil

brainmaze_utils.annotations.time_to_utc(dfHyp)#

Converts time to the UTC format.