ezmsg.blackrock.cerelink#
CereLink-based source for ezmsg — streams continuous and spike data from Blackrock devices.
Classes
- class CereLinkProducer(*args, settings=None, **kwargs)[source]#
Bases:
BaseProducer[CereLinkSettings,AxisArray]Owns the pycbsdk Session, ring buffers, and spike queue.
- Parameters:
settings (CereLinkSettings | None)
- __init__(*args, settings=None, **kwargs)[source]#
- Parameters:
settings (CereLinkSettings | None)
- spike_queue: Queue[EventMessage]#
- open()[source]#
Create and start the Session, configure channels, register callbacks.
device_type=Noneis an explicit no-op — the producer stays idle and_producereturnsNoneon every call, which lets the unit sit dormant until a real device is selected by the host app.- Return type:
None
- close()[source]#
Tear down the Session and unblock any in-flight
_produce.The
_data_event.set()is what frees a coroutine that may be awaiting new samples — without it, an in-flight_producefrom the previous producer instance would block forever after a settings-driven recreate, eventually getting GC’d as a pending task.- Return type:
None
- reload_channel_map(cmp_path)[source]#
Apply a new CMP to the existing Session, refresh cached positions, and rebuild each active group’s template so subsequent AxisArrays carry the new (x, y) positions.
pycbsdk has no API to clear an applied CMP — pass
Noneand the call is a no-op with a warning.- Parameters:
cmp_path (str)
- Return type:
None
- class CereLinkSettings(device_type: 'DeviceType | None' = None, cbtime: 'bool' = False, microvolts: 'bool' = True, cont_buffer_dur: 'float' = 0.5, ccf_path: 'str | None' = None, cmp_path: 'str | None' = None, n_chans: 'int | None' = None, channel_type: 'ChannelType' = <ChannelType.FRONTEND: 0>, sample_rate: 'SampleRate | None' = None, ac_input_coupling: 'bool' = False)[source]#
Bases:
Settings- Parameters:
- device_type: DeviceType | None = None#
Device type to connect to.
None= no Session — the unit produces nothing until a real device is selected. This idle-by-default mode lets a host app defer the cost of opening pycbsdk until the user picks a device, which is useful on macOS where simultaneous Sessions exhaust POSIX shared memory.
- ccf_path: str | None = None#
CCF file to load after connection (or None to skip). Mutually exclusive with n_chans/sample_rate.
- cmp_path: str | None = None#
CMP file for electrode positions (or None to skip). Bank offset is always 0.
- n_chans: int | None = None#
Number of channels to enable (used with channel_type and sample_rate). Mutually exclusive with ccf_path.
- channel_type: ChannelType = 0#
Channel type filter for programmatic setup.
- sample_rate: SampleRate | None = None#
Sample rate for programmatic setup (e.g. SampleRate.SR_30kHz). Mutually exclusive with ccf_path.
- ac_input_coupling: bool = False#
AC input coupling (highpass filter). Ignored when ccf_path is provided.
- __init__(device_type=None, cbtime=False, microvolts=True, cont_buffer_dur=0.5, ccf_path=None, cmp_path=None, n_chans=None, channel_type=ChannelType.FRONTEND, sample_rate=None, ac_input_coupling=False)#
- class CereLinkSource(*args, **kwargs)[source]#
Bases:
BaseProducerUnit[CereLinkSettings,AxisArray,CereLinkProducer]ezmsg Unit that streams continuous and spike data from a Blackrock device.
- SETTINGS#
alias of
CereLinkSettings
- OUTPUT_SPIKE = OutputStream:unlocated[EventMessage](self.num_buffers=32, self.force_tcp=None, self.allow_local=None)#
- OUTPUT_DEVICE_STATUS = OutputStream:unlocated[DeviceStatus](self.num_buffers=32, self.force_tcp=None, self.allow_local=None)#
- __init__(*args, **kwargs)[source]#
Initialize an Addressable object.
The name and location are initially None and must be set before the object can be properly addressed. This is achieved through the
_set_name()and_set_location()methods.- Return type:
None
- async initialize()[source]#
Runs when the Unit is instantiated.
This is called from within the same process this unit will live in. This lifecycle hook can be overridden. It can be run as async functions by simply adding the async keyword when overriding.
This method is where you should initialize your unit’s state and prepare for message processing.
- Return type:
None
- async on_settings(msg)[source]#
Receive a settings message, override self.SETTINGS, and re-create the producer. Child classes that wish to have fine-grained control over whether the core producer resets on settings changes should override this method.
- Parameters:
msg (CereLinkSettings) – a settings message.
- Return type:
None
- shutdown()[source]#
Runs when the Unit terminates.
This is called from within the same process this unit will live in. This lifecycle hook can be overridden. It can be run as async functions by simply adding the async keyword when overriding.
This method is where you should clean up resources and perform any necessary shutdown procedures.
- Return type:
None
- class DeviceStatus(device_type, success, error='')[source]#
Bases:
objectResult of a settings-driven device switch.
Emitted on
CereLinkSource.OUTPUT_DEVICE_STATUSafter eachon_settingsbackgroundopen()attempt. The GUI consumes this to confirm or revert its device selection (the snapshot’s settings_changed event fires before the open completes and so cannot distinguish success from failure).- Parameters:
device_type (DeviceType | None)
success (bool)
error (str)
- device_type: DeviceType | None#
- __init__(device_type, success, error='')#
- Parameters:
device_type (DeviceType | None)
success (bool)
error (str)
- Return type:
None
- class DeviceStatus(device_type, success, error='')[source]#
Bases:
objectResult of a settings-driven device switch.
Emitted on
CereLinkSource.OUTPUT_DEVICE_STATUSafter eachon_settingsbackgroundopen()attempt. The GUI consumes this to confirm or revert its device selection (the snapshot’s settings_changed event fires before the open completes and so cannot distinguish success from failure).- Parameters:
device_type (DeviceType | None)
success (bool)
error (str)
- device_type: DeviceType | None#
- __init__(device_type, success, error='')#
- Parameters:
device_type (DeviceType | None)
success (bool)
error (str)
- Return type:
None
- class CereLinkSettings(device_type: 'DeviceType | None' = None, cbtime: 'bool' = False, microvolts: 'bool' = True, cont_buffer_dur: 'float' = 0.5, ccf_path: 'str | None' = None, cmp_path: 'str | None' = None, n_chans: 'int | None' = None, channel_type: 'ChannelType' = <ChannelType.FRONTEND: 0>, sample_rate: 'SampleRate | None' = None, ac_input_coupling: 'bool' = False)[source]#
Bases:
Settings- Parameters:
- device_type: DeviceType | None = None#
Device type to connect to.
None= no Session — the unit produces nothing until a real device is selected. This idle-by-default mode lets a host app defer the cost of opening pycbsdk until the user picks a device, which is useful on macOS where simultaneous Sessions exhaust POSIX shared memory.
- ccf_path: str | None = None#
CCF file to load after connection (or None to skip). Mutually exclusive with n_chans/sample_rate.
- cmp_path: str | None = None#
CMP file for electrode positions (or None to skip). Bank offset is always 0.
- n_chans: int | None = None#
Number of channels to enable (used with channel_type and sample_rate). Mutually exclusive with ccf_path.
- channel_type: ChannelType = 0#
Channel type filter for programmatic setup.
- sample_rate: SampleRate | None = None#
Sample rate for programmatic setup (e.g. SampleRate.SR_30kHz). Mutually exclusive with ccf_path.
- ac_input_coupling: bool = False#
AC input coupling (highpass filter). Ignored when ccf_path is provided.
- __init__(device_type=None, cbtime=False, microvolts=True, cont_buffer_dur=0.5, ccf_path=None, cmp_path=None, n_chans=None, channel_type=ChannelType.FRONTEND, sample_rate=None, ac_input_coupling=False)#
- class CereLinkProducer(*args, settings=None, **kwargs)[source]#
Bases:
BaseProducer[CereLinkSettings,AxisArray]Owns the pycbsdk Session, ring buffers, and spike queue.
- Parameters:
settings (CereLinkSettings | None)
- __init__(*args, settings=None, **kwargs)[source]#
- Parameters:
settings (CereLinkSettings | None)
- spike_queue: Queue[EventMessage]#
- open()[source]#
Create and start the Session, configure channels, register callbacks.
device_type=Noneis an explicit no-op — the producer stays idle and_producereturnsNoneon every call, which lets the unit sit dormant until a real device is selected by the host app.- Return type:
None
- close()[source]#
Tear down the Session and unblock any in-flight
_produce.The
_data_event.set()is what frees a coroutine that may be awaiting new samples — without it, an in-flight_producefrom the previous producer instance would block forever after a settings-driven recreate, eventually getting GC’d as a pending task.- Return type:
None
- reload_channel_map(cmp_path)[source]#
Apply a new CMP to the existing Session, refresh cached positions, and rebuild each active group’s template so subsequent AxisArrays carry the new (x, y) positions.
pycbsdk has no API to clear an applied CMP — pass
Noneand the call is a no-op with a warning.- Parameters:
cmp_path (str)
- Return type:
None
- class CereLinkSource(*args, **kwargs)[source]#
Bases:
BaseProducerUnit[CereLinkSettings,AxisArray,CereLinkProducer]ezmsg Unit that streams continuous and spike data from a Blackrock device.
- SETTINGS#
alias of
CereLinkSettings
- OUTPUT_SPIKE = OutputStream:unlocated[EventMessage](self.num_buffers=32, self.force_tcp=None, self.allow_local=None)#
- OUTPUT_DEVICE_STATUS = OutputStream:unlocated[DeviceStatus](self.num_buffers=32, self.force_tcp=None, self.allow_local=None)#
- __init__(*args, **kwargs)[source]#
Initialize an Addressable object.
The name and location are initially None and must be set before the object can be properly addressed. This is achieved through the
_set_name()and_set_location()methods.- Return type:
None
- async initialize()[source]#
Runs when the Unit is instantiated.
This is called from within the same process this unit will live in. This lifecycle hook can be overridden. It can be run as async functions by simply adding the async keyword when overriding.
This method is where you should initialize your unit’s state and prepare for message processing.
- Return type:
None
- async on_settings(msg)[source]#
Receive a settings message, override self.SETTINGS, and re-create the producer. Child classes that wish to have fine-grained control over whether the core producer resets on settings changes should override this method.
- Parameters:
msg (CereLinkSettings) – a settings message.
- Return type:
None
- shutdown()[source]#
Runs when the Unit terminates.
This is called from within the same process this unit will live in. This lifecycle hook can be overridden. It can be run as async functions by simply adding the async keyword when overriding.
This method is where you should clean up resources and perform any necessary shutdown procedures.
- Return type:
None