Skip to content

radiens_core.allego_client

AllegoClient — real-time data acquisition client.

Classes

AllegoClient

Bases: BaseClient

Client for real-time data acquisition and streaming.

Connects to a local Allego on its default ports.

Example
with AllegoClient() as client:
    params = client.get_stim_params()
METHOD DESCRIPTION
close

Close the client's server connections.

deselect_channels

Remove signals from the current selection, leaving the rest untouched.

disable_all_triggers

Disable all recording triggers.

disable_trigger

Disable a specific digital trigger channel.

enable_trigger

Enable a digital trigger channel to start or stop recording.

flash_sinaps

Flash new firmware to the Sinaps probe FPGA.

get_channel_metadata

Get current channel metadata for all connected channels.

get_core_config

Get core hardware configuration settings.

get_dac_reg

Get current DAC (Analog Output) register settings.

get_default_spike_sorter_id

Return Allego's spike sorter ID, whether or not the sorter is running.

get_detect_params

Fetch active detection configurations per channel.

get_dio_reg

Get current DIO (Digital Output) register settings.

get_dsp_group

Get current DSP filter configurations.

get_intan_impedance

Measure impedance for all channels on a specific port.

get_kpi_metrics

Retrieve computed KPI signal metrics from the live cache.

get_kpi_status

Get the current KPI computation status.

get_recording_config

Get current recording configuration settings.

get_signals

Retrieve signal data from the primary live cache.

get_sinaps_status_registers

Get the current Sinaps probe status registers.

get_spike_sorter_dashboard

Get the spike sorter dashboard for real-time monitoring.

get_spike_sorter_ids

Get the spike sorter IDs.

get_spike_sorter_state

Get the current state and progress of a spike sorter.

get_status

Get comprehensive system status.

get_stim_params

Get stimulation parameters for all configured channels.

get_stim_step

Get current stimulation step size setting.

get_trigger_state

Get current trigger channel configuration.

healthcheck

Verify the server is responsive.

load_all_mosi

Load all MOSI register values into the Sinaps probe.

manual_stim_trigger

Manually trigger stimulation.

manual_stim_trigger_toggle

Toggle manual stimulation trigger.

read_wire_out

Read a wire-out register value from the Sinaps FPGA.

restart

Restart the system with the specified backbone mode.

scan_ports

Scan all hardware ports to determine connected headstages and probes.

select_channels

Add signals to the current selection, leaving the rest selected.

set_channel_groups

Make the color groups exactly groups, discarding existing assignments.

set_core_config

Update core hardware configuration settings.

set_dac_gain

Set DAC (Analog Output) gain.

set_dac_highpass

Configure DAC (Analog Output) high-pass filter.

set_dac_off

Turn off all DAC (Analog Output) streams.

set_dac_stream

Map a source channel to a DAC (Analog Output) channel.

set_detect_params

Update detection parameters on the given channels.

set_dio_events

Configure DIO channel to trigger on analog threshold crossings.

set_dio_gated

Set DIO gated mode polarity.

set_dio_manual

Set DIO channel state manually.

set_dio_pulse

Configure DIO channel(s) for pulse mode.

set_dsp_group

Replace the filters of one DSP stage.

set_kpi_packet_dur

Set the KPI packet duration, the update granularity of the moving average.

set_kpi_update_period

Set how often the server processes newly arrived signal into KPI metrics.

set_record_state

Set data recording state.

set_recording_config

Set recording configuration settings.

set_selected_channels

Make the channel selection exactly signals.

set_stim_params

Update stimulation parameters for specified channels.

set_stim_step

Set the stimulation step size.

set_stim_trigger

Set the state of a stimulation keypress trigger.

set_stream_state

Set data streaming state.

set_trigger_state

Enable or disable a recording trigger channel.

spike_sorter_command

Send a command to an active spike sorter.

start_recording

Start recording data to disk.

start_streaming

Start data streaming from the hardware.

stop_recording

Stop recording data to disk.

stop_streaming

Stop data streaming from the hardware.

toggle_stim_trigger

Toggle a stimulation keypress trigger.

transmit_mosi

Transmit the loaded MOSI registers to the Sinaps probe.

update_core_config

Update core hardware configuration settings.

update_detect_params

Update detection thresholds, shadow, window and spike width on the given channels.

update_recording_config

Replace the recording configuration.

ATTRIBUTE DESCRIPTION
server_version

Connected server version as (major, minor, patch).

TYPE: ServerVersion

Attributes

server_version property
server_version: ServerVersion

Connected server version as (major, minor, patch).

