Analysis core¶
These core types appear in velocity, diameter, and batch analysis signatures. They are included here so generated API pages can explain the objects passed into and returned from analysis code.
Bases: ABC
Base class for one ROI/channel analysis instance.
Derived classes define a stable analysis_name, optional
detection_schema, and a concrete :meth:run method. The base class owns
analysis identity, validated detection parameters, dirty state,
serialization helpers, and common table utilities.
Detection parameters describe scientific behavior and are serialized with the analysis. Runtime execution options, such as multiprocessing worker counts, should live on derived classes and should not be serialized unless they change scientific results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
Zero-based channel index for this analysis. |
required |
roi_id
|
int
|
ROI identifier for this analysis. |
required |
detection_params
|
dict[str, Any] | None
|
Optional detection parameter values. Missing values
are filled from |
None
|
Source code in src/acqstore/acq_image/analysis/model.py
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 | |
is_dirty ¶
is_dirty() -> bool
Return whether this analysis has unsaved changes.
Returns:
| Type | Description |
|---|---|
bool
|
True if this analysis has unsaved changes. |
Source code in src/acqstore/acq_image/analysis/model.py
302 303 304 305 306 307 308 | |
set_dirty ¶
set_dirty() -> None
Mark this analysis dirty.
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/acqstore/acq_image/analysis/model.py
310 311 312 313 314 315 316 | |
set_clean ¶
set_clean() -> None
Mark this analysis clean.
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/acqstore/acq_image/analysis/model.py
318 319 320 321 322 323 324 | |
get_detection_schema
classmethod
¶
get_detection_schema() -> tuple[DetectionParamSchema, ...]
Return detection parameter schema.
Returns:
| Type | Description |
|---|---|
tuple[DetectionParamSchema, ...]
|
Tuple of |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the class |
Source code in src/acqstore/acq_image/analysis/model.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
get_detection_schema_dataframe
classmethod
¶
get_detection_schema_dataframe() -> pd.DataFrame
Return this analysis type's detection-parameter schema as a DataFrame.
This is a scripting and documentation convenience that describes the
full detection-parameter schema. It is available on every analysis type
(for example RadonVelocityAnalysis, DiameterAnalysis,
EventAnalysis, HeartRateAnalysis).
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame indexed by parameter |
DataFrame
|
parameter. Columns are |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
analysis declares no detection parameters. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the class |
Source code in src/acqstore/acq_image/analysis/model.py
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 | |
get_default_detection_params
classmethod
¶
get_default_detection_params() -> dict[str, Any]
Return default detection parameters from detection_schema.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Mapping from parameter name to default value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the schema contains duplicate parameter names. |
Source code in src/acqstore/acq_image/analysis/model.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
validate_detection_params
classmethod
¶
validate_detection_params(params: dict[str, Any]) -> None
Validate detection parameter mapping against schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict[str, Any]
|
Detection parameter mapping. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If any key is not present in the schema. |
TypeError
|
If any value has the wrong type. |
ValueError
|
If any enum value is not in |
Source code in src/acqstore/acq_image/analysis/model.py
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 | |
run
abstractmethod
¶
run(
data_provider: AnalysisDataProvider,
*,
context: AnalysisRunContext | None = None,
dependencies: dict[str, BaseAnalysis] | None = None,
) -> AnalysisResult
Run analysis using a narrow data-provider API.
Derived implementations should read pixels and physical units only
through data_provider. They should use context for progress and
cancellation, respect dependency analyses when declared, store results in
self.result, and call self.set_dirty() after mutating results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_provider
|
AnalysisDataProvider
|
Minimal image/header access provider. |
required |
context
|
AnalysisRunContext | None
|
Optional runtime context for progress and cancellation. |
None
|
dependencies
|
dict[str, BaseAnalysis] | None
|
Dependency analyses keyed by analysis name. |
None
|
Returns:
| Type | Description |
|---|---|
AnalysisResult
|
Analysis result. Implementations usually return |
Source code in src/acqstore/acq_image/analysis/model.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
get_plot_data ¶
get_plot_data() -> AnalysisPlotData | None
Return display-ready plot data for this analysis.
Derived analyses override this when they have a canonical x/y plot.
Returns:
| Type | Description |
|---|---|
AnalysisPlotData | None
|
Plot data, or None when the analysis has no canonical plot. |
Source code in src/acqstore/acq_image/analysis/model.py
488 489 490 491 492 493 494 495 496 | |
get_overlay_traces ¶
get_overlay_traces() -> tuple[
AnalysisOverlayTraceData, ...
]
Return ROI-local trace overlays for raster viewers.
Derived analyses override this when they expose edge or path overlays. Coordinates are ROI-local physical units; GUI layers translate to full-image Plotly coordinates.
Returns:
| Type | Description |
|---|---|
tuple[AnalysisOverlayTraceData, ...]
|
Tuple of overlay trace data. Empty when no overlays exist. |
Source code in src/acqstore/acq_image/analysis/model.py
498 499 500 501 502 503 504 505 506 507 508 | |
has_table ¶
has_table() -> bool
Return whether this analysis has table output.
Returns:
| Type | Description |
|---|---|
bool
|
True if result table exists. |
Source code in src/acqstore/acq_image/analysis/model.py
510 511 512 513 514 515 516 | |
get_table_columns ¶
get_table_columns() -> list[str]
Return result table column names.
Returns:
| Type | Description |
|---|---|
list[str]
|
Column names, or an empty list when no table exists. |
Source code in src/acqstore/acq_image/analysis/model.py
518 519 520 521 522 523 524 525 526 | |
get_column ¶
get_column(name: str) -> list[Any]
Return one result table column as a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Column name. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
Column values as a list. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this analysis has no table. |
KeyError
|
If the column does not exist. |
Source code in src/acqstore/acq_image/analysis/model.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
table_with_bookkeeping ¶
table_with_bookkeeping() -> pd.DataFrame | None
Return table with channel and ROI bookkeeping columns.
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
DataFrame with |
DataFrame | None
|
the analysis has no table output. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If result table already contains reserved bookkeeping columns. |
Source code in src/acqstore/acq_image/analysis/model.py
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 | |
to_json_dict ¶
to_json_dict() -> dict[str, Any]
Return JSON-serializable analysis record.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing identity, detection params, and summary. |
Source code in src/acqstore/acq_image/analysis/model.py
573 574 575 576 577 578 579 580 581 582 583 584 585 | |
load_json_dict ¶
load_json_dict(record: dict[str, Any]) -> None
Load detection params and summary from a JSON record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
dict[str, Any]
|
Analysis record from source sidecar JSON. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/acqstore/acq_image/analysis/model.py
587 588 589 590 591 592 593 594 595 596 597 | |
save_record_json ¶
save_record_json(path: str | Path) -> None
Save this analysis record to a standalone JSON file.
This helper is useful in tests. Normal AcqImage save code should use
AcqAnalysisSet.serialize_json_analysis() and merge records into the
source sidecar JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Output JSON file path. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/acqstore/acq_image/analysis/model.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
load_record_json ¶
load_record_json(path: str | Path) -> None
Load this analysis record from a standalone JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Input JSON file path. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/acqstore/acq_image/analysis/model.py
614 615 616 617 618 619 620 621 622 623 | |
Bases: Protocol
Minimal data access surface needed by analyses.
Analysis implementations use this protocol instead of reaching into
AcqImage internals. The contract is intentionally small: ROI-local image
data and image physical spacing. This keeps analysis code reusable from GUI,
batch, test, and notebook workflows.
Source code in src/acqstore/acq_image/analysis/data_provider.py
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 | |
get_roi_image ¶
get_roi_image(channel: int, roi_id: int) -> np.ndarray
Return image data for one channel cropped to one ROI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
Channel index. |
required |
roi_id
|
int
|
ROI identifier. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Two-dimensional ROI image data. |
Source code in src/acqstore/acq_image/analysis/data_provider.py
28 29 30 31 32 33 34 35 36 37 38 | |
get_image_physical_units ¶
get_image_physical_units() -> tuple[float, float]
Return physical units for the 2D image plane.
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Per-pixel |
Source code in src/acqstore/acq_image/analysis/data_provider.py
40 41 42 43 44 45 46 | |
Runtime context for progress reporting and cooperative cancellation.
Analysis code receives this object from GUI controllers, batch runners, or
scripts. Derived analyses should call :meth:report_progress at natural
milestones and :meth:raise_if_cancelled or :meth:is_cancelled inside
long loops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress_callback
|
Callable[[float | None, str], None] | None
|
Optional callback receiving |
None
|
cancel_callback
|
Callable[[], bool] | None
|
Optional callback returning |
None
|
Source code in src/acqstore/acq_image/analysis/model.py
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 | |
report_progress ¶
report_progress(
fraction: float | None, message: str = ''
) -> None
Report progress for a running analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float | None
|
Fraction complete, or None if unknown. |
required |
message
|
str
|
Human-readable progress message. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/acqstore/acq_image/analysis/model.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
is_cancelled ¶
is_cancelled() -> bool
Return whether cancellation has been requested.
Returns:
| Type | Description |
|---|---|
bool
|
True if cancellation has been requested. |
Source code in src/acqstore/acq_image/analysis/model.py
186 187 188 189 190 191 192 | |
raise_if_cancelled ¶
raise_if_cancelled() -> None
Raise if cancellation has been requested.
Raises:
| Type | Description |
|---|---|
AnalysisCancelled
|
If cancellation has been requested. |
Source code in src/acqstore/acq_image/analysis/model.py
194 195 196 197 198 199 200 201 | |
Outputs from one completed or loaded analysis.
summary stores small JSON-serializable values that belong in an
acquisition sidecar. table stores larger per-row results that can be
saved to CSV and inspected in notebooks or GUI tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary
|
dict[str, Any]
|
Small JSON-serializable result dictionary. |
dict()
|
table
|
DataFrame | None
|
Optional large tabular output. Tables produced by derived
analyses must not include reserved bookkeeping columns |
None
|
Source code in src/acqstore/acq_image/analysis/model.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |