Event Management

Triggers

class tad.Triggers(slots)[source]

Bases: object

Container for a list of time slots representing triggers.

Parameters:

slots (List[tad.Triggers.TimeSlot]) – List of TimeSlot objects representing the triggers.

add_interval_slot(start, end, ID=None, description=None, blank=False)[source]

Add a new time slot to the triggers.

Parameters:
  • start (float) – Start time of the new slot.

  • end (float) – End time of the new slot.

  • ID (int | None) – Optional identifier for the new slot.

  • description (str | None) – Optional description for the new slot.

  • blank (bool | None) – Optional flag to indicate if the slot should be blanked out in the analysis (e.g., for artifact removal).

Return type:

None

add_timed_slot(tstart, duration, ID=None, description=None, blank=False)[source]

Add a new time slot to the triggers.

Parameters:
  • tstart (float) – Start time of the new slot.

  • duration (float) – Duratino of the new slot.

  • ID (int | None) – Optional identifier for the new slot.

  • description (str | None) – Optional description for the new slot.

  • blank (bool | None) – Optional flag to indicate if the slot should be blanked out in the analysis (e.g., for artifact removal).

Return type:

None

check_overlaps()[source]

Check for overlapping time slots.

Returns:

A list of tuples, where each tuple contains the indices of the overlapping slots.

Return type:

List[tuple]

load_from_json(filepath)[source]

Load triggers from a JSON file.

Parameters:

filepath (str) – Path to the JSON file from which the triggers will be loaded.

Return type:

None

save2json(filepath)[source]

Save the triggers to a JSON file.

Parameters:

filepath (str) – Path to the JSON file where the triggers will be saved.

Return type:

None

slots: List[TimeSlot]
sort_slots()[source]

Sort the time slots in ascending order based on their start times.

Return type:

None

TimeSlot

class tad.TimeSlot(start, end, ID=None, description=None, blank=False)[source]

Bases: object

Represents a time slot with a start and end time.

Parameters:
  • start (float) – Start time of the slot.

  • end (float) – End time of the slot.

  • ID (int | None) – Optional identifier for the slot

  • description (str | None) – Optional description for the slot

  • blank (bool | None) – Optional flag to indicate if the slot should be blanked out in the analysis (e.g., for artifact removal)

ID: int | None = None
blank: bool | None = False
description: str | None = None
duration()[source]

Compute the duration of the time slot.

Returns:

Duration of the slot (end - start).

Return type:

float

end: float
start: float

Trigger Functions

tad.load_triggers_from_json(filepath)[source]

Load triggers from a JSON file.

Parameters:

filepath (str) – Path to the JSON file from which the triggers will be loaded.

Returns:

A list of TimeSlot objects representing the triggers.

Return type:

TimeSlot