A development build reports (inf, inf, inf).

Functions

close
close() -> None

Close the client's server connections.

deselect_channels
deselect_channels(signals: FlexSignalSpec) -> ChannelMetadata

Remove signals from the current selection, leaving the rest untouched.

PARAMETER DESCRIPTION
signals

Channels to deselect. Same forms as set_selected_channels().

TYPE: FlexSignalSpec

RETURNS DESCRIPTION
ChannelMetadata

Refreshed channel metadata reflecting the new selection.

RAISES DESCRIPTION
ValueError

If an index is not present in the connected hardware.

RadiensError

On communication failure or server error.

disable_all_triggers
disable_all_triggers() -> None

Disable all recording triggers.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

disable_trigger
disable_trigger(*, channel: FlexTriggerChannel, port: FlexPort | None = None) -> None

Disable a specific digital trigger channel.

Unless RecordingConfig.split_files_by_port is set, this disables all triggers.

PARAMETER DESCRIPTION
channel

The digital input/output channel to disable. Accepts TriggerChannel enum, string name without the T_ prefix (e.g. "din_0"), or int value. Must not resolve to TriggerChannel.T_NONE — use disable_all_triggers() to disable all triggers at once.

TYPE: FlexTriggerChannel

port

Hardware port the channel belongs to. See enable_trigger().

TYPE: FlexPort | None DEFAULT: None

RAISES DESCRIPTION
ValueError

If channel resolves to TriggerChannel.T_NONE.

RadiensError

On communication failure or server error.

enable_trigger
enable_trigger(*, channel: FlexTriggerChannel, port: FlexPort | None = None) -> None

Enable a digital trigger channel to start or stop recording.

When enabled, a voltage transition on channel will automatically start or stop recording on the hardware. Unless RecordingConfig.split_files_by_port is set, only one trigger is active, so enabling one replaces any other.

PARAMETER DESCRIPTION
channel

The digital input/output channel to use as a trigger. Accepts TriggerChannel enum, string name without the T_ prefix (e.g. "din_0"), or int value. Must not resolve to TriggerChannel.T_NONE — use disable_all_triggers() to disable all triggers at once.

TYPE: FlexTriggerChannel

port

Hardware port the channel belongs to. Accepts Port enum, single-letter string ("a"-"h"), or int. Only meaningful when RecordingConfig.split_files_by_port is set, where None assigns the trigger to port A.

TYPE: FlexPort | None DEFAULT: None

RAISES DESCRIPTION
ValueError

If channel resolves to TriggerChannel.T_NONE.

RadiensError

On communication failure or server error.

flash_sinaps
flash_sinaps(bitfile: str) -> None

Flash new firmware to the Sinaps probe FPGA.

PARAMETER DESCRIPTION
bitfile

Path to the FPGA bitfile to flash.

TYPE: str

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_channel_metadata
get_channel_metadata() -> ChannelMetadata

Get current channel metadata for all connected channels.

RETURNS DESCRIPTION
ChannelMetadata

Complete channel metadata including probe geometry, signal types, channel indices, and site positions for all channels.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_core_config
get_core_config() -> CoreConfig

Get core hardware configuration settings.

RETURNS DESCRIPTION
CoreConfig

Current core hardware configuration including sampling frequency, loop duration, and cable delays.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_dac_reg
get_dac_reg() -> AnalogOutRegister

Get current DAC (Analog Output) register settings.

RETURNS DESCRIPTION
AnalogOutRegister

The complete DAC register state, including gain, high-pass filter configuration, and channel mappings.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_default_spike_sorter_id
get_default_spike_sorter_id() -> str

Return Allego's spike sorter ID, whether or not the sorter is running.

RETURNS DESCRIPTION
str

The spike sorter ID.

RAISES DESCRIPTION
RadiensError

If the server reports no sorter.

get_detect_params
get_detect_params(
    spike_sorter_id: str, channels: list[int] | None = None
) -> dict[int, SpikeDetectParams]

Fetch active detection configurations per channel.

PARAMETER DESCRIPTION
spike_sorter_id

Ignored; Allego runs one sorter. Pass get_default_spike_sorter_id().

TYPE: str

channels

Optional list of native channel indices. If None, returns params for all configured channels.

TYPE: list[int] | None DEFAULT: None

RETURNS DESCRIPTION
dict[int, SpikeDetectParams]

Map from native channel index to its SpikeDetectParams.

get_dio_reg
get_dio_reg() -> DigitalOutRegister

Get current DIO (Digital Output) register settings.

RETURNS DESCRIPTION
DigitalOutRegister

