Skip to content

BIDSBehEvent

BIDSBehEvent represents one row in a behavioral *_beh.tsv file.

Unlike BIDSTaskEvent, timing fields are optional and you can store flexible behavioral metadata.

Practical Example

from psychopy_bids import bids

event = bids.BIDSBehEvent(
    trial_type="rating",
    response_value=4,
    response_label="high_confidence",
)

When To Use It

  • Use for non-time-locked annotations.
  • Use for ratings, questionnaires, or block-level behavioral summaries.

API Reference

Bases: dict

A class that represents events of behavioral experiments.

This class is used for events that do not include the mandatory onset and duration columns. Events are, for example, stimuli presented to the participant or participant responses.

Examples:

>>> from psychopy_bids import bids
>>> event = bids.BIDSBehEvent(trial=1, resp='L')
Notes

For more details on behavioral experiment files, see BIDS Specification.

Source code in psychopy_bids/bids/bidsbehevent.py
class BIDSBehEvent(dict):
    """A class that represents events of behavioral experiments.

    This class is used for events that do not include the mandatory onset and duration columns.
    Events are, for example, stimuli presented to the participant or participant responses.

    Examples
    --------
    >>> from psychopy_bids import bids
    >>> event = bids.BIDSBehEvent(trial=1, resp='L')

    Notes
    -----
    For more details on behavioral experiment files, see [BIDS Specification](https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/07-behavioral-experiments.html).
    """

    def __init__(self, *args: tuple, **kwargs: dict) -> None:
        """Initialize a BIDSBehEvent object.

        Parameters
        ----------
        *args : tuple
            Any arguments that the object's superclass's `__init__` method might require.
        **kwargs : dict
            Any keyword arguments that the object's superclass's `__init__` method might require.
        """
        super().__init__(*args, **kwargs)
        self.__dict__ = self

    # -------------------------------------------------------------------------------------------- #

    def __repr__(self) -> str:
        """Return a printable representational string of the given object.

        This method returns a string representation of the BIDSBehEvent object containing its
        attribute-value pairs.

        Returns:
        -------
        str
            A string representation of the BIDSBehEvent object.
        """
        items = [f"{key}={value}" for key, value in self.items() if value is not None]
        return f"BIDSBehEvent({', '.join(items)})" if items else "BIDSBehEvent()"

__init__(*args, **kwargs)

Initialize a BIDSBehEvent object.

Parameters:

Name Type Description Default
*args tuple

Any arguments that the object's superclass's __init__ method might require.

()
**kwargs dict

Any keyword arguments that the object's superclass's __init__ method might require.

{}
Source code in psychopy_bids/bids/bidsbehevent.py
def __init__(self, *args: tuple, **kwargs: dict) -> None:
    """Initialize a BIDSBehEvent object.

    Parameters
    ----------
    *args : tuple
        Any arguments that the object's superclass's `__init__` method might require.
    **kwargs : dict
        Any keyword arguments that the object's superclass's `__init__` method might require.
    """
    super().__init__(*args, **kwargs)
    self.__dict__ = self

__repr__()

Return a printable representational string of the given object.

This method returns a string representation of the BIDSBehEvent object containing its attribute-value pairs.

Returns:

str A string representation of the BIDSBehEvent object.

Source code in psychopy_bids/bids/bidsbehevent.py
def __repr__(self) -> str:
    """Return a printable representational string of the given object.

    This method returns a string representation of the BIDSBehEvent object containing its
    attribute-value pairs.

    Returns:
    -------
    str
        A string representation of the BIDSBehEvent object.
    """
    items = [f"{key}={value}" for key, value in self.items() if value is not None]
    return f"BIDSBehEvent({', '.join(items)})" if items else "BIDSBehEvent()"