Architecture¶
Purpose¶
This page explains where the major runtime responsibilities live so maintainers can find the right layer quickly.
Main Layers¶
| Layer | Directory | Responsibility |
|---|---|---|
| public entry points | autoflow/ |
CLI, GUI launcher, public Python API |
| pipeline orchestration | autoflow/core |
workspace state and step orchestration |
| algorithms | autoflow/algorithms |
loading, preprocessing, graph, planes, metrics, segmentation, streamlines |
| GUI | autoflow/ui |
PySide6 window, docks, viewers, dialogs, and editors; pyqtgraph owns interactive orthogonal slices |
| rendering | autoflow/rendering |
offline video export |
| reporting and portable geometry | autoflow/quality.py, autoflow/plane_io.py, autoflow/reporting.py |
staged QC, cross-case plane coordinates, and human-readable summaries |
| tests | tests |
behavior coverage |
| configuration | configs, autoflow/config.py |
per-module JSON defaults and loading |
Primary Execution Paths¶
CLI batch path¶
autoflow/cli.pyparses flagsautoflow/api.pybuildsAutoFlowConfigautoflow/processing.py:process_single()runs the batch orderautoflow/core/pipeline.pyexecutes concrete steps
GUI path¶
autoflow/ui/launcher.pystarts the appautoflow/ui/app.pymanages the main window and UI stateautoflow/core/pipeline.pyruns steps against the workspaceautoflow/ui/viewer.pyrenders 3D state through the local Qt VTK widget or the forwarded-X11 EGL adapter inautoflow/ui/remote_plotter.py;autoflow/ui/ortho_viewer.pyandautoflow/ui/slice_view.pyrender interactive 2D stateautoflow/ui/app.pyexports Labeler exchange features, launches the optional SpatioTemporal Labeler process, and imports a saved label sequence after the process exits
Python API path¶
autoflow/api.pyexposesAutoFlowConfig,run_case(),run_batch(), andbuild_workspace()- config defaults come from
autoflow/config.py - execution still flows through
autoflow/processing.pyandautoflow/core/pipeline.py
Core Data Flow¶
- loader returns
LoadedCase - workspace stores normalized source arrays and metadata
- segmentation availability controls downstream step eligibility
- skeleton feeds graph and paths
- graph and paths feed planes
- planes feed metrics
- segmentation and flow feed derived metrics
- rendering consumes planes, metrics, and derived arrays
- quality reporting inspects the current workspace without mutating algorithm results
Temporal segmentation path¶
autoflow/algorithms/segmentation.py:generate_nnunet_4d_auto_segmentation()
constructs one nnUNet sample per cardiac frame from the Dataset7020 temporal
channels, invokes the checkpoint once, and restores an XYZT label volume.
auto_folds=single selects one checkpoint; all passes every available fold
to nnUNet's ensemble predictor. Topology preprocessing uses a 3D majority
vote, while Workspace.segmask_binary remains temporal for phase-wise metrics.
Design Constraints To Keep¶
LoadedCasenormalization is the contract between loaders and the rest of the system- downstream arrays use spatial and vector-component order
LR/AP/FH; source-order metadata is audit information, while 3D and 2D viewers must label the normalized array order - workspace centerlines and planes use local physical millimetres; array lookup divides by spacing without subtracting origin, while VTK/world export adds origin exactly once
- TKE stays optional
- segmentation is an interface with multiple valid sources
- external segmentation edits must be imported through the existing segmentation-source invalidation path
- GUI and CLI share pipeline logic as much as possible
Derived Artifact Cache¶
DerivedResults.artifact_signatures owns independent wss, tke, and pressure signatures. PipelineEngine._ensure_derived_metrics() must compare the current signature before reusing any derived array. New parameters or algorithm changes must be added to the affected signature payload and its algorithm-version token. Do not use array presence alone as cache validity.
Plane metrics cache thresholded support geometry per unique mask phase and slice specifications per plane and representative phase. WSS caches the extracted and smoothed base surface per unique mask phase, then copies that geometry before attaching phase-specific arrays. Geometry caches must never share mutable phase-specific scalar data.
Long-running compute-oriented GUI pipeline steps are dispatched by _PipelineTaskWorker in autoflow/ui/app.py. The worker mutates the active workspace while a window-modal progress dialog prevents competing user actions; scene cache invalidation and VTK actor refresh happen on the GUI thread after completion. Interactive editors and live streamline/pathline actions are deliberately excluded from this worker path.