The complete DIO register state, including current mode and per-channel configurations.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_dsp_group
get_dsp_group(stream_group_id: str = PRIMARY_CACHE_STREAM_GROUP_ID) -> DSPGroup

Get current DSP filter configurations.

PARAMETER DESCRIPTION
stream_group_id

The stream group to query. Defaults to the live signal stream, "Live Signals".

TYPE: str DEFAULT: PRIMARY_CACHE_STREAM_GROUP_ID

RETURNS DESCRIPTION
DSPGroup

The current hardware and software filter parameters.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_intan_impedance
get_intan_impedance(port: FlexPort) -> Impedance

Measure impedance for all channels on a specific port.

PARAMETER DESCRIPTION
port

The hardware port to measure. Accepts Port enum, single-letter string ("a"-"h"), or int (0-7).

TYPE: FlexPort

RETURNS DESCRIPTION
Impedance

Impedance measurements for all channels on the specified port.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_kpi_metrics
get_kpi_metrics(
    metrics: list[FlexKpiMetricId],
    channel_indices: list[int] | None = None,
    signal_type: FlexSignalType = AMP,
    stream_group_id: str = PRIMARY_CACHE_STREAM_GROUP_ID,
    *,
    service_mode: FlexKpiServiceMode = STREAM,
    stream_lookback_sec: float | None = None,
) -> KpiMetricsResult

Retrieve computed KPI signal metrics from the live cache.

PARAMETER DESCRIPTION
metrics

List of KPI metric identifiers. Accepts KpiMetricId objects, KpiMetric members, or metric name strings (case-insensitive).

TYPE: list[FlexKpiMetricId]

channel_indices

Native channel indices to query. None returns the selected channels.

TYPE: list[int] | None DEFAULT: None

signal_type

Signal type to query. KPI covers amplifier channels only. Defaults to AMP.

TYPE: FlexSignalType DEFAULT: AMP

stream_group_id

Stream group to query. Defaults to the live signal stream.

TYPE: str DEFAULT: PRIMARY_CACHE_STREAM_GROUP_ID

service_mode

Which answering mode to use. STREAM (the default) returns an exponential moving average, whose extrema are envelopes rather than exact min/max. RANGE is not available on a live stream.

TYPE: FlexKpiServiceMode DEFAULT: STREAM

stream_lookback_sec

How many seconds of recent signal the moving average reflects. Used only when service_mode is STREAM. The window is shared by every client of the stream, including the Allego app, which sets it while displaying metrics. None keeps the current window (1 s until set).

TYPE: float | None DEFAULT: None

RETURNS DESCRIPTION
KpiMetricsResult

One value per channel and metric, labeled with the channel of each row and the metric of each column; see KpiMetricsResult.

RAISES DESCRIPTION
SignalSelectionError

If a requested channel index is not in the live stream.

CapabilityError

If the connected server predates the current KPI metric set.

RadiensError

On communication failure or server error.

get_kpi_status
get_kpi_status(stream_group_id: str = PRIMARY_CACHE_STREAM_GROUP_ID) -> KpiStatus

Get the current KPI computation status.

PARAMETER DESCRIPTION
stream_group_id

Stream group to query. Defaults to the live signal stream.

TYPE: str DEFAULT: PRIMARY_CACHE_STREAM_GROUP_ID

RETURNS DESCRIPTION
KpiStatus

The KPI computation status; see KpiStatus.

RAISES DESCRIPTION
CapabilityError

If the connected server predates the current KPI metric set.

RadiensError

On communication failure or server error.

get_recording_config
get_recording_config() -> RecordingConfig

Get current recording configuration settings.

RETURNS DESCRIPTION
RecordingConfig

Current recording configuration including file paths, naming, and recording type settings.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_signals
get_signals(
    time_range: FlexTimeRange,
    signals: FlexSignalSpec | None = None,
    *,
    apply_dsp: bool = False,
) -> SignalArrays

Retrieve signal data from the primary live cache.

Warning

With apply_dsp set, only selected channels can be read: asking for an unselected one raises ServerCommunicationError, and so does signals=None whenever any channel is deselected. Pass {"amp": "selected"}, or select more channels first with set_selected_channels().

PARAMETER DESCRIPTION
time_range

Range to read from the live cache; see FlexTimeRange. get_status().streaming.primary_cache_t_range reports what it holds.

TYPE: FlexTimeRange

signals

Channel selection — list of amp indices, SignalSpec.amp([...]), a dict for several types, or {"amp": "selected"} for the current selection. None returns all amplifier channels.

