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
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 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 | |
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
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
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
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 | |
normalize_signal(signal)
¶
Normalize signal to [0, 1]. Legacy API — use _normalize().
Source code in src/sc_neurocore/interfaces/bci.py
113 114 115 116 117 118 | |
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
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
BCIDecoder
¶
Bases: BCIEncoder
Legacy alias. Use BCIEncoder instead.
Source code in src/sc_neurocore/interfaces/bci.py
139 140 141 142 143 | |
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
29 30 31 32 33 34 35 36 37 | |
CCWParameters
dataclass
¶
Parameters for CCW audio generation.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
40 41 42 43 44 45 46 47 48 | |
VIBRANAState
dataclass
¶
State for VIBRANA visualization sync.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
51 52 53 54 55 56 57 58 59 | |
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
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 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 | |
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
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
create_bridge(ccw_params=None)
¶
Factory function to create a CCW bridge instance.
Source code in src/sc_neurocore/interfaces/ccw_bridge.py
414 415 416 | |
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
15 16 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 | |
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
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 | |
generate_bitstream_frame(length=256)
¶
Generate a HxWxLength bitstream cube from current surface state.
Source code in src/sc_neurocore/interfaces/dvs_input.py
63 64 65 66 67 68 69 70 71 72 | |
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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
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
26 27 28 29 30 31 32 | |
ROS2Node
¶
ROS 2 Interface Node. Publishes motor commands from sc-neurocore to robots.
Source code in src/sc_neurocore/interfaces/real_world.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
publish_cmd_vel(linear_x, angular_z)
¶
Simulates publishing to /cmd_vel.
Source code in src/sc_neurocore/interfaces/real_world.py
45 46 47 48 49 50 51 52 | |