Skip to content

radiens_core.models.spikesorter

Spike sorter control and status domain models.

CLASS DESCRIPTION
DashElement

Elements available for the spike sorter dashboard.

InputFeatureType

Feature types used for spike sorting.

SpikeDetectParams

Detection parameters for a single recording channel.

SpikeSorterClustererParams

Parameters for the spike clustering algorithm.

SpikeSorterCommand

Commands for controlling an active spike sorter.

SpikeSorterCriterionLevel

Stringency levels for AI evaluation, from least to most strict.

SpikeSorterDashboard

Comprehensive spike sorter dashboard data.

SpikeSorterDashboardGeneral

General summary metrics for the spike sorter dashboard.

SpikeSorterDynamicConfig

Configuration for AI dynamic tracking auto-updates.

SpikeSorterDynamicCriteria

Criteria stringency levels for AI auto-updates.

SpikeSorterDynamicUpdatePeriod

Update periods in seconds for AI auto-updates.

SpikeSorterFeatureParams

Parameters for feature extraction during spike sorting.

SpikeSorterLaunchParams

Parameters for launching a new spike sorter.

SpikeSorterLaunchResult

Result of a spike sorter launch request.

SpikeSorterParamCommand

Commands for updating individual spike sorter detection parameters.

SpikeSorterPhase

Where an offline sort is in its pipeline.

SpikeSorterState

Current state and progress of a spike sorter.

SpikeSorterStateSystem

Overall system state of a spike sorter.

SpikeSorterSubCommand

Sub-commands for spike sorter operations.

SpikeSorterType

Supported spike sorter types.

ATTRIBUTE DESCRIPTION
FlexDashElement

DashElement that also accepts a string name (case-insensitive) or int value.

FlexSpikeSorterCommand

SpikeSorterCommand that also accepts a string name (case-insensitive).

FlexSpikeSorterSubCommand

SpikeSorterSubCommand that also accepts a string name (case-insensitive).

Attributes

FlexDashElement module-attribute

FlexDashElement = DashElement | DashElementStr | int

DashElement that also accepts a string name (case-insensitive) or int value.

FlexSpikeSorterCommand module-attribute

FlexSpikeSorterCommand = SpikeSorterCommand | SpikeSorterCommandStr

SpikeSorterCommand that also accepts a string name (case-insensitive).

FlexSpikeSorterSubCommand module-attribute

FlexSpikeSorterSubCommand = SpikeSorterSubCommand | SpikeSorterSubCommandStr

SpikeSorterSubCommand that also accepts a string name (case-insensitive).

Classes

DashElement

Bases: IntEnum

Elements available for the spike sorter dashboard.

ATTRIBUTE DESCRIPTION
ENABLED_PORTS

Ports the sorter is enabled on.

GENERAL

Sorter-wide summary.

PORT_STATS

Per-port statistics.

SITE_STATS

Per-site statistics.

SITE_PANEL

Per-site panel data.

NEURON_STATS

Per-neuron statistics.

NEURON_PANEL

Per-neuron panel data.

AI

AI tracking state.

InputFeatureType

Bases: IntEnum

Feature types used for spike sorting.

SPD and SPD_POS are not supported at the moment.

ATTRIBUTE DESCRIPTION
WFM

Spike waveform.

SPD

Shape, phase and distribution features.

WFM_POS

Waveform plus site position.

SPD_POS

Shape, phase and distribution features plus site position.

SpikeDetectParams

Bases: BaseModel

Detection parameters for a single recording channel.

All fields are optional to allow for partial updates.

ATTRIBUTE DESCRIPTION
is_enabled

Whether detection is enabled on this channel.

TYPE: bool | None

ntv_chan_idx

Native channel index (used in return structures, not set via bulk update).

TYPE: int | None

thr

Threshold values in microvolts [neg, pos].

TYPE: list[float] | None

thr_sd

Threshold values in standard deviations [neg, pos].

TYPE: list[float] | None

thr_wdw_pts

thr_wdw in samples. Read-only; update_detect_params() ignores it.

TYPE: list[int] | None

thr_wdw

Spike window around the threshold crossing in seconds [pre, post, total]. update_detect_params() sends only pre and post; the server reports the window with its peak-search margin added.

TYPE: list[float] | None

shadow

Dead time after a detected spike during which no new spike is detected, in seconds.

TYPE: float | None

