Session
SessionConfig
dataclass
SessionConfig(user_name: str = None, user_age: int = None, user_gender: str = None, classes: list = lambda: ['default'](), trials: int = 1, baseline_duration: float = 15, rest_duration: float = 2, ready_duration: float = 1, cue_duration: float = 1.5, motor_duration: float = 4, extra_duration: float = 0, save_dir: str = './sessions/', capture_blinks: bool = False)
Configuration settings for a session.
Attributes:
Name | Type | Description |
---|---|---|
user_name |
str
|
Name of the user. |
user_age |
int
|
Age of the user. |
user_gender |
str
|
Gender of the user. |
classes |
list
|
List of class names for the session. |
trials |
int
|
Number of trials per class. |
baseline_duration |
float
|
Duration of the baseline phase in seconds. |
rest_duration |
float
|
Duration of the rest phase in seconds. |
ready_duration |
float
|
Duration of the ready phase in seconds. |
cue_duration |
float
|
Duration of the cue phase in seconds. |
motor_duration |
float
|
Duration of the motor phase in seconds. |
extra_duration |
float
|
Additional random duration added to motor phase. |
save_dir |
str
|
Directory to save session data. |
capture_blinks |
bool
|
Whether to capture blink events. |
Session
Session(headset: MindWaveMobile2, config: SessionConfig, lazy_start: bool = True)
Manages EEG headset data collection sessions.
This class handles the configuration, execution, and data storage of EEG data collection sessions.
It also emits signals at different stages of the session, this can be used to build a UI on top of it.
Session flow:
- Session Start signal: Indicates the start of the session.
- Baseline Start signal: Indicates the start of the baseline phase.
- Baseline End signal: Indicates the end of the baseline phase.
for trial in range(trials*len(classes)):
- Trial Start signal: Indicates the start of a new trial associated with a class.
- Rest signal: Indicates the rest phase before starting the motor imagery task.
- Ready signal: Indicates the ready phase before the cue.
- Cue signal: Indicates the cue phase for the motor imagery task.
- Motor signal: Indicates the start of the motor imagery task.
- Trial End signal: Indicates the end of the trial associated with a class.
- Session End signal: Indicates the end of the session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
headset
|
MindWaveMobile2
|
The MindWave Mobile 2 headset instance. |
required |
config
|
SessionConfig
|
The configuration settings for the session. |
required |
lazy_start
|
bool
|
Whether to start the session immediately after initialization. |
True
|
Source code in mindwave/session.py
start
Starts the data collection session.
NOTE: The headset must be running before starting the session.
Source code in mindwave/session.py
stop
Stops the data collection session.
Source code in mindwave/session.py
save
Saves the collected session data and events to disk.
Source code in mindwave/session.py
on_signal
on_signal(listener: Callable[[SessionEvent], Any]) -> Subscription
Registers a listener for session signals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listener
|
Callable[[SessionEvent], Any]
|
The listener function to be called when a session event is emitted. |
required |
Returns:
Name | Type | Description |
---|---|---|
Subscription |
Subscription
|
A Subscription object that can be used to unsubscribe the listener. |