qc.camera¶
CameraTestSuite ¶
CameraTestSuite(
data_stream: Camera,
*,
expected_fps: Optional[int] = None,
clock_jitter_s: float = 0.0001,
start_time_s: Optional[float] = None,
stop_time_s: Optional[float] = None,
)
Bases: Suite
Test suite for validating camera data integrity.
Provides tests for validating video and metadata integrity according to the AIND file format specification for behavior videos.
For more details, see: https://github.com/AllenNeuralDynamics/aind-file-standards/blob/ce0aa517a40064d1ac9764d42c9efe4ae5c61f7b/file_formats/behavior_videos.md
Attributes:
Name | Type | Description |
---|---|---|
data_stream |
Camera
|
The Camera data stream to test. |
expected_fps |
Optional expected frames per second for validation. |
|
clock_jitter_s |
Maximum allowed time difference between frame timestamps, in seconds. |
|
start_time_s |
Optional expected start time for validation, in seconds. |
|
stop_time_s |
Optional expected stop time for validation, in seconds. |
Examples:
from contraqctor.contract.camera import Camera, CameraParams
from contraqctor.qc.camera import CameraTestSuite
from contraqctor.qc.base import Runner
# Create and load a camera data stream
params = CameraParams(path="recordings/session1/")
camera_stream = Camera("front_camera", reader_params=params).load()
# Create test suite with validation parameters
suite = CameraTestSuite(
camera_stream,
expected_fps=30,
start_time_s=10.0,
stop_time_s=310.0
)
# Run tests
runner = Runner().add_suite(suite)
results = runner.run_all_with_progress()
Initialize the camera test suite.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_stream
|
Camera
|
The Camera data stream to test. |
required |
expected_fps
|
Optional[int]
|
Optional expected frames per second for validation. |
None
|
clock_jitter_s
|
float
|
Maximum allowed time difference between frame timestamps, in seconds. |
0.0001
|
start_time_s
|
Optional[float]
|
Optional expected start time for validation, in seconds. |
None
|
stop_time_s
|
Optional[float]
|
Optional expected stop time for validation, in seconds. |
None
|
Source code in src/contraqctor/qc/camera.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
description
property
¶
name
property
¶
name: str
Get the name of the test suite.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the test suite class. |
test_metadata_shape ¶
test_metadata_shape()
Checks if the metadata DataFrame has the expected shape. Including headers.
Source code in src/contraqctor/qc/camera.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
test_check_dropped_frames ¶
test_check_dropped_frames()
Check if there are dropped frames in the metadata DataFrame.
Source code in src/contraqctor/qc/camera.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
test_match_expected_fps ¶
test_match_expected_fps()
Check if the frames per second (FPS) of the video metadata matches the expected FPS.
Source code in src/contraqctor/qc/camera.py
120 121 122 123 124 125 126 127 128 129 130 131 |
|
test_is_start_bounded ¶
test_is_start_bounded()
Check if the start time of the video is bounded by the provided start time.
Source code in src/contraqctor/qc/camera.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
test_is_stop_bounded ¶
test_is_stop_bounded()
Check if the stop time of the video is bounded by the provided stop time.
Source code in src/contraqctor/qc/camera.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
test_video_frame_count ¶
test_video_frame_count()
Check if the number of frames in the video matches the number of rows in the metadata DataFrame.
Source code in src/contraqctor/qc/camera.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
test_histogram_and_create_asset ¶
test_histogram_and_create_asset()
Checks the histogram of the video and ensures color is well distributed. It also saves an asset with a single frame of the video and color histogram.
Source code in src/contraqctor/qc/camera.py
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 |
|
get_tests ¶
Find all methods starting with 'test'.
Yields:
Name | Type | Description |
---|---|---|
ITest |
ITest
|
Test methods found in the suite. |
Source code in src/contraqctor/qc/base.py
321 322 323 324 325 326 327 328 329 |
|
pass_test ¶
pass_test() -> Result
pass_test(
result: Any = None,
message: Optional[str] = None,
*,
context: Optional[Any] = None,
) -> Result
Create a passing test result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result
|
Any
|
The value to include in the test result. |
None
|
message
|
Optional[str]
|
Optional message describing why the test passed. |
None
|
context
|
Optional[Any]
|
Optional contextual data for the test result. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Result |
Result
|
A Result object with PASSED status. |
Source code in src/contraqctor/qc/base.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
|
warn_test ¶
warn_test() -> Result
warn_test(
result: Any = None,
message: Optional[str] = None,
*,
context: Optional[Any] = None,
) -> Result
Create a warning test result.
Creates a result with WARNING status, or FAILED if warnings are elevated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result
|
Any
|
The value to include in the test result. |
None
|
message
|
Optional[str]
|
Optional message describing the warning. |
None
|
context
|
Optional[Any]
|
Optional contextual data for the test result. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Result |
Result
|
A Result object with WARNING or FAILED status. |
Source code in src/contraqctor/qc/base.py
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 |
|
fail_test ¶
fail_test() -> Result
fail_test(
result: Optional[Any] = None,
message: Optional[str] = None,
*,
context: Optional[Any] = None,
) -> Result
Create a failing test result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result
|
Optional[Any]
|
The value to include in the test result. |
None
|
message
|
Optional[str]
|
Optional message describing why the test failed. |
None
|
context
|
Optional[Any]
|
Optional contextual data for the test result. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Result |
Result
|
A Result object with FAILED status. |
Source code in src/contraqctor/qc/base.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
|
skip_test ¶
skip_test() -> Result
Create a skipped test result.
Creates a result with SKIPPED status, or FAILED if skips are elevated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
Optional[str]
|
Optional message explaining why the test was skipped. |
None
|
context
|
Optional[Any]
|
Optional contextual data for the test result. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Result |
Result
|
A Result object with SKIPPED or FAILED status. |
Source code in src/contraqctor/qc/base.py
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
setup ¶
setup() -> None
Run before each test method.
This method can be overridden by subclasses to implement setup logic that runs before each test.
Source code in src/contraqctor/qc/base.py
685 686 687 688 689 690 691 |
|
teardown ¶
teardown() -> None
Run after each test method.
This method can be overridden by subclasses to implement teardown logic that runs after each test.
Source code in src/contraqctor/qc/base.py
693 694 695 696 697 698 699 |
|
run_test ¶
Run a single test method and yield its results.
Handles setup, test execution, result processing, and teardown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_method
|
ITest
|
The test method to run. |
required |
Yields:
Name | Type | Description |
---|---|---|
Result |
Result
|
Result objects produced by the test method. |
Source code in src/contraqctor/qc/base.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 |
|
run_all ¶
Run all test methods in the suite.
Finds all test methods and runs them in sequence.
Yields:
Name | Type | Description |
---|---|---|
Result |
Result
|
Result objects produced by all test methods. |
Source code in src/contraqctor/qc/base.py
785 786 787 788 789 790 791 792 793 794 |
|