TYPE: FlexSignalSpec | None DEFAULT: None

apply_dsp

Return the signal filtered by the stream group's stage-2 DSP group, which is what KPI metrics, the spike sorter and the Allego monitor see. False (the default) returns unfiltered wideband. Filter state does not carry over between calls: the same range read with the same stage-2 chain and channel selection returns the same samples.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SignalArrays

Signal data as numpy arrays (channels x samples). Its time_range is the range served, which is shorter than requested when part of the range has aged out of the live cache or lies ahead of the stream.

RAISES DESCRIPTION
ValueError

If a channel index does not exist.

CapabilityError

If the connected server is too old to support this method, or apply_dsp is set and the server predates it, or the range is open or a lookback and the server is too old to serve one.

RadiensError

On communication failure or server error.

get_sinaps_status_registers
get_sinaps_status_registers() -> SinapsStatusRegisters

Get the current Sinaps probe status registers.

RETURNS DESCRIPTION
SinapsStatusRegisters

Current status registers including calibration state, active pixel counts per shank, reference voltages, error flags, and probe identification information.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_spike_sorter_dashboard
get_spike_sorter_dashboard(
    spike_sorter_id: str, elements: list[FlexDashElement] | None = None
) -> SpikeSorterDashboard

Get the spike sorter dashboard for real-time monitoring.

PARAMETER DESCRIPTION
spike_sorter_id

Ignored; Allego runs one sorter. Pass get_default_spike_sorter_id().

TYPE: str

elements

Optional list of dashboard elements to include. Each element can be a DashElement enum, string name (e.g. "general"), or int value (1-8). None requests ENABLED_PORTS and GENERAL.

TYPE: list[FlexDashElement] | None DEFAULT: None

RETURNS DESCRIPTION
SpikeSorterDashboard

Dashboard data for the requested elements.

get_spike_sorter_ids
get_spike_sorter_ids() -> list[str]

Get the spike sorter IDs.

Allego has a single sorter, whose ID is returned whether or not it is running.

RETURNS DESCRIPTION
list[str]

List of spike sorter IDs.

get_spike_sorter_state
get_spike_sorter_state(spike_sorter_id: str) -> SpikeSorterState

Get the current state and progress of a spike sorter.

PARAMETER DESCRIPTION
spike_sorter_id

Ignored; Allego runs one sorter. Pass get_default_spike_sorter_id().

TYPE: str

RETURNS DESCRIPTION
SpikeSorterState

Current state including system status, progress, and messages.

get_status
get_status() -> BackboneStatus

Get comprehensive system status.

RETURNS DESCRIPTION
BackboneStatus

Current streaming status, recording status, port information, connection state, and GPIO channel counts.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_stim_params
get_stim_params() -> dict[int, StimParams]

Get stimulation parameters for all configured channels.

RETURNS DESCRIPTION
dict[int, StimParams]

Stimulation parameters keyed by system channel index.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_stim_step
get_stim_step() -> StimStepState

Get current stimulation step size setting.

RETURNS DESCRIPTION
StimStepState

Current stimulation step configuration.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

get_trigger_state
get_trigger_state() -> TriggerState

Get current trigger channel configuration.

RETURNS DESCRIPTION
TriggerState

Current trigger state showing enabled channels and ports.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

healthcheck
healthcheck(service: ServiceEndpoint = ALLEGO_LIFECYCLE) -> None

Verify the server is responsive.

PARAMETER DESCRIPTION
service

Service to probe: ALLEGO_LIFECYCLE, ALLEGO_CORE, ALLEGO_PCACHE, ALLEGO_KPI or ALLEGO_NEURONS.

TYPE: ServiceEndpoint DEFAULT: ALLEGO_LIFECYCLE

RAISES DESCRIPTION
ValueError

If service is not an Allego service.

RadiensError

If the health check fails or the server is unresponsive.

load_all_mosi
load_all_mosi(register_vals: list[int]) -> None

Load all MOSI register values into the Sinaps probe.

PARAMETER DESCRIPTION
register_vals

List of 32-bit register values to load.

TYPE: list[int]

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

manual_stim_trigger
manual_stim_trigger(request: ManualStimTriggerRequest) -> None

Manually trigger stimulation.

Deprecated

Use set_stim_trigger() instead.

PARAMETER DESCRIPTION
request

Manual trigger configuration

TYPE: ManualStimTriggerRequest

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

manual_stim_trigger_toggle
manual_stim_trigger_toggle(request: ManualStimTriggerToggleRequest) -> None

Toggle manual stimulation trigger.

