The feedback module provides a flexible framework for implementing real-time feedback mechanisms in BCI experiments. It supports both visual and auditory feedback, allowing researchers to create customized feedback paradigms for their specific needs.
Feedback in BCI systems is crucial for providing users with information about their brain activity in real-time. This module implements a robust feedback system that can be easily extended and customized for different experimental paradigms.
Feedback: Abstract base class that defines the interface for all feedback mechanisms- Provides common functionality for feedback administration
- Defines abstract methods that must be implemented by subclasses
- Manages feedback type registration and logging
The module supports two main types of feedback:
-
Visual Feedback (
VisualFeedback)- Displays text or image stimuli on screen
- Supports customizable positioning, timing, and appearance
- Provides precise timing control for stimulus presentation
- Features:
- Text and image stimulus support
- Configurable font, size, and color
- Position control
- Timing synchronization
-
Auditory Feedback (
AuditoryFeedback)- Plays sound stimuli through the system's audio output
- Supports various audio formats and sampling rates
- Provides timing control for audio presentation
- Features:
- Sound playback
- Configurable audio parameters
- Timing synchronization
from bcipy.feedback.visual.visual_feedback import VisualFeedback
from psychopy import visual
from bcipy.helpers.clock import Clock
# Initialize display window
window = visual.Window(size=[800, 600])
# Configure parameters
parameters = {
'feedback_font': 'Arial',
'feedback_stim_height': 0.1,
'feedback_pos_x': 0,
'feedback_pos_y': 0,
'feedback_duration': 1.0,
'feedback_color': 'white'
}
# Create feedback instance
clock = Clock()
feedback = VisualFeedback(window, parameters, clock)
# Administer feedback
timing = feedback.administer("Hello World", StimuliType.TEXT)from bcipy.feedback.sound.auditory_feedback import AuditoryFeedback
from psychopy import core
import numpy as np
# Configure parameters
parameters = {
'sound_buffer_time': 1.0
}
# Create feedback instance
clock = core.Clock()
feedback = AuditoryFeedback(parameters, clock)
# Generate a simple tone
fs = 44100 # sampling frequency
t = np.linspace(0, 1, fs) # 1 second duration
sound = np.sin(2 * np.pi * 440 * t) # 440 Hz sine wave
# Administer feedback
timing = feedback.administer(sound, fs)Both feedback types can be configured through a parameters dictionary. Common parameters include:
- Timing parameters (duration, intervals)
- Display parameters (position, size, color)
- Stimulus-specific parameters (font, audio format)
The feedback module provides precise timing control through:
- Clock synchronization
- Timestamp recording
- Buffer time management
To create a new feedback type:
- Create a new class inheriting from
Feedback - Implement the required abstract methods:
configure()administer()
- Register the new feedback type in
FeedbackTypeenum
- Always use the provided timing mechanisms for synchronization
- Handle exceptions appropriately in feedback administration
- Clean up resources after feedback presentation
- Use appropriate buffer times for smooth presentation
- Test feedback timing in your specific experimental setup
- PsychoPy documentation for visual stimulus presentation
- SoundDevice documentation for audio playback
- BciPy documentation for integration with other modules