API Reference
Synchronous datasets
ProfiledDataset
apairo.core.profiled_dataset.ProfiledDataset
Bases: SynchronousDataset, ConfigurableDataset
Synchronous dataset driven by a YAML structural profile.
Subclasses declare a _profile class attribute pointing to a YAML file
(relative to apairo/dataset/profiles/ or an absolute path). The profile
describes the directory layout, file extensions, dtypes, and any type
transformations. All file discovery, loading, split filtering, and derived
key resolution are handled automatically.
Example
Minimal subclass::
class MyDataset(ProfiledDataset):
_profile = "my_dataset.yaml"
Usage::
ds = MyDataset("/data/my_dataset", keys=["lidar", "labels"], split="train")
sample = ds[0]
# sample.data["lidar"] -> np.ndarray
# sample.data["labels"] -> np.ndarray
Attributes:
| Name | Type | Description |
|---|---|---|
available_keys |
FrozenSet[str]
|
Frozenset of key names declared in the profile. Populated at class definition time from the YAML file. |
See Also
YAML Profiles <https://apairo-robotics.github.io/apairo/datasets/yaml-profiles/>_
for the full profile specification.
Source code in apairo/core/profiled_dataset.py
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 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
frame_sequence_ids
property
Sequence ID for every frame, indexed by global frame index.
Returns a string array of shape (len(self),) where
frame_sequence_ids[i] is the sequence ID that frame i belongs
to. Combined with :attr:FilteredView.indices, this lets you split a
pre-filtered dataset by sequence without a second disk sweep::
ds_filtered = ds.filter("trav_gt", HasMinPositives(min_pos))
seq_ids = ds.frame_sequence_ids[ds_filtered.indices]
for train_seqs, val_seqs in folds:
train_idx = np.where(np.isin(seq_ids, train_seqs))[0]
val_idx = np.where(np.isin(seq_ids, val_seqs))[0]
ds_train = ds_filtered.filter(train_idx)
ds_val = ds_filtered.filter(val_idx)
frame_stems
property
Filename stem for every frame, indexed by global frame index.
describe
Describe available channels for this dataset.
Reads .apairo at the dataset root (creating it if absent) and
cross-references it with the profile's declared modalities to show
which raw channels are present or missing, and which preprocessed
channels have been registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_id
|
str | None
|
Optional sequence identifier -- used as the display label only. Channel availability is dataset-wide. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Example::
ds = Rellis3DDataset("/data/RELLIS")
ds.describe("00000")
Source code in apairo/core/profiled_dataset.py
split
Return a new dataset instance filtered to the named split.
Source code in apairo/core/profiled_dataset.py
filter_split
Return a FilteredView restricted to the named predefined split.
Applies the split without re-instantiating the dataset — registered
transforms are preserved. Replaces :meth:split for use mid-chain::
ds.transform("lidar", RobotFilter())
ds_train = ds.filter_split("train") # transforms kept
Source code in apairo/core/profiled_dataset.py
SynchronousDataset
apairo.core.synchronous_dataset.SynchronousDataset
Bases: AbstractDataset
Base class for datasets where index i returns a complete synchronous frame.
All modalities at index i are co-captured -- no timestamps, no interleaving.
sample.timestamp is always None. Random access and standard PyTorch
DataLoader shuffling work without any additional wrappers.
Subclasses must implement __len__ and _load.
For new synchronous datasets, prefer extending
:class:~apairo.core.profiled_dataset.ProfiledDataset with a YAML profile
rather than subclassing this directly.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamps |
Always |
Source code in apairo/core/synchronous_dataset.py
SemanticKittiDataset
apairo.dataset.semantic_kitti.SemanticKittiDataset
Bases: ProfiledDataset
SemanticKITTI dataset -- driving LiDAR with dense semantic labels.
Keys: lidar (float32, shape (N, 4)), labels (int64, lower 16 bits = semantic class).
Example::
ds = SemanticKittiDataset("/data/kitti/dataset", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
Source code in apairo/dataset/semantic_kitti/dataset.py
Goose3DDataset
apairo.dataset.goose.Goose3DDataset
Bases: ProfiledDataset
GOOSE 3D dataset -- outdoor off-road LiDAR with traversability labels.
Keys: lidar (float32, shape (N, 4)), labels (int64).
Split: "train", "val", or "test".
Example::
ds = Goose3DDataset("/data/GOOSE_3D", keys=["lidar", "labels"], split="train")
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
Source code in apairo/dataset/goose/dataset.py
Rellis3DDataset
apairo.dataset.rellis.Rellis3DDataset
Bases: ProfiledDataset
RELLIS-3D dataset -- off-road LiDAR with semantic labels.
Keys: lidar (float32, shape (N, 4)), labels (int64).
Optional: poses (float64, shape (3, 4)) -- one 3x4 pose matrix per frame,
loaded from a per-sequence poses.txt file (one row of 12 floats per frame).
Example::
ds = Rellis3DDataset("/data/RELLIS", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
ds = Rellis3DDataset("/data/RELLIS", keys=["lidar", "poses"])
# sample.data["poses"] -> np.ndarray (3, 4)
Source code in apairo/dataset/rellis/dataset.py
Asynchronous datasets
RawDataset
apairo.dataset.raw.RawDataset
Bases: RootSequenceMixin, AsyncLayoutDataset, ConfigurableDataset
Generic channels.yaml-driven dataset; single sequence or dataset root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
A sequence directory (has |
required |
keys
|
Optional[List[str]]
|
Channels to load. |
None
|
Example::
RawDataset.init(seq_dir) # once: write .apairo
ds = RawDataset(root, keys=["lidar", "imu"]) # whole dataset
ds.run_preprocess(MyLabeler()) # persisted as a new channel
Source code in apairo/dataset/raw/dataset.py
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 | |
calibration
property
Static extrinsics from .apairo/calibration.yaml (e.g. written from
/tf_static). On a root, sequences' tables are merged.
init
classmethod
init(directory: str | Path, *, merge: bool = False, overwrite: bool = False, name: Optional[str] = None) -> Path
Write the .apairo sidecar(s) by scanning directory. Root-aware.
A sequence directory (its sub-directories hold data files) gets a
.apairo/channels.yaml with loaders inferred per channel. A root
directory (its sub-directories are sequences) gets each sequence
initialised, then a .apairo/dataset.yaml manifest (name + sequence
order + channel union).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Sequence or dataset-root directory (auto-detected). |
required |
merge
|
bool
|
Add newly detected channels without touching existing ones. |
False
|
overwrite
|
bool
|
Discard existing |
False
|
name
|
Optional[str]
|
Dataset name for the root manifest (default: directory name). |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the file written -- |
Path
|
|
Source code in apairo/dataset/raw/dataset.py
TartanKittiDataset
apairo.dataset.tartan_kitti.TartanKittiDataset
Bases: RootSequenceMixin, AsyncLayoutDataset, ConfigurableDataset
TartanDrive v2 dataset (asynchronous layout, fixed channel profile).
A profiled member of the asynchronous layout family: the on-disk format is
handled by :class:~apairo.dataset.kitti.AsyncLayoutDataset, the
multi-sequence root behaviour by
:class:~apairo.core.root_sequence.RootSequenceMixin, and this class pins
the fixed TartanDrive channel set via profile.yaml. (Datasets with a
dynamic channel set use :class:~apairo.dataset.raw.RawDataset instead.)
Accepts either a single sequence directory or a root directory that contains multiple sequences -- the structure is auto-detected.
Single sequence::
ds = TartanKittiDataset(seq_dir, keys=["velodyne_0", "cmd"])
Root directory (all sequences, flat access)::
ds = TartanKittiDataset(root_dir, keys=["velodyne_0"])
len(ds) # total events across all sequences
ds.sequences # list[TartanKittiDataset], one per sequence
Lazy init -- inspect before loading::
ds = TartanKittiDataset(root_or_seq_dir)
ds.available # frozenset of available channels
ds.keys = ["velodyne_0"] # initialize loaders
ds.keys = "all" # or load everything
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Single sequence directory or root directory. |
required |
keys
|
Optional[List[str] | str]
|
Channels to load. |
None
|
Source code in apairo/dataset/tartan_kitti/dataset.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 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 | |
describe
classmethod
Describe available channels -- auto-detects root vs sequence directory.
Root directory: lists each sequence with its raw and preprocessed channels. Sequence directory: shows raw present/missing and preprocessed channels.
Source code in apairo/dataset/tartan_kitti/dataset.py
AsyncLayoutDataset
Abstract per-channel layout base for the asynchronous family. Internal base
class — subclass it to add a fixed-channel async dataset; end users load through
RawDataset or TartanKittiDataset.
apairo.dataset.kitti.AsyncLayoutDataset
Bases: AbstractDataset
Abstract asynchronous layout loader (one subdirectory per channel).
This is the format primitive of the asynchronous dataset family -- it is
not the KITTI dataset (no real KITTI dataset uses it; see
:class:~apairo.dataset.semantic_kitti.SemanticKittiDataset, which is a
synchronous :class:~apairo.core.profiled_dataset.ProfiledDataset).
It describes how channels are stored, never which channels exist: each
channel is a subdirectory with its own timestamps.txt and data files in
a format known to the loader registry (npys, npy, bin, img,
zarr). The set of channels is per-instance state, read from
.apairo/channels.yaml (or an explicit dataset_profile). Datasets
with a fixed channel set layer a profile on top (e.g.
:class:~apairo.dataset.tartan_kitti.TartanKittiDataset); datasets with
dynamic channels (e.g. apairo-extractor output) use
:class:~apairo.dataset.raw.RawDataset, which reads the channel set from
.apairo with no profile.
Usage with an explicit profile (original API)::
ds = AsyncLayoutDataset(seq_dir, keys=["lidar", "cam"], dataset_profile="my.yaml")
Usage with .apairo (after :meth:init has been called)::
AsyncLayoutDataset.init(seq_dir) # once, auto-detects channels
ds = AsyncLayoutDataset(seq_dir) # keys and loaders come from .apairo
ds = AsyncLayoutDataset(seq_dir, keys=["lidar"]) # restrict to a subset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Path to the dataset root / sequence directory. |
required |
keys
|
Optional[List[str]]
|
Modality names to load. |
None
|
dataset_profile
|
Optional[str | Path]
|
YAML profile filename or absolute Path mapping keys
to loader types. |
None
|
Source code in apairo/dataset/kitti/dataset.py
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 | |
init
classmethod
init(directory: str | Path, *, raw_keys: Optional[List[str]] = None, overwrite: bool = False, merge: bool = False) -> None
Scan a KITTI-layout directory and write .apairo/channels.yaml.
All detected subdirectories are registered as raw channels. Loader type is inferred from file extensions:
.bin→bin.png/.jpg/ … →img- multiple
.npyfiles →npys - single
.npyfile →npy
For ambiguous cases (e.g. a single-frame .npy that is actually
per-frame), call :func:~apairo.core.config.register_raw_channel
afterwards to override the detected loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
KITTI root / sequence directory to initialize. |
required |
raw_keys
|
Optional[List[str]]
|
Subdirectory names to include. |
None
|
overwrite
|
bool
|
Discard the existing |
False
|
merge
|
bool
|
Add newly detected raw channels to an existing |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
FileExistsError
|
If |
ValueError
|
If no new recognizable channels are found. |
Source code in apairo/dataset/kitti/dataset.py
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 | |
StreamDataset
apairo.dataset.stream.StreamDataset
Bases: AbstractDataset
In-memory asynchronous dataset built from timestamped event streams.
The bridge between live or freshly-decoded data (ROS messages, queue
items, arrays in RAM) and the apairo API: give it one (timestamps,
items) pair per channel and it behaves exactly like a file-backed
asynchronous dataset -- merged timeline, single-event samples, and above
all :meth:~apairo.core.abstract_dataset.AbstractDataset.synchronize::
ds = StreamDataset({
"image": (img_ts, img_msgs), # any indexable items
"lidar": (lidar_ts, lidar_msgs),
"odom": (odom_ts, odom_msgs),
})
ds[0] # one event, timestamp-ordered
frames = ds.synchronize(reference=clock, method="latest")
Items are stored as given -- they can be numpy arrays, ROS messages, or any Python objects; apairo never copies or converts them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
streams
|
Dict[str, Tuple[ndarray, Sequence]]
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
On empty streams, length mismatch, or non-ascending timestamps. |
Source code in apairo/dataset/stream.py
SynchronizedView
apairo.core.synchronized_view.SynchronizedView
Bases: AbstractDataset
A synchronous view over an asynchronous dataset.
Created by :meth:~apairo.core.abstract_dataset.AbstractDataset.synchronize.
Index i returns a complete sample built around the i-th tick of the
reference clock: every channel contributes either an existing event
matched by timestamp, or a value synthesized at the tick by an
:class:~apairo.core.interpolator.Interpolator. The matching is a pure
index computation (one np.searchsorted per channel at construction
time) -- no data is read until access.
Because the view is synchronous (timestamps is None), the full
chaining API applies: .filter(), .select(), .cache(),
.join(), and map-style PyTorch DataLoader with shuffling.
.. note:: The view reads channel data directly from the parent's loaders -- transforms registered on the parent are not applied (they were written for single-event samples). Register transforms on the view::
ds_sync = ds.synchronize().transform("velodyne_0", RangeFilter(50))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
AbstractDataset
|
Asynchronous dataset exposing per-channel |
required |
reference
|
str | ndarray | None
|
The clock to resample onto. Three forms:
|
None
|
method
|
ChannelStrategy | dict[str, ChannelStrategy]
|
Strategy applied to every channel, or a dict mapping channel
names to per-channel strategies (unlisted channels default to
|
'latest'
|
tolerance
|
float | None
|
Maximum |
None
|
Example::
from apairo_transform.interp import Se3Interp
ds = TartanKittiDataset(seq, keys=["velodyne_0", "gicp_poses"])
ds_sync = ds.synchronize(
reference="velodyne_0",
method={"gicp_poses": Se3Interp()}, # velodyne_0 -> "latest"
tolerance=0.05,
)
s = ds_sync[0]
s.data["gicp_poses"] # pose interpolated at s.timestamp
Source code in apairo/core/synchronized_view.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 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 | |
reference
property
Channel providing the clock, or None for an external clock.
reference_timestamps
property
Timestamp of each frame in the view (reference clock).
frame_indices
property
Per-channel event indices backing each frame.
Shape (n,) for matched channels (the event used), (n, 2) for
interpolated channels (the bracketing pair).
time_offsets
Signed t_event - t_ref per frame for key, in seconds.
Interpolated channels return zeros: their values are synthesized at the reference instant.
Source code in apairo/core/synchronized_view.py
Interpolator
apairo.core.interpolator.Interpolator
Bases: ABC
Synthesize a channel value at the reference instant from its two bracketing events.
This is the value-level counterpart of the index-level matching
strategies ("latest", "nearest"): instead of picking an existing
event, an interpolator builds a new value at t_ref. Use it for
continuous signals -- poses, IMU, commands -- never for data that cannot
be blended (point clouds, images).
Contract, as orchestrated by
:class:~apairo.core.synchronized_view.SynchronizedView:
- a channel whose strategy is an
Interpolatorreceives, for each reference tickt, its two bracketing events(t0, v0)and(t1, v1)witht0 <= t <= t1andt0 < t1; - ticks not bracketed by two events (before the first event or after the last) are dropped from the view;
- exact matches (
t == t0) bypass the interpolator -- the stored value is returned directly, so implementations never seet0 == t1; - with
tolerance, both neighbours must lie within tolerance oft(max(t - t0, t1 - t) <= tolerance).
Concrete implementations (LinearInterp, Se3Interp, ...) live in
apairo_transform.interp.
Example::
class LinearInterp(Interpolator):
def __call__(self, t, t0, v0, t1, v1):
a = (t - t0) / (t1 - t0)
return (1.0 - a) * v0 + a * v1
Source code in apairo/core/interpolator.py
__call__
abstractmethod
Dataset composition
ConcatDataset
apairo.dataset.concat.ConcatDataset
Bases: AbstractDataset
Concatenates multiple dataset instances into one.
Takes the intersection of keys across all datasets so every index returns the same set of modalities regardless of which underlying dataset is hit. Indexing is O(log n) via binary search over cumulative lengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
List[AbstractDataset]
|
Non-empty list of dataset instances to concatenate. |
required |
Example::
sequences = [
SemanticKittiDataset(f"/data/kitti/seq_{i:02d}", keys=["lidar", "labels"])
for i in range(11)
]
combined = ConcatDataset(sequences)
sample = combined[0]
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in apairo/dataset/concat.py
split_sequences
apairo.dataset.split_sequences
split_sequences(datasets: list, ratios: tuple[float, float, float] = (0.8, 0.1, 0.1)) -> tuple[list, list, list]
Split datasets into train/val/test at the sequence level.
Splitting at sequence level avoids temporal leakage between splits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
list
|
Ordered list (one entry per recording session). |
required |
ratios
|
tuple[float, float, float]
|
(train, val, test) fractions, must sum to 1.0. |
(0.8, 0.1, 0.1)
|
Source code in apairo/dataset/__init__.py
Extensibility
ConfigurableDataset
apairo.core.configurable_dataset.ConfigurableDataset
Mixin for datasets that support preprocessed-channel extensibility via .apairo.
Any dataset class that wants to be extensible at runtime (i.e. allow users to register new preprocessed channels without touching source code) should inherit from this mixin alongside its normal base class.
Concrete subclasses must implement :meth:_bootstrap_config, which describes
how to auto-discover the dataset's raw channels when .apairo does not yet
exist.
Usage pattern for preprocessing scripts::
MyDataset.register_channel(
seq_dir, "my_channel", "npys",
timestamps_from="lidar",
sources=["lidar"],
)
Usage in dataset __init__::
config = self._load_or_create_config(sequence_dir)
Source code in apairo/core/configurable_dataset.py
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 | |
run_preprocess
class-attribute
instance-attribute
Run a preprocessor and persist the output channel.
Can be called on the class or on an existing instance:
Class form -- root_dir required::
Goose3DDataset.run_preprocess(preprocessor, "/data/GOOSE_3D", split="train")
Instance form -- root_dir inferred from the dataset::
ds = Goose3DDataset("/data/GOOSE_3D", keys=["lidar"], split="train")
ds.run_preprocess(preprocessor)
Extra keyword arguments are forwarded to the dataset constructor (class form)
or ignored (instance form, since the instance is already configured).
overwrite=True recomputes even if the output already exists.
register_channel
classmethod
register_channel(sequence_dir: str | Path, key: str, loader: str, *, timestamps_from: Optional[str] = None, sources: Optional[list[str]] = None) -> None
Register a preprocessed channel in sequence_dir/.apairo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
timestamps_from
|
Optional[str]
|
Channel whose timestamps to share when this channel
has no |
None
|
sources
|
Optional[list[str]]
|
Provenance -- channels this channel was derived from. |
None
|
Source code in apairo/core/configurable_dataset.py
describe
classmethod
Describe what is available in a sequence directory.
Reads .apairo (creating it if absent) and cross-references it with
the class's :attr:available_keys to produce a three-way breakdown:
- raw / present -- raw channels on disk and registered
- raw / missing -- raw channels known from the profile but not on disk
- preprocess -- channels produced by a preprocessing pipeline
Returns the breakdown as a dict and prints a human-readable summary.
Example::
MyDataset.describe("/data/my_dataset/sequence_01")
Source code in apairo/core/configurable_dataset.py
register_raw_channel
classmethod
register_raw_channel(sequence_dir: str | Path, key: str, loader: str, *, has_timestamps: Optional[bool] = None) -> None
Declare a raw channel in sequence_dir/.apairo.
Use this to manually add or override a raw channel declaration, for
example after :meth:init detected the wrong loader type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
has_timestamps
|
Optional[bool]
|
Whether the channel has |
None
|
Source code in apairo/core/configurable_dataset.py
verify
classmethod
Verify that .apairo is coherent with what is on disk.
Prints any issues found and returns True when the config is clean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory containing |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Example::
ok = MyDataset.verify("/data/my_dataset/seq_01")
Source code in apairo/core/configurable_dataset.py
RootSequenceMixin
Shared single-sequence vs. dataset-root handling for the asynchronous family
(flat indexing, per-sequence access, per-sequence synchronize + concat).
Reused by RawDataset and TartanKittiDataset.
apairo.core.root_sequence.RootSequenceMixin
Flat-indexed root over several same-typed sequence datasets.
Source code in apairo/core/root_sequence.py
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 | |
available
property
Channels available -- intersection across sequences for a root dataset.
sequence_ids
property
Sequence directory names, in load order (root datasets only).
sequence
Return a :class:~apairo.core.sequence_view.SequenceView for seq_id.
Source code in apairo/core/root_sequence.py
synchronize
Resample onto a reference clock -- see :meth:AbstractDataset.synchronize.
On a root dataset each sequence is synchronized independently (clocks are not comparable across recordings) and the results concatenated, so an external clock array is only valid on a single sequence.
Source code in apairo/core/root_sequence.py
register_channel
apairo.core.config.register_channel
register_channel(root_dir: str | Path, key: str, loader: str, *, timestamps_from: Optional[str] = None, sources: Optional[list[str]] = None, frame: Optional[str] = None) -> None
Register a preprocessed channel in root_dir/.apairo/channels.yaml.
This is the low-level standalone function. Most users will prefer the
classmethod :meth:ConfigurableDataset.register_channel so that the call
site names the dataset type explicitly.
Existing channels (raw or preprocessed) are preserved -- only key is
updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dir
|
str | Path
|
Dataset root directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
timestamps_from
|
Optional[str]
|
Source channel whose timestamps this channel shares
(provenance only -- the channel always has its own |
None
|
sources
|
Optional[list[str]]
|
Provenance -- raw channels this channel was derived from. |
None
|
frame
|
Optional[str]
|
Coordinate frame the channel's data is expressed in (descriptive metadata only; apairo does not apply transforms). |
None
|
Source code in apairo/core/config.py
WRITERS
Format writers used by the preprocessing runner.
Keyed by loader name ("npy", "npys", "bin", "pt").
from apairo import WRITERS
writer = WRITERS["npy"]()
writer.write(my_array, Path("/data/output/000000.npy"))
apairo.writer.WRITERS
module-attribute
WRITERS: dict[str, type] = {'npy': NPYWriter, 'npys': NPYWriter, 'bin': BINWriter, 'zarr': ZarrWriter, 'img': TarImageWriter}
DERIVED_LOADERS
File-level loaders for derived/preprocessed keys.
Keyed by loader name ("npy", "pt", "bin", "img").
Each entry is a Callable[[Path], torch.Tensor].
apairo.loader.DERIVED_LOADERS
module-attribute
DERIVED_LOADERS: dict[str, Callable[[Path], ndarray]] = {'npy': lambda path: load(path), 'bin': lambda path: fromfile(path, dtype=float32), 'img': _load_img}
Preprocessing
FramePreprocessor
apairo.core.preprocessor.FramePreprocessor
Bases: Preprocessor
Preprocessor that operates frame-by-frame.
The runner calls :meth:process once per input frame. Use this for
per-scan operations (label inference, feature extraction, …).
Output is stored as one file per frame (000000.npy, 000001.npy,
…) when output_loader is "npys" or "bin".
Example::
class TravLabel(FramePreprocessor):
output_key = "trav_label"
output_loader = "npys"
input_keys = ["velodyne_0"]
timestamps_from = "velodyne_0" # no own timestamps.txt
def process(self, sample: Sample) -> np.ndarray:
pts = sample.data["velodyne_0"]
return my_model(pts)
Source code in apairo/core/preprocessor.py
process
abstractmethod
Process one frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample
|
A :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A |
Source code in apairo/core/preprocessor.py
SequencePreprocessor
apairo.core.preprocessor.SequencePreprocessor
Bases: Preprocessor
Preprocessor that operates on the full sequence at once.
The runner calls :meth:process with an iterator over all input frames.
Use this for algorithms that need global context (ICP, trajectory
smoothing, …).
Output is stored as a single {output_key}.npy file when
output_loader is "npy".
Example::
class GICPPoses(SequencePreprocessor):
output_key = "gicp_poses"
output_loader = "npy"
input_keys = ["velodyne_0"]
sources = ["velodyne_0"] # has its own timestamps.txt
def process(self, frames: Iterator[Sample]) -> np.ndarray:
poses = []
for sample in frames:
pts = sample.data["velodyne_0"]
poses.append(register(pts))
return np.stack(poses) # (N, 4, 4)
Source code in apairo/core/preprocessor.py
process
abstractmethod
Process all frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Iterator[Sample]
|
Iterator of :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A |
Source code in apairo/core/preprocessor.py
Data structures
Sample
apairo.core.sample.Sample
dataclass
A single dataset sample -- one timeline event or one complete frame.
For temporal datasets: data has one key, timestamp is set. For synchronous datasets: data has all modality keys, timestamp is None.