canns.pipeline.asa_gui.core.state

State management for ASA GUI.

This module provides centralized workflow state management with Qt signals for reactive UI updates. All file paths are stored relative to the working directory for portability.

Classes

StateManager

Reactive state manager with Qt signals.

WorkflowState

Centralized state for ASA analysis workflow.

Functions

relative_path(state, path)

Convert absolute path to workdir-relative path.

resolve_path(state, path)

Convert relative path to absolute path.

validate_files(state)

Check if required files exist and are valid.

validate_preprocessing(state)

Check if preprocessing is complete.

Module Contents

class canns.pipeline.asa_gui.core.state.StateManager(parent=None)[source]

Bases: PySide6.QtCore.QObject

Reactive state manager with Qt signals.

Emits signals when state changes to enable reactive UI updates. Supports undo/redo through state history.

batch_update(**kwargs)[source]

Update multiple fields without emitting individual signals.

Emits state_replaced at the end.

can_redo()[source]

Check if redo is available.

can_undo()[source]

Check if undo is available.

push_history()[source]

Save current state for undo.

redo()[source]

Restore next state.

Returns:

True if redo was successful

Return type:

bool

reset()[source]

Reset state to defaults.

undo()[source]

Restore previous state.

Returns:

True if undo was successful

Return type:

bool

update(**kwargs)[source]

Update state fields and emit signals.

Parameters:

**kwargs (Any) – Field names and their new values

property state: WorkflowState[source]

Get current workflow state.

state_changed[source]
state_replaced[source]
class canns.pipeline.asa_gui.core.state.WorkflowState[source]

Centralized state for ASA analysis workflow.

All file paths are relative to workdir for portability.

copy()[source]

Create a shallow copy of the state (excluding large arrays).

aligned_pos: dict[str, numpy.typing.NDArray[numpy.floating]] | None = None[source]
analysis_mode: str = 'tda'[source]
analysis_params: dict[str, Any][source]
artifacts: dict[str, pathlib.Path][source]
asa_file: pathlib.Path | None = None[source]
current_stage: str = ''[source]
embed_data: numpy.typing.NDArray[numpy.floating] | None = None[source]
input_mode: str = 'asa'[source]
is_running: bool = False[source]
neuron_file: pathlib.Path | None = None[source]
preclass: str = 'none'[source]
preclass_params: dict[str, Any][source]
preprocess_method: str = 'none'[source]
preprocess_params: dict[str, Any][source]
preset: str = 'grid'[source]
progress: int = 0[source]
traj_file: pathlib.Path | None = None[source]
workdir: pathlib.Path[source]
canns.pipeline.asa_gui.core.state.relative_path(state, path)[source]

Convert absolute path to workdir-relative path.

Parameters:
Returns:

Path relative to workdir

Return type:

pathlib.Path

canns.pipeline.asa_gui.core.state.resolve_path(state, path)[source]

Convert relative path to absolute path.

Parameters:
Returns:

Absolute path or None if path is None

Return type:

pathlib.Path | None

canns.pipeline.asa_gui.core.state.validate_files(state)[source]

Check if required files exist and are valid.

Parameters:

state (WorkflowState) – Current workflow state

Returns:

Tuple of (is_valid, error_message)

Return type:

tuple[bool, str]

canns.pipeline.asa_gui.core.state.validate_preprocessing(state)[source]

Check if preprocessing is complete.

Parameters:

state (WorkflowState) – Current workflow state

Returns:

Tuple of (is_valid, error_message)

Return type:

tuple[bool, str]