poulet_py.utils.qst module#
- class TCSInterface(port, *, maximum_temperature=40, beep=False, trigger_out_channel=255, read_timeout=2, response_timeout=2, n_trials=1, stimuli=None, mode='random', interstimulus_period=0)[source]#
Bases:
TCSInterface class for the Thermal Cutaneous Stimulator (TCS) device.
Handles serial communication with the device and provides methods to configure and execute thermal stimulus experiments.
- Parameters:
port (str) – Serial port to which the device is connected.
maximum_temperature (float, optional) – Maximum allowed temperature in °C (default: 40).
beep (bool, optional) – Whether to enable audible beeps (default: False).
trigger_out_channel (int, optional) – Output channel for trigger signals (default: 255).
read_timeout (float, optional) – Timeout for read operations in seconds (default: 2).
response_timeout (float, optional) – Timeout for device responses in seconds (default: 2).
n_trials (int, optional) – Number of trials to run (default: 1).
stimuli (list[TCSStimulus], optional) – List of stimulus configurations (default: None).
mode ({'random', 'fixed'}, optional) – Stimulus presentation mode (default: ‘random’).
interstimulus_period (int or list[int], optional) – Time between stimuli in milliseconds (default: 0).
- stimuli#
List of configured stimulus sequences.
- Type:
list[TCSStimulus]
- n_trials#
Number of trials to be executed.
- Type:
int
- mode#
Stimulus presentation mode (‘random’ or ‘fixed’).
- Type:
str
- interstimulus_period#
Time between stimuli in milliseconds. assign a list of integers for random selection or a single integer for fixed time.
- Type:
int or list[int]
- __init__(port, *, maximum_temperature=40, beep=False, trigger_out_channel=255, read_timeout=2, response_timeout=2, n_trials=1, stimuli=None, mode='random', interstimulus_period=0)[source]#
Initialize TCS interface with validation.
- Args:
port: Serial port device path (e.g. ‘/dev/ttyUSB0’ or ‘COM3’) maximum_temperature: Safety limit for maximum allowed temperature (0-60°C) beep: Whether to enable audible beep during stimulation trigger_out_channel: Output channel of trigger signal (1-255) read_timeout: Serial read timeout in seconds response_timeout: Timeout for command responses in seconds
- property stimuli: list[TCSStimulus]#
Get or set the stimulus sequence.
- Returns:
Currently configured stimulus sequence.
- Return type:
list[TCSStimulus]
Notes
When setting the stimuli, they are automatically validated and a sequence is generated according to the configured mode (random/fixed) and number of trials.
- run(*, plot=False, max_plot_samples=1000)[source]#
Execute the configured experiment.
- Parameters:
plot (bool, optional) – Whether to show real-time plotting (default: False).
max_plot_samples (int, optional) – Maximum number of samples to show in the plot (default: 1000).
- Returns:
List of readings collected during the experiment.
- Return type:
list[dict]
- Raises:
ValueError – If no stimuli are configured before running.
Notes
Each reading contains: - timestamp: Time of reading - temperature: Current temperature - trial: Trial number - Other relevant parameters