spacr.qt.widgets.annotation_strategy_panel

Annotation-strategy controls and reports for the Cells montage.

The panel selects from the object rows, guide wells, and score column shown in the montage. Strategy execution runs in a worker thread, while selection, hold-out construction, model fitting, and reporting are implemented by spacr.regression_annotation.

Classes

AnnotationStrategyPanel

Configure and run cell-annotation strategies from a montage.

Functions

wells_of_plans(→ Tuple[str, ...])

Return unique guide wells referenced by montage plans.

Module Contents

class spacr.qt.widgets.annotation_strategy_panel.AnnotationStrategyPanel(objects_provider: Callable[[], Any] | None = None, wells_provider: Callable[[], Sequence[str]] | None = None, score_provider: Callable[[], str] | None = None, folder_provider: Callable[[], str] | None = None, parent: PySide6.QtWidgets.QWidget | None = None, *, threaded: bool = True)[source]

Bases: PySide6.QtWidgets.QWidget

Configure and run cell-annotation strategies from a montage.

Parameters:
  • objects_provider – Callable returning candidate object rows, or None before montage data are available.

  • wells_provider – Callable returning selected guide wells.

  • score_provider – Callable returning the per-object score column.

  • folder_provider – Callable returning the default output directory.

  • parent – Parent widget.

  • threaded – Run computation in a worker thread. Inline execution is intended for deterministic testing only.

Variables:

finished – Emitted with the strategy key after a successful run.

Build the panel that proposes which objects to annotate next.

Every input arrives through a provider rather than being passed in: the panel is built before the run it describes exists, and asking at use time is what lets it follow a screen whose table has since changed.

Parameters:
  • objects_provider – called for the object table.

  • wells_provider – called for the wells in play.

  • score_provider – called for the score column to rank on.

  • folder_provider – called for the run folder to write into.

  • parent – parent widget, or None.

  • threaded – propose on a worker thread. Set False in tests so a proposal finishes before it returns.

about_text() → str[source]

Return the current strategy description.

closeEvent(event)[source]

Stop active work when the panel closes.

Parameters:

event – the close event, passed on to the base class after the strategy worker is shut down.

reason() → str[source]

Return the reason the selected strategy cannot run, or ''.

The check uses the loaded rows and current controls, so unsupported data are identified when the strategy is selected rather than after a model fit has started.

refresh() → None[source]

Refresh guide wells and control state from the current montage.

report_text() → str[source]

Return the text displayed in the report pane.

request()[source]

Build an annotation request, or return None without cells.

result()[source]

Return the latest annotation result, or None.

run() → bool[source]

Run the selected strategy in the configured job runner.

Returns:

True if execution was submitted; otherwise False.

save(folder: str | None = None) → Dict[str, str][source]

Write selected cells, hold-out data, predictions, and the report.

Parameters:

folder – Output directory. If omitted, a directory chooser is displayed.

Returns:

Mapping from output type to path, or an empty mapping if no files were written.

set_strategy(key: str) → bool[source]

Select a strategy by key and report whether it was available.

Parameters:

key – key of a strategy in spacr.regression_annotation.STRATEGIES, matched as a string against the menu entries. An unknown key leaves the selection unchanged and returns False.

shutdown() → None[source]

Stop the strategy worker before destroying the widget.

strategy_key() → str[source]

Return the key of the currently selected strategy.

spacr.qt.widgets.annotation_strategy_panel.wells_of_plans(plans: Sequence[Any]) → Tuple[str, ...][source]

Return unique guide wells referenced by montage plans.

Parameters:

plans – Montage plans in display order.

Returns:

Well identifiers in first-occurrence order.

Nested helpers

AnnotationStrategyPanel.run.work()

Run the annotation strategy. Off the GUI thread.

spacr/qt/widgets/annotation_strategy_panel.py:608