Deprecated

Use toggle_stim_trigger() instead.

PARAMETER DESCRIPTION
request

Manual trigger toggle configuration

TYPE: ManualStimTriggerToggleRequest

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

read_wire_out
read_wire_out(wire_out_address: int) -> int

Read a wire-out register value from the Sinaps FPGA.

PARAMETER DESCRIPTION
wire_out_address

Address of the wire-out register to read.

TYPE: int

RETURNS DESCRIPTION
int

Integer value read from the specified wire-out register.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

restart
restart(*, mode: FlexBackboneMode) -> None

Restart the system with the specified backbone mode.

PARAMETER DESCRIPTION
mode

The backbone hardware mode to restart with. Accepts BackboneMode enum or a case-insensitive string (e.g. "smartbox_pro", "xdaq_core_stim").

TYPE: FlexBackboneMode

RAISES DESCRIPTION
RadiensError

If the restart fails.

scan_ports
scan_ports() -> ChannelMetadata

Scan all hardware ports to determine connected headstages and probes.

RETURNS DESCRIPTION
ChannelMetadata

Updated channel metadata based on the newly discovered hardware.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

select_channels
select_channels(signals: FlexSignalSpec) -> ChannelMetadata

Add signals to the current selection, leaving the rest selected.

PARAMETER DESCRIPTION
signals

Channels to select. Same forms as set_selected_channels().

TYPE: FlexSignalSpec

RETURNS DESCRIPTION
ChannelMetadata

Refreshed channel metadata reflecting the new selection.

RAISES DESCRIPTION
ValueError

If an index is not present in the connected hardware.

RadiensError

On communication failure or server error.

set_channel_groups
set_channel_groups(groups: Sequence[FlexSignalSpec]) -> ChannelMetadata

Make the color groups exactly groups, discarding existing assignments.

Color groups drive display grouping and ordering in Allego — the probe wireframe's "Order" tool sets the same thing. Groups are indexed in the order given, but each signal type within a group gets its own index and a group matching no channels gets none, so read the resulting indices from color_group_idxs on the returned metadata rather than assuming 1..N.

PARAMETER DESCRIPTION
groups

Desired groups, in order. Each accepts the same forms as set_selected_channels().

TYPE: Sequence[FlexSignalSpec]

RETURNS DESCRIPTION
ChannelMetadata

Refreshed channel metadata reflecting the new groups.

RAISES DESCRIPTION
ValueError

If a requested channel is not selected; only selected channels can be grouped.

RadiensError

On communication failure or server error.

set_core_config
set_core_config(request: SetCoreConfigRequest) -> None

Update core hardware configuration settings.

Deprecated

Use update_core_config() instead.

PARAMETER DESCRIPTION
request

Configuration parameters to update.

TYPE: SetCoreConfigRequest

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dac_gain
set_dac_gain(gain: int) -> None

Set DAC (Analog Output) gain.

PARAMETER DESCRIPTION
gain

The gain value to set.

TYPE: int

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dac_highpass
set_dac_highpass(enable: bool, cutoff_freq: float) -> None

Configure DAC (Analog Output) high-pass filter.

PARAMETER DESCRIPTION
enable

Whether to enable the high-pass filter.

TYPE: bool

cutoff_freq

The cutoff frequency in Hz.

TYPE: float

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dac_off
set_dac_off() -> None

Turn off all DAC (Analog Output) streams.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dac_stream
set_dac_stream(dac_idx: int, ntv_chan_idx: int) -> None

Map a source channel to a DAC (Analog Output) channel.

PARAMETER DESCRIPTION
dac_idx

The DAC channel index to configure.

TYPE: int

ntv_chan_idx

The source channel index to output.

TYPE: int

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_detect_params
set_detect_params(
    spike_sorter_id: str, params: SpikeDetectParams, channels: list[int]
) -> None

Update detection parameters on the given channels.

Deprecated

Use update_detect_params() instead.

PARAMETER DESCRIPTION
spike_sorter_id

As for update_detect_params().

TYPE: str

params

As for update_detect_params().

TYPE: SpikeDetectParams

channels

As for update_detect_params().

TYPE: list[int]

set_dio_events
set_dio_events(chan_idx: int, threshold: float, polarity: bool) -> None

Configure DIO channel to trigger on analog threshold crossings.

Hardware only; not available with a simulated backbone.

PARAMETER DESCRIPTION
chan_idx

Native index of the digital output channel.

TYPE: int

threshold

Event threshold in microvolts (μV).

TYPE: float

polarity

Event polarity (True for positive-going, False for negative-going).