shadow_pts

shadow in samples. Read-only; update_detect_params() ignores it.

TYPE: int | None

is_set_thr

Whether the detection threshold is armed [neg, pos].

TYPE: list[bool] | None

weak_thr

Artifact-rejection level in microvolts [neg, pos]. When armed, a detected waveform that goes past it is discarded as an artifact.

TYPE: list[float] | None

weak_thr_sd

Artifact-rejection level in noise standard deviations [neg, pos].

TYPE: list[float] | None

is_set_weak_thr

Whether the artifact-rejection level is armed [neg, pos]. Setting a level does not arm it.

TYPE: list[bool] | None

spike_width_sec

[min, max] seconds a detected spike may span at half its peak on its detecting site and still be clustered. One outside the bounds is marked noise and never assigned to a unit. Defaults to [0.00015, 0.002]; the 0.15 ms minimum rejects narrow spikes such as cerebellar ones (about 0.1 ms).

TYPE: list[float] | None

SpikeSorterClustererParams

Bases: BaseModel

Parameters for the spike clustering algorithm.

ATTRIBUTE DESCRIPTION
pos_influence_frac

Influence of spike position on clustering.

TYPE: float | None

wfm_shape_influence_frac

Influence of waveform shape on clustering.

TYPE: float | None

eps

Epsilon parameter for DBSCAN-like clustering.

TYPE: float | None

min_pts

Minimum points for a cluster.

TYPE: int | None

disabled

Whether clustering is disabled.

TYPE: bool

SpikeSorterCommand

Bases: IntEnum

Commands for controlling an active spike sorter.

ATTRIBUTE DESCRIPTION
ON

Start sorting.

OFF

Stop sorting.

CLEAR_SORT

Discard the sorter's spikes.

REBASE

Stop, discard the spikes, apply new feature and clusterer parameters, and start again.

INIT

Stop, discard the spikes, reset detection parameters to defaults and rebuild the site neighborhoods. A sorter that was running is started again.

SpikeSorterCriterionLevel

Bases: IntEnum

Stringency levels for AI evaluation, from least to most strict.

ATTRIBUTE DESCRIPTION
LEAST

Least strict.

LESS

Less strict than balanced.

BALANCED

The middle level.

MORE

More strict than balanced.

MOST

Most strict.

SpikeSorterDashboard

Bases: BaseModel

Comprehensive spike sorter dashboard data.

ATTRIBUTE DESCRIPTION
enabled_ports

List of hardware ports with active sorting.

TYPE: list[Port]

general

General summary metrics.

TYPE: SpikeSorterDashboardGeneral | None

SpikeSorterDashboardGeneral

Bases: BaseModel

General summary metrics for the spike sorter dashboard.

SpikeSorterDynamicConfig

Bases: BaseModel

Configuration for AI dynamic tracking auto-updates.

ATTRIBUTE DESCRIPTION
is_enabled

Whether dynamic AI tracking is enabled.

TYPE: bool | None

update_period_sec

Schedule for dynamic updates.

TYPE: SpikeSorterDynamicUpdatePeriod | None

criteria

Stringency criteria for updates.

TYPE: SpikeSorterDynamicCriteria | None

SpikeSorterDynamicCriteria

Bases: BaseModel

Criteria stringency levels for AI auto-updates.

SpikeSorterDynamicUpdatePeriod

Bases: BaseModel

Update periods in seconds for AI auto-updates.

SpikeSorterFeatureParams

Bases: BaseModel

Parameters for feature extraction during spike sorting.

ATTRIBUTE DESCRIPTION
num_features

Number of features to extract.

TYPE: int

feature_type

Type of features to extract: WFM or WFM_POS. Also accepts the name as a string (e.g. "wfm"). Defaults to WFM_POS, matching the server.

TYPE: InputFeatureType | InputFeatureTypeStr

latent_dim

Latent dimension for feature reduction.

TYPE: int | None

resample_wfm_len

Length to resample waveforms to.

TYPE: int | None

SpikeSorterLaunchParams

Bases: BaseModel

Parameters for launching a new spike sorter.

ATTRIBUTE DESCRIPTION
dsource_id

ID of the data source to sort (required for file sorting).

TYPE: str | None

sub_cmd

Sub-command for the sorting operation. SpikeSorterSubCommand.DETECT_ONLY detects spikes without clustering them into neurons.

