Interfaces¶
External I/O bridges: brain-computer interface protocols, CCW audio bridge, dynamic vision sensor input, and real-world actuator output.
BCI¶
sc_neurocore.interfaces.bci
¶
Encode continuous neural signals (EEG, LFP, intracortical) into spike trains and stochastic bitstreams for SC processing.
Uses framework-native encoding (seeded RNG for reproducibility, Sobol quasi-random for low-discrepancy encoding). Supports windowed encoding for streaming BCI pipelines.
For spike compression/telemetry, see spike_codec (6 codecs).
BCIEncoder
dataclass
¶
Encode continuous neural signals into spike trains.
Replaces the old BCIDecoder (misleading name — it encodes, not decodes). Uses seeded RNG for deterministic, reproducible encoding.
Parameters¶
n_channels : int Number of recording channels. sampling_rate : int Input signal sampling rate (Hz). window_ms : float Encoding window duration in milliseconds. seed : int RNG seed for reproducibility.
Source code in src/sc_neurocore/interfaces/bci.py
| Python | |
|---|---|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
encode(signal, T=20)
¶
Encode a signal block into spike trains via rate coding.
Parameters¶
signal : ndarray of shape (n_channels,) or (n_channels, n_samples) Continuous neural signal. Multi-sample input is averaged per channel to get firing probabilities. T : int Number of output timesteps per window.
Returns¶
ndarray of shape (T, n_channels), int8 binary
Source code in src/sc_neurocore/interfaces/bci.py
| Python | |
|---|---|
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
encode_stream(signal)
¶
Encode a multi-window signal stream.
Parameters¶
signal : ndarray of shape (n_channels, total_samples) Full recording. Split into windows of window_ms duration.
Returns¶
ndarray of shape (total_T, n_channels), int8 binary
Source code in src/sc_neurocore/interfaces/bci.py
| Python | |
|---|---|
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
normalize_signal(signal)
¶
Normalize signal to [0, 1]. Legacy API — use _normalize().
Source code in src/sc_neurocore/interfaces/bci.py
| Python | |
|---|---|
114 115 116 117 118 119 | |
encode_to_bitstream(signal, length=256)
¶
Legacy API. Encodes (channels, time) → (channels, length).
New code should use .encode() which returns (T, channels).
Source code in src/sc_neurocore/interfaces/bci.py
| Python | |
|---|---|
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
BCIDecoder
¶
Bases: BCIEncoder
Legacy alias. Use BCIEncoder instead.
Source code in src/sc_neurocore/interfaces/bci.py
| Python | |
|---|---|
140 141 142 143 144 | |
Closed-Loop BCI HIL¶
sc_neurocore.interfaces.bci_closed_loop
¶
Deterministic closed-loop BCI template for HIL prototyping.
The template wires raw electrode windows through WaveformCodec compression, AER event payload generation, spike-rate decoding, feedback emission, and runtime telemetry. It deliberately uses an in-process implant emulator by default so tests and examples can exercise the closed loop without claiming access to a physical implant.
ClosedLoopBCIConfig
dataclass
¶
Configuration for one raw-waveform to feedback HIL loop.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
FeedbackFrame
dataclass
¶
Feedback vector emitted to an implant emulator or hardware adapter.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
50 51 52 53 54 55 56 | |
ClosedLoopBCIResult
dataclass
¶
One processed BCI/HIL loop window.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
59 60 61 62 63 64 65 66 67 68 69 70 | |
SpikeDecoder
¶
Bases: Protocol
Decoder interface for closed-loop spike windows.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
73 74 75 76 77 | |
decode(spike_raster)
¶
Decode a binary spike raster into feedback control values.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
76 77 | |
FeedbackSink
¶
Bases: Protocol
Feedback interface for an implant emulator or hardware adapter.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
80 81 82 83 84 | |
apply_feedback(values, timestamp_us)
¶
Apply decoded feedback values and return the emitted frame.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
83 84 | |
RateSpikeDecoder
dataclass
¶
Decode spike rasters as per-channel firing rates.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
87 88 89 90 91 92 93 94 95 96 97 98 | |
ImplantEmulator
dataclass
¶
Deterministic feedback sink used by the closed-loop template.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
ClosedLoopBCITemplate
dataclass
¶
WaveformCodec + AER + telemetry closed-loop BCI scaffold.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
process_window(waveform, *, window_start_us=0)
¶
Process one raw electrode window through the closed-loop template.
Source code in src/sc_neurocore/interfaces/bci_closed_loop.py
| Python | |
|---|---|
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
sc_neurocore.interfaces.bci_hil_manifest
¶
Reference manifests for closed-loop BCI hardware-in-the-loop templates.
BCIHILBoardProfile
dataclass
¶
Board/input profile for a closed-loop BCI reference pipeline.
Source code in src/sc_neurocore/interfaces/bci_hil_manifest.py
| Python | |
|---|---|
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
to_dict()
¶
Return a deterministic manifest dictionary.
Source code in src/sc_neurocore/interfaces/bci_hil_manifest.py
| Python | |
|---|---|
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
available_bci_hil_profiles()
¶
Return all reference profiles in deterministic order.
Source code in src/sc_neurocore/interfaces/bci_hil_manifest.py
| Python | |
|---|---|
118 119 120 121 | |
get_bci_hil_profile(profile_id)
¶
Return one reference profile by identifier.
Source code in src/sc_neurocore/interfaces/bci_hil_manifest.py
| Python | |
|---|---|
124 125 126 127 128 129 130 131 | |
build_bci_hil_reference_manifest(profile_id='pynq_shd')
¶
Build a deterministic closed-loop BCI/HIL reference manifest.
Source code in src/sc_neurocore/interfaces/bci_hil_manifest.py
| Python | |
|---|---|
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
create_bci_hil_template(profile_id='pynq_shd')
¶
Create a ClosedLoopBCITemplate from a reference profile.
Source code in src/sc_neurocore/interfaces/bci_hil_manifest.py
| Python | |
|---|---|
158 159 160 161 | |
build_bci_hil_reference_manifest() exposes deterministic reference
manifests for pynq_shd and probe_384ch. Both use the
ClosedLoopBCITemplate path:
raw waveform window
-> WaveformCodec compression
-> threshold spike raster
-> AER payload generation
-> rate decoder
-> feedback frame
-> DeviceTelemetry summary
The pynq_shd profile uses the repository's documented SHD topology
(700 -> 256 -> 20) as the reference model shape and defaults to the
in-process implant emulator. Physical PYNQ use still requires the external
bitstream and an explicit hardware feedback sink.
CCW Bridge¶
sc_neurocore.interfaces.ccw_bridge
¶
SC-NeuroCore ↔ CCW/VIBRANA bridge.
Converts stochastic bitstream outputs to audio parameters and visualization states for the CCW application.
CCWMode
¶
Bases: str, Enum
CCW modulation modes aligned with VIBRANA.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
30 31 32 33 34 35 36 37 38 | |
CCWParameters
dataclass
¶
Parameters for CCW audio generation.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
41 42 43 44 45 46 47 48 49 | |
VIBRANAState
dataclass
¶
State for VIBRANA visualization sync.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
52 53 54 55 56 57 58 59 60 | |
CCWBridge
¶
Bridge between SC-NeuroCore and CCW/VIBRANA systems.
Converts bitstream outputs from SCPN layers into audio parameters and visualization states for the CCW application.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
bitstream_to_frequency(bitstream, freq_min=1.0, freq_max=40.0)
¶
Convert a bitstream to a frequency value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bitstream
|
ndarray[Any, Any]
|
Binary array from SC layer output |
required |
freq_min
|
float
|
Minimum frequency (Hz) |
1.0
|
freq_max
|
float
|
Maximum frequency (Hz) |
40.0
|
Returns:
| Type | Description |
|---|---|
float
|
Frequency in Hz mapped from bitstream probability |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
scpn_metrics_to_ccw(metrics)
¶
Convert SCPN global metrics to CCW audio parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
Dict[str, float]
|
Dict from get_global_metrics() of SCPN layers |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict of CCW-compatible audio parameters |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
glyph_vector_to_vibrana(glyph_vector)
¶
Convert L7 glyph vector to VIBRANA visualization parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
glyph_vector
|
ndarray[Any, Any]
|
6D vector [phi, fib, metatron, platonic, e8, health] |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict of VIBRANA visualization parameters |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
generate_binaural_sample(ccw_params, duration_samples=1024)
¶
Generate binaural audio samples from CCW parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccw_params
|
Dict[str, float]
|
Parameters from scpn_metrics_to_ccw() |
required |
duration_samples
|
int
|
Number of samples to generate |
1024
|
Returns:
| Type | Description |
|---|---|
Tuple[ndarray[Any, Any], ndarray[Any, Any]]
|
Tuple of (left_channel, right_channel) numpy arrays |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
generate_ccw_metadata(scpn_outputs, glyph_vector=None)
¶
Generate complete CCW metadata package for audio/visual sync.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scpn_outputs
|
Dict[str, Any]
|
Full output dict from run_integrated_step() |
required |
glyph_vector
|
Optional[ndarray[Any, Any]]
|
Optional L7 glyph vector |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Complete metadata dict for CCW system |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
export_glyph_stream(glyph_vector, cosmic_vector=None, filepath=None)
¶
Export glyph stream data for VIBRANA/CCW hardware playback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
glyph_vector
|
ndarray[Any, Any]
|
Normalized glyph vector from L7 |
required |
cosmic_vector
|
Optional[Dict[str, float]]
|
Optional L8 cosmic phase data |
None
|
filepath
|
Optional[str]
|
Optional file path to save |
None
|
Returns:
| Type | Description |
|---|---|
str
|
JSON string of glyph stream data |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
create_session_config(mode=CCWMode.MEDITATION, duration_minutes=20)
¶
Create a complete CCW session configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
CCWMode
|
CCW/VIBRANA mode |
MEDITATION
|
duration_minutes
|
int
|
Session duration |
20
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Session configuration dict |
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
create_bridge(ccw_params=None)
¶
Factory function to create a CCW bridge instance.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
| Python | |
|---|---|
415 416 417 | |
DVS Input¶
sc_neurocore.interfaces.dvs_input
¶
DVSInputLayer
dataclass
¶
Interface for Dynamic Vision Sensors (Event Cameras). Converts AER events (x, y, t, p) into SC Bitstreams.
Source code in src/sc_neurocore/interfaces/dvs_input.py
| Python | |
|---|---|
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
process_events(events)
¶
Integrate a batch of events. Events format: (x, y, timestamp_ms, polarity) Returns: Frame of probabilities [0, 1]
Source code in src/sc_neurocore/interfaces/dvs_input.py
| Python | |
|---|---|
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
generate_bitstream_frame(length=256)
¶
Generate a HxWxLength bitstream cube from current surface state.
Source code in src/sc_neurocore/interfaces/dvs_input.py
| Python | |
|---|---|
80 81 82 83 84 85 86 87 88 89 | |
Real World¶
sc_neurocore.interfaces.real_world
¶
LSLBridge
¶
Lab Streaming Layer (LSL) Bridge. Connects EEG/Physiological streams to sc-neurocore. (Mock implementation for standalone use).
Source code in src/sc_neurocore/interfaces/real_world.py
| Python | |
|---|---|
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
receive_chunk(max_samples=32)
¶
Simulates receiving a chunk of samples. In real version: calls inlet.pull_chunk().
Source code in src/sc_neurocore/interfaces/real_world.py
| Python | |
|---|---|
27 28 29 30 31 32 33 | |
ROS2Node
¶
ROS 2 Interface Node. Publishes motor commands from sc-neurocore to robots.
Source code in src/sc_neurocore/interfaces/real_world.py
| Python | |
|---|---|
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
publish_cmd_vel(linear_x, angular_z)
¶
Simulates publishing to /cmd_vel.
Source code in src/sc_neurocore/interfaces/real_world.py
| Python | |
|---|---|
46 47 48 49 50 51 52 53 | |