TYPE: bool

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dio_gated
set_dio_gated(polarity: bool) -> None

Set DIO gated mode polarity.

PARAMETER DESCRIPTION
polarity

Gated polarity (True for high-active, False for low-active).

TYPE: bool

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dio_manual
set_dio_manual(chan_idx: int, state: bool) -> None

Set DIO channel state manually.

Switches the DIO mode to manual.

PARAMETER DESCRIPTION
chan_idx

Native index of the digital output channel.

TYPE: int

state

Desired state (True for high, False for low).

TYPE: bool

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dio_pulse
set_dio_pulse(interval_sec: float, duration_sec: float, chan_idx: int = -1) -> None

Configure DIO channel(s) for pulse mode.

Simulated backbone only; not available on hardware.

PARAMETER DESCRIPTION
interval_sec

Pulse interval in seconds.

TYPE: float

duration_sec

Pulse duration in seconds.

TYPE: float

chan_idx

Native index of the digital output channel, or -1 for all.

TYPE: int DEFAULT: -1

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_dsp_group
set_dsp_group(
    *,
    stage: FlexFilterStage,
    params: list[FlexDSPParams],
    stream_group_id: str = PRIMARY_CACHE_STREAM_GROUP_ID,
) -> None

Replace the filters of one DSP stage.

The other stages are left alone. To change one filter, read the stage with get_dsp_group() and send back the whole list.

Warning

params replaces the stage on every port, and a filter applies only to its port's channels. List a filter once per port it applies to; a port missing from the list loses its filters.

PARAMETER DESCRIPTION
stage

The filter stage to update. Accepts FilterStage enum, string name ("hardware", "stage1", "stage2"), or int (0-2).

TYPE: FlexFilterStage

params

Filter parameters for this stage. Each item can be a DSPParams or a DSPParamsDict. Every filter goes in stage, whatever its own stage.

TYPE: list[FlexDSPParams]

stream_group_id

The stream group to update. Allego accepts only the live signal stream, "Live Signals" (the default).

TYPE: str DEFAULT: PRIMARY_CACHE_STREAM_GROUP_ID

RAISES DESCRIPTION
ValueError

If a filter sets zero_phase, which is not supported, or breaks a field rule that DSPParams documents.

ServerCommunicationError

If stage is hardware or stage 1 while recording (stage 2 can be changed at any time), or the server cannot build a filter.

CapabilityError

If a filter sets a non-Butterworth family or a ripple_db and the connected server predates them.

set_kpi_packet_dur
set_kpi_packet_dur(
    packet_dur: float, stream_group_id: str = PRIMARY_CACHE_STREAM_GROUP_ID
) -> None

Set the KPI packet duration, the update granularity of the moving average.

Deprecated

No Allego server implements it; every call fails. Removed in 0.1.0.

PARAMETER DESCRIPTION
packet_dur

Duration of each KPI packet in seconds.

TYPE: float

stream_group_id

Stream group to configure. Defaults to the live signal stream.

TYPE: str DEFAULT: PRIMARY_CACHE_STREAM_GROUP_ID

RAISES DESCRIPTION
CapabilityError

If the connected server predates the current KPI metric set.

RadiensError

On communication failure or server error.

set_kpi_update_period
set_kpi_update_period(
    update_period: float, stream_group_id: str = PRIMARY_CACHE_STREAM_GROUP_ID
) -> None

Set how often the server processes newly arrived signal into KPI metrics.

Deprecated

No Allego server implements it; every call fails. Removed in 0.1.0.

PARAMETER DESCRIPTION
update_period

Update interval in seconds.

TYPE: float

stream_group_id

Stream group to configure. Defaults to the live signal stream.

TYPE: str DEFAULT: PRIMARY_CACHE_STREAM_GROUP_ID

RAISES DESCRIPTION
CapabilityError

If the connected server predates the current KPI metric set.

RadiensError

On communication failure or server error.

set_record_state
set_record_state(request: RecordStateRequest) -> None

Set data recording state.

Deprecated

Use start_recording() or stop_recording() instead.

PARAMETER DESCRIPTION
request

Record state configuration specifying the desired mode and optional port

TYPE: RecordStateRequest

RAISES DESCRIPTION
RadiensError

If the record state change fails.

set_recording_config
set_recording_config(config: RecordingConfig) -> None

Set recording configuration settings.

Deprecated

Use update_recording_config() instead.

PARAMETER DESCRIPTION
config

Recording configuration.

TYPE: RecordingConfig

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_selected_channels
set_selected_channels(signals: FlexSignalSpec) -> ChannelMetadata