TYPE: SpikeSorterSubCommand

clusterer_params

Optional clustering parameters. None uses the server's defaults, as does any field left None. With an older Radiens server, None keeps whatever an earlier launch on the dataset set.

TYPE: SpikeSorterClustererParams | None

feature_params

Optional feature extraction parameters, with the same None behavior.

TYPE: SpikeSorterFeatureParams | None

neighbor_radius_um

Per-site neighbor search radius, in microns. None keeps the dataset's current radius, which an earlier launch may have changed.

TYPE: float | None

max_num_site_neighbors

Cap on the number of neighbors kept per site (closest first). 0 detects on every channel independently, so a threshold crossing is never discarded for being smaller than a neighbor's. None keeps all neighbors within the radius when neighbor_radius_um is set; with both None the current neighborhood is kept.

TYPE: int | None

seed

Root of every random draw the sort makes, recorded in the sort's provenance. None draws one from the clock. Passing the seed a previous sort recorded reproduces that sort, given the same recording, settings and server build. Detect-only sorts record no seed.

TYPE: int | None

SpikeSorterLaunchResult

Bases: BaseModel

Result of a spike sorter launch request.

ATTRIBUTE DESCRIPTION
spike_sorter_id

Unique ID of the launched sorter.

TYPE: str

sorter_type

Type of the launched sorter.

TYPE: SpikeSorterType

msg

Status message from the server.

TYPE: str

SpikeSorterParamCommand

Bases: IntEnum

Commands for updating individual spike sorter detection parameters.

update_detect_params() sends these for you, one per SpikeDetectParams field set.

ATTRIBUTE DESCRIPTION
THR_LEVEL

Sets thr.

THR_LEVEL_SD

Sets thr_sd.

THR_WDW

Sets thr_wdw.

WEAK_THR_LEVEL

Sets weak_thr.

WEAK_THR_LEVEL_SD

Sets weak_thr_sd.

SHADOW

Sets shadow.

THR_ACTIVATE

Sets is_set_thr.

WEAK_THR_ACTIVATE

Sets is_set_weak_thr.

SPIKE_WIDTH

Sets spike_width_sec.

SpikeSorterPhase

Bases: IntEnum

Where an offline sort is in its pipeline.

A streaming sorter's phase has no fixed meaning. For a recording still being written, DETECTING and FINALIZING can last until recording stops. Older servers always report UNSPECIFIED.

ATTRIBUTE DESCRIPTION
UNSPECIFIED

The sort has not started.

DETECTING

Detecting spikes.

TRAINING

Training the sorter on the detected spikes.

SORTING

Clustering spikes into units.

FINALIZING

Writing out the result.

COMPLETE

Done. The output fileset can be read.

SpikeSorterState

Bases: BaseModel

Current state and progress of a spike sorter.

ATTRIBUTE DESCRIPTION
sys

Overall system state (ON, OFF, NOT_CONFIGURED).

TYPE: SpikeSorterStateSystem

phase

Which stage of the pipeline an offline sort is in.

TYPE: SpikeSorterPhase

frac_complete

Fraction of the current phase completed (0.0 to 1.0). It returns to 0 at each phase change and reads 1 at the end of training as well as at the end of the sort, so a caller waiting on a sort reads phase, not this.

TYPE: float

is_on

Whether the sorter is currently active.

TYPE: bool

msg

phase as a display string.

TYPE: str

error_msg

Error message if the sorter is in an error state.

TYPE: str

warn_msg

Warning message from the server.

TYPE: str

SpikeSorterStateSystem

Bases: IntEnum

Overall system state of a spike sorter.

ATTRIBUTE DESCRIPTION
ON

Running.

OFF

Stopped.

NOT_CONFIGURED

Not set up yet.

SpikeSorterSubCommand

Bases: IntEnum

Sub-commands for spike sorter operations.

ATTRIBUTE DESCRIPTION
NULL

Full sorting, with clustering.

DETECT_ONLY

Detect spikes without clustering them.

SpikeSorterType

Bases: IntEnum

Supported spike sorter types.

ATTRIBUTE DESCRIPTION
NULL

No sorter.

VEX_STREAM

Sorts a live stream in Allego.

SPIKES_STREAM

Not produced by current servers.

VEX_FILE

Sorts a recording's signals.

SPIKES_FILE

Sorts the spikes in a spikes fileset.