Core¶
Joint data object and shared primitives.
BaseData¶
Unified container for neural data, stimulus labels, and trial structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neuro
|
ndarray | None
|
Neural data array. |
required |
neuro_info
|
dict
|
Metadata dict. Required key: |
required |
stim_labels
|
ndarray | None
|
Internal stimulus-label array of shape |
None
|
vision_info
|
dict | None
|
Dict with |
None
|
trial
|
ndarray | None
|
Trial-ID array of shape |
None
|
trial_info
|
dict | None
|
Dict with |
None
|
trial_starts
|
ndarray | None
|
Start sample indices per trial, shape |
None
|
trial_ends
|
ndarray | None
|
End sample indices per trial, shape |
None
|
vision_onsets
|
ndarray | None
|
Stimulus onset sample indices, shape |
None
|
trial_meta
|
DataFrame | None
|
Per-trial metadata table. |
None
|
data_mode
|
str or None
|
|
None
|
Examples:
>>> import numpy as np
>>> neuro = np.random.randn(1000, 64)
>>> info = dict(sfreq=250.0, ch_names=[f"ch{i}" for i in range(64)])
>>> bd = BaseData(neuro, info)
>>> bd
BaseData(ntime=1000, nchan=64, n_trials=0, configured=False)
Source code in src/vneurotk/core/recording.py
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 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 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | |
configured
property
¶
Whether :meth:configure has been called.
has_vision
property
¶
Whether any DNN features have been stored via :attr:vision.extract_from().
info
property
¶
Summary of neuro, visual, and trial metadata.
is_configured
property
¶
Alias for :attr:configured. True after :meth:configure succeeds.
is_vision_ready
property
¶
True when DNN features have been extracted and :attr:vision is safe to access.
n_timepoints
property
¶
Time points per trial.
n_trials
property
¶
Number of trials (0 if not configured).
nchan
property
¶
Number of channels.
neuro
property
writable
¶
Neural data as a :class:NeuroData.
Behaves like a plain ndarray; additionally exposes
.epochs and .continuous for trial-structured views.
ntime
property
¶
Number of time samples (first axis for continuous/patterns; second for epochs).
stim_labels
property
¶
Raw stimulus label array from the trial layout.
Shape depends on data_mode:
"continuous"→(ntime,)"epochs"→(n_trials, n_timebins)
None before :meth:configure is called.
trial_stim_ids
property
¶
Stimulus ID at the onset of each trial, shape (n_trials,).
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If :meth: |
vision
property
¶
DNN feature store for this dataset.
Returns a :class:VisionData with the following interface:
db— original stimulus image dict (vision_db).stim_ids— per-onset stimulus IDs, shape(n_trials,).meta— :class:~pandas.DataFramewith one row per stored :class:~vneurotk.vision.representation.VisualRepresentation.vision[mask]— smart accessor: string / int / bool-mask index; single VR → alignedndarray; multiple VRs →VisualRepresentations.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If :meth: |
configure(stim_ids, trial_window=None, vision_onsets=None, vision_db=None)
¶
Attach stimulus and trial structure to the data.
For continuous data (data_mode == "continuous"), both
trial_window and vision_onsets are required.
For pre-epoched data (data_mode == "epochs"), both parameters
are optional: vision_onsets falls back to any already-stored value,
then defaults to index 0 of each epoch; trial_window is ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_ids
|
(array - like, shape(n_onsets))
|
Stimulus ID for each onset / trial, must match vision_onsets length and order. |
required |
trial_window
|
list of float | int or None
|
Two-element |
None
|
vision_onsets
|
ndarray or None
|
1-D array of stimulus onset sample indices. Required for continuous data. For epochs data defaults to already-stored value or 0. |
None
|
vision_db
|
dict, list, np.ndarray, or None
|
Stimulus image source. Stored immediately as the Stimulus Set for
this Recording. Can also be supplied later via
:meth: |
None
|
Source code in src/vneurotk/core/recording.py
for_continuous(neuro=None, neuro_info=None, **kwargs)
classmethod
¶
Factory for continuous (2-D time-series) recordings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neuro
|
ndarray or None
|
Neural data, shape |
None
|
neuro_info
|
dict or None
|
Metadata dict; |
None
|
**kwargs
|
Any
|
Any other :class: |
{}
|
Returns:
| Type | Description |
|---|---|
BaseData
|
|
Source code in src/vneurotk/core/recording.py
for_epochs(neuro=None, neuro_info=None, **kwargs)
classmethod
¶
Factory for pre-epoched recordings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neuro
|
ndarray or None
|
Neural data, shape |
None
|
neuro_info
|
dict or None
|
Metadata dict; |
None
|
**kwargs
|
Any
|
Any other :class: |
{}
|
Returns:
| Type | Description |
|---|---|
BaseData
|
|
Source code in src/vneurotk/core/recording.py
load()
¶
Explicitly load neuro data into memory and return self.
Returns:
| Type | Description |
|---|---|
BaseData
|
self, for method chaining. |
Source code in src/vneurotk/core/recording.py
plot(window=(0.0, 5.0), figsize=(6, 3), cmap_neuro='Greys', cmap_ontime='summer', color_offtime='black', marker_size=40)
¶
Plot neural activity alongside stimulus labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
tuple of float | int
|
Display window. Float values are seconds, int values are samples. |
(0.0, 5.0)
|
figsize
|
tuple of float
|
Figure size |
(6, 3)
|
cmap_neuro
|
str
|
Colormap for neural heatmap. |
'Greys'
|
cmap_ontime
|
str
|
Colormap for in-trial time. |
'summer'
|
color_offtime
|
str
|
Color for off-trial points. |
'black'
|
marker_size
|
float
|
Scatter marker size. |
40
|
Returns:
| Type | Description |
|---|---|
Figure
|
|
Source code in src/vneurotk/core/recording.py
save(path)
¶
Persist the configured data to an HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
VTKPath | Path | str
|
Destination file path. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If :meth: |
Source code in src/vneurotk/core/recording.py
set_neuro_loader(loader)
¶
Register a lazy loader for the neuro array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loader
|
NeuroLoader
|
Callable with no arguments that returns |
required |
Source code in src/vneurotk/core/recording.py
StimulusSet¶
Container linking per-onset stimulus IDs to per-stimulus images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_ids
|
(array - like, shape(n_onsets))
|
Stimulus ID for each onset. |
required |
stimuli
|
dict, list, np.ndarray, or None
|
Image source for each unique stimulus.
|
None
|
Notes
Supported image types: PIL.Image, np.ndarray, Path, str.
Path / str entries are lazily loaded as PIL.Image on
__getitem__ access.
Examples:
Source code in src/vneurotk/core/stimulus.py
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 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 | |
stim_ids
property
¶
Per-onset stimulus IDs, shape (n_onsets,).
stimuli
property
¶
Dict {stim_id: image} or None if not provided.
unique_ids
property
¶
Unique stimulus IDs in sorted order.
__contains__(stim_id)
¶
Return True if stim_id has an associated image in this StimulusSet.
__getitem__(stim_id)
¶
Return the image for stim_id, lazily loading Path / str entries.
Source code in src/vneurotk/core/stimulus.py
from_dict(stim_ids, stimuli)
classmethod
¶
Build from an explicit {stim_id: image} mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_ids
|
(array - like, shape(n_onsets))
|
Stimulus ID per onset. |
required |
stimuli
|
dict
|
Complete |
required |
Returns:
| Type | Description |
|---|---|
StimulusSet
|
|
Source code in src/vneurotk/core/stimulus.py
from_h5(stim_ids, lazy_dict)
classmethod
¶
Build from a :class:LazyH5Dict or any Mapping for lazy HDF5 access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_ids
|
(array - like, shape(n_onsets))
|
Stimulus ID per onset. |
required |
lazy_dict
|
Mapping
|
Any mapping conforming to :class: |
required |
Returns:
| Type | Description |
|---|---|
StimulusSet
|
|
Source code in src/vneurotk/core/stimulus.py
from_unique_list(stim_ids, images)
classmethod
¶
Build from a list of images aligned with unique stim_ids.
images must have exactly as many entries as there are unique stimulus IDs, ordered by first appearance in stim_ids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_ids
|
(array - like, shape(n_onsets))
|
Stimulus ID per onset. |
required |
images
|
list
|
One image per unique stimulus, in first-appearance order. |
required |
Returns:
| Type | Description |
|---|---|
StimulusSet
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/vneurotk/core/stimulus.py
Info¶
Summary object returned by :attr:BaseData.info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neuro
|
dict
|
Dict with keys |
required |
visual
|
dict or None
|
Dict with key |
required |
trial
|
dict or None
|
Dict with keys |
required |
configured
|
bool
|
Whether the parent :class: |
required |
data_mode
|
str
|
|
'continuous'
|
Source code in src/vneurotk/core/info.py
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 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 | |