Make the channel selection exactly signals.

Only signal types named in signals are touched — passing a bare list of amp indices leaves the GPIO selection alone. Clear one type with {"amp": []}.

PARAMETER DESCRIPTION
signals

Desired selection — list of amp indices, "all", SignalSpec.amp([...]), or a dict for multiple signal types.

TYPE: FlexSignalSpec

RETURNS DESCRIPTION
ChannelMetadata

Refreshed channel metadata reflecting the new selection.

RAISES DESCRIPTION
ValueError

If an index is not present in the connected hardware.

RadiensError

On communication failure or server error.

set_stim_params
set_stim_params(params: dict[int, StimParams]) -> None

Update stimulation parameters for specified channels.

Channels are updated in order. If one fails, the channels before it keep their new parameters.

PARAMETER DESCRIPTION
params

Map from system channel index to its new stimulation parameters. The key overrides StimParams.stim_sys_chan_idx.

TYPE: dict[int, StimParams]

RAISES DESCRIPTION
RadiensError

If params is empty, or on communication failure or server error.

Example
stim_params = StimParams.biphasic(
    amplitude=100.0,  # μA
    pulse_duration=100.0,  # μs
    polarity=StimPolarity.CATHODIC_FIRST,
    stim_sys_chan_idx=42,
    trigger_source_idx=StimKeypressIndex.KEYPRESS_1,
)

client.set_stim_params({
    42: stim_params,
    43: stim_params.model_copy(update={"first_phase_amplitude": 150.0}),
})
set_stim_step
set_stim_step(*, step: StimStep) -> None

Set the stimulation step size.

PARAMETER DESCRIPTION
step

The stimulation step size to set.

TYPE: StimStep

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_stim_trigger
set_stim_trigger(*, trigger: FlexStimKeypressIndex, on: bool) -> None

Set the state of a stimulation keypress trigger.

PARAMETER DESCRIPTION
trigger

The keypress trigger index (1-8). Accepts StimKeypressIndex enum or a plain int.

TYPE: FlexStimKeypressIndex

on

True to activate the trigger, False to deactivate.

TYPE: bool

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

set_stream_state
set_stream_state(request: StreamStateRequest) -> None

Set data streaming state.

Deprecated

Use start_streaming() or stop_streaming() instead.

PARAMETER DESCRIPTION
request

Stream state configuration specifying the desired mode

TYPE: StreamStateRequest

RAISES DESCRIPTION
RadiensError

If the stream state change fails.

set_trigger_state
set_trigger_state(*, channel: TriggerChannel, enabled: bool, port: Port) -> None

Enable or disable a recording trigger channel.

Deprecated

Use enable_trigger(), disable_trigger(), or disable_all_triggers() instead.

PARAMETER DESCRIPTION
channel

Trigger channel identifier.

TYPE: TriggerChannel

enabled

Whether the channel should be enabled.

TYPE: bool

port

Hardware port identifier.

TYPE: Port

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

spike_sorter_command
spike_sorter_command(
    spike_sorter_id: str | None = None,
    cmd: FlexSpikeSorterCommand | None = None,
    *,
    sub_cmd: FlexSpikeSorterSubCommand = NULL,
    clusterer_params: SpikeSorterClustererParams | None = None,
    feature_params: SpikeSorterFeatureParams | None = None,
    neighbor_radius_um: float | None = None,
    max_num_site_neighbors: int | None = None,
) -> None

Send a command to an active spike sorter.

PARAMETER DESCRIPTION
spike_sorter_id

ID of the spike sorter to control. None uses Allego's sorter (get_default_spike_sorter_id()).

TYPE: str | None DEFAULT: None

cmd

The command to execute. Accepts SpikeSorterCommand enum or string (e.g. "on", "off", "rebase"). Required.

TYPE: FlexSpikeSorterCommand | None DEFAULT: None

sub_cmd

Optional sub-command. Accepts SpikeSorterSubCommand enum or string ("null", "detect_only").

TYPE: FlexSpikeSorterSubCommand DEFAULT: NULL

clusterer_params

Optional parameters for the clustering algorithm. Fully applied only by "rebase"; "on" and "off" read only disabled.

TYPE: SpikeSorterClustererParams | None DEFAULT: None

feature_params

Optional parameters for feature extraction. Applied only by "rebase".

TYPE: SpikeSorterFeatureParams | None DEFAULT: None

neighbor_radius_um

Optional per-site neighbor search radius, in microns. Only applied when cmd is "init"; ignored otherwise. If unset, the current radius is kept.

