AOI perturbation API¶
The AOI perturbation surface is vendor-neutral and exported from the eyeprocesspy package front door.
aoi_perturbation ¶
AOI perturbation and uncertainty analysis public API.
__all__
module-attribute
¶
__all__ = ['OUTSIDE', 'AMBIGUOUS', 'aoi_perturbation_spec', 'validate_aoi_geometry', 'convert_aoi_margin_to_degrees', 'convert_aoi_margin_to_pixels', 'dilate_aoi', 'erode_aoi', 'translate_aoi', 'jitter_aoi', 'perturb_aoi_geometry', 'create_aoi_perturbation_grid', 'apply_aoi_perturbation_grid', 'compare_aoi_assignments', 'estimate_aoi_assignment_stability', 'estimate_fixation_assignment_probability', 'recompute_aoi_features', 'run_aoi_sensitivity_analysis', 'summarise_aoi_sensitivity', 'assess_aoi_inference_stability', 'report_aoi_sensitivity', 'plot_aoi_perturbations', 'plot_aoi_assignment_stability', 'plot_aoi_coefficient_stability', 'plot_aoi_robustness_surface']
EyeProcessValidationError ¶
Bases: EyeProcessError
Raised when a canonical dataset violates validation contracts.
EyeResult ¶
Bases: dict
Small R-list-like result object with stable class metadata.
Source code in src/eyeprocesspy/irt.py
_AssignmentVector ¶
_assign_points ¶
_assign_points(data: DataFrame, geometry: DataFrame, *, x_col: str, y_col: str, overlap_policy: str = 'ambiguous') -> pd.Series
Source code in src/eyeprocesspy/_aoi_assignment_core.py
_validate_model_table ¶
Source code in src/eyeprocesspy/_aoi_assignment_core.py
compare_aoi_assignments ¶
compare_aoi_assignments(baseline: Sequence[Any], perturbed: Sequence[Any], *, ids: Sequence[Any] | None = None) -> EyeResult
Source code in src/eyeprocesspy/_aoi_assignment_core.py
estimate_aoi_assignment_stability ¶
estimate_aoi_assignment_stability(comparisons: Mapping[str, Any] | DataFrame, *, metadata: DataFrame | None = None, group_cols: Sequence[str] | None = None) -> EyeResult
Source code in src/eyeprocesspy/_aoi_assignment_core.py
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 | |
estimate_fixation_assignment_probability ¶
estimate_fixation_assignment_probability(assignments: Mapping[str, Sequence[Any]] | DataFrame, *, ids: Sequence[Any] | None = None, include_baseline: bool = True) -> pd.DataFrame
Estimate empirical assignment frequencies across a declared perturbation set.
Source code in src/eyeprocesspy/_aoi_assignment_core.py
recompute_aoi_features ¶
recompute_aoi_features(data: DataFrame, assignments: Sequence[Any], *, participant_col: str | None = None, trial_col: str | None = None, duration_col: str | None = None, time_col: str | None = None, perturbation_id: str | None = None, aoi_levels: Sequence[str] | None = None, observation_level: str = 'fixation') -> pd.DataFrame
Recompute AOI features without dropping observed zero-assignment cells.
A participant/trial × AOI cell receives a structural zero count only when the group contains at least one non-missing AOI assignment opportunity. Groups whose assignments are all missing retain NA counts/inspection. Dwell is NA when an assigned observation has missing duration, and first-fixation timing is never inferred from row order.
Source code in src/eyeprocesspy/_aoi_assignment_core.py
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 | |
_frame ¶
_software_provenance ¶
Source code in src/eyeprocesspy/_aoi_geometry_primitives.py
_stable_frame_hash ¶
Source code in src/eyeprocesspy/_aoi_geometry_primitives.py
_spec_value ¶
Source code in src/eyeprocesspy/_aoi_geometry_units.py
aoi_perturbation_spec ¶
aoi_perturbation_spec(perturbation_id: str, operation: str = 'baseline', *, margin_x: float = 0.0, margin_y: float | None = None, translation_x: float = 0.0, translation_y: float = 0.0, unit: str = 'px', screen_width_px: int | None = None, screen_height_px: int | None = None, viewing_distance: float | None = None, physical_screen_size: Sequence[float] | None = None, degrees_per_pixel: Sequence[float] | None = None, seed: int | None = None, boundary_policy: str = 'warn') -> EyeResult
Create a validated, reproducible AOI perturbation specification.
Source code in src/eyeprocesspy/_aoi_geometry_units.py
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 | |
convert_aoi_margin_to_degrees ¶
convert_aoi_margin_to_degrees(margin_pixels: Any, *, screen_width_px: int, screen_height_px: int, viewing_distance: float, physical_screen_size: Sequence[float]) -> tuple[float, float]
Convert pixel margins to degrees of visual angle on x and y axes.
Source code in src/eyeprocesspy/_aoi_geometry_units.py
convert_aoi_margin_to_pixels ¶
convert_aoi_margin_to_pixels(margin_degrees: Any, *, screen_width_px: int, screen_height_px: int, viewing_distance: float, physical_screen_size: Sequence[float]) -> tuple[float, float]
Convert visual-angle margins to pixels on x and y axes.
Source code in src/eyeprocesspy/_aoi_geometry_units.py
validate_aoi_geometry ¶
Validate rectangular and polygonal AOI geometry without resolving overlap.
Source code in src/eyeprocesspy/_aoi_geometry_validation.py
apply_aoi_perturbation_grid ¶
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
create_aoi_perturbation_grid ¶
create_aoi_perturbation_grid(*, dilations: Iterable[float] | None = None, erosions: Iterable[float] | None = None, translations_x: Iterable[float] | None = None, translations_y: Iterable[float] | None = None, translations_xy: Iterable[Sequence[float]] | None = None, jitters: Iterable[float] | None = None, anisotropic: Iterable[Sequence[float]] | None = None, unit: str = 'px', include_baseline: bool = True, seed: int = 20260918, **geometry_kwargs: Any) -> EyeResult
Create a deterministic perturbation grid without silently crossing choices.
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
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 | |
dilate_aoi ¶
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
erode_aoi ¶
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
jitter_aoi ¶
jitter_aoi(aois: DataFrame, x: float, y: float | None = None, *, seed: int = 20260918, **kwargs: Any) -> pd.DataFrame
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
perturb_aoi_geometry ¶
Apply one perturbation and preserve nominal and transformed provenance.
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
translate_aoi ¶
Source code in src/eyeprocesspy/_aoi_perturb_ops.py
plot_aoi_assignment_stability ¶
Source code in src/eyeprocesspy/plots_aoi_perturbation.py
plot_aoi_coefficient_stability ¶
Source code in src/eyeprocesspy/plots_aoi_perturbation.py
plot_aoi_perturbations ¶
plot_aoi_perturbations(x: Any, *, perturbation_id: str | None = None, data: DataFrame | None = None, x_col: str | None = None, y_col: str | None = None, ax: Any = None)
Source code in src/eyeprocesspy/plots_aoi_perturbation.py
plot_aoi_robustness_surface ¶
plot_aoi_robustness_surface(x: Any, *, value_col: str = 'proportion_unchanged', x_col: str = 'margin_x', y_col: str = 'margin_y', ax: Any = None)
Source code in src/eyeprocesspy/plots_aoi_perturbation.py
_result ¶
run_aoi_sensitivity_analysis ¶
run_aoi_sensitivity_analysis(data: DataFrame, aois: DataFrame, grid: Any, *, x_col: str, y_col: str, observation_id_col: str | None = None, participant_col: str | None = None, trial_col: str | None = None, duration_col: str | None = None, time_col: str | None = None, observation_level: str = 'fixation', overlap_policy: str = 'ambiguous', model_callback: Callable[[DataFrame, DataFrame, Any], DataFrame] | None = None, preprocessing_specification: Any = None, event_detector: Any = None, quality_rules: Any = None, model_specification: Any = None) -> EyeResult
Run geometry perturbation, remapping, feature recomputation, and optional models.
Source code in src/eyeprocesspy/aoi_perturbation.py
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 | |
assess_aoi_inference_stability ¶
Source code in src/eyeprocesspy/aoi_perturbation.py
summarise_aoi_sensitivity ¶
Source code in src/eyeprocesspy/aoi_perturbation.py
report_aoi_sensitivity ¶
Return a compact manuscript-oriented Markdown report.
Source code in src/eyeprocesspy/aoi_perturbation.py
Core contract¶
Use aoi_perturbation_spec() for one validated branch or create_aoi_perturbation_grid() for a declared sensitivity set.
run_aoi_sensitivity_analysis() performs geometry perturbation → AOI remapping → feature recomputation → optional fixed model callback → assignment/model stability summaries while retaining failures and provenance.
See AOI perturbation and uncertainty analysis for design, interpretation, limitations, and reporting guidance.
Practical guidance¶
Use the AOI robustness decision clinic to interpret assignment/model stability patterns, the fixation-level worked example for end-to-end model propagation, and the sample-level worked example when geometry sensitivity is evaluated directly on gaze samples.
Failure handling¶
Use AOI perturbation troubleshooting for geometry failures, overlap ambiguity, zero-versus-missing denominators, callback exceptions, non-convergence, and model-N changes. The worked failure clinic executes these states on synthetic data.
Planning¶
Use the AOI sensitivity analysis plan before running branch-specific models. The worked filled plan maps each planning decision to the public API.
Evidence bundle¶
Use the AOI robustness reporting bundle to package the analysis plan, branch audit, assignment/model summaries, failures, provenance, report, and figures. The worked example provides a deterministic helper and SHA-256 manifest without adding a new public API.