TYPE: float | None DEFAULT: None

max_num_site_neighbors

Optional cap on the number of neighbors kept per site (closest first). Only applied when cmd is "init"; ignored otherwise. If unset, all neighbors within the radius are kept when neighbor_radius_um is set; with both unset the current neighborhood is kept.

TYPE: int | None DEFAULT: None

Warning

"init" clears the sorter's spikes and resets its detection thresholds, windows and shadow to defaults before applying the new neighborhood. A running sorter is turned back on afterwards.

RAISES DESCRIPTION
TypeError

If cmd is omitted.

RadiensError

If cmd is "on" or "rebase" while streaming is off, or on communication failure or server error.

start_recording
start_recording(*, port: FlexPort | None = None) -> None

Start recording data to disk.

PARAMETER DESCRIPTION
port

Optional port to start recording on. Accepts Port enum, single-letter string ("a"-"h"), or int (0-7). If omitted, applies system-level control.

TYPE: FlexPort | None DEFAULT: None

Note

Streaming starts first if it is off. If RecordingConfig.recording_type records spikes, the spike sorter is turned on too.

RAISES DESCRIPTION
RadiensError

If the record state change fails.

start_streaming
start_streaming() -> None

Start data streaming from the hardware.

RAISES DESCRIPTION
RadiensError

If the stream state change fails.

stop_recording
stop_recording(*, port: FlexPort | None = None) -> None

Stop recording data to disk.

PARAMETER DESCRIPTION
port

Optional port to stop recording on. Accepts Port enum, single-letter string ("a"-"h"), or int (0-7). If omitted, applies system-level control.

TYPE: FlexPort | None DEFAULT: None

RAISES DESCRIPTION
RadiensError

If the record state change fails.

stop_streaming
stop_streaming() -> None

Stop data streaming from the hardware.

RAISES DESCRIPTION
RadiensError

If the stream state change fails.

toggle_stim_trigger
toggle_stim_trigger(*, trigger: FlexStimKeypressIndex) -> None

Toggle a stimulation keypress trigger.

PARAMETER DESCRIPTION
trigger

The keypress trigger index (1-8) to toggle. Accepts StimKeypressIndex enum or a plain int.

TYPE: FlexStimKeypressIndex

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

transmit_mosi
transmit_mosi() -> None

Transmit the loaded MOSI registers to the Sinaps probe.

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

update_core_config
update_core_config(
    *,
    samp_freq: float | None = None,
    loop_dur: float | None = None,
    pcache_persistence: float | None = None,
    cable_delay: CableDelay | None = None,
) -> None

Update core hardware configuration settings.

Fields left as None are unchanged. Fails while streaming.

Warning

Stops the spike sorter, even when the call then fails. Changing samp_freq also clears the live cache, resets the sorter, restarts KPI, and lowers any filter edge above the new Nyquist frequency.

PARAMETER DESCRIPTION
samp_freq

Target sampling frequency in Hz.

TYPE: float | None DEFAULT: None

loop_dur

Not currently settable; the server ignores it.

TYPE: float | None DEFAULT: None

pcache_persistence

Not currently settable; the server ignores it.

TYPE: float | None DEFAULT: None

cable_delay

Cable delay configuration for a specific port.

TYPE: CableDelay | None DEFAULT: None

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

update_detect_params
update_detect_params(
    spike_sorter_id: str, params: SpikeDetectParams, channels: list[int]
) -> None

Update detection thresholds, shadow, window and spike width on the given channels.

Fields in params that are None will not be modified.

PARAMETER DESCRIPTION
spike_sorter_id

Ignored; Allego runs one sorter. Pass get_default_spike_sorter_id().

TYPE: str

params

The detection parameters to apply.

TYPE: SpikeDetectParams

channels

List of native channel indices to apply the parameters to.

TYPE: list[int]

RAISES DESCRIPTION
CapabilityError

If params.spike_width_sec is set and the connected server predates it.

update_recording_config
update_recording_config(config: RecordingConfig) -> None

Replace the recording configuration.

Every field of config is applied. get_recording_config() does not report datasource_idx, so set it explicitly when round-tripping a config. Fails while recording.

PARAMETER DESCRIPTION
config

Recording configuration specifying file paths, naming, and recording type (continuous/spikes/both).

TYPE: RecordingConfig

RAISES DESCRIPTION
RadiensError

On communication failure or server error.

Example
config = client.get_recording_config()
config = config.model_copy(update={"base_file_path": "/new/path", "datasource_idx": 3})
client.update_recording_config(config)