Channels and multiple inputs

A multi-input operation must state which images it reads and how far it reads in each. This is more than naming files: the declarations let Blockflow create dependencies, keep producer images alive and account for simultaneous buffers. Reading another image secretly from a path inside a kernel bypasses all three.

Attachment order and image identities

The first attachment is the run’s initial image zero. Extra attachments use ImageId::supplied(0), ImageId::supplied(1) and so on. Thus the second array in an attachment list is supplied image zero, not phase-written image one:

Array in attachment list Meaning in a plan
First Initial image 0
Second ImageId::supplied(0)
Third ImageId::supplied(1)
Result of phase zero The handle returned by that phase’s Phase::image

The supplied identity range is separate from phase outputs. This prevents adding another external channel from renumbering every internal result. A caller can name an external channel before it knows how many phases a partitioned plan will contain.

let a = OmeVolumePyramid::open(root, 0, time)?.attached_level(level)?;
let b = OmeVolumePyramid::open(root, 1, time)?.attached_level(level)?;
let environment = ZarrEnvironment::attach(work, &[a, b])?;

This is a selection sketch using the paths/imports from OME-Zarr input. Select the same intended time and level for each channel; equal array dimensions alone do not establish registration.

Replace the primary input or add an operand

Chain::source(image, dtype) starts a branch from a selected image. Use it when the subsequent chain should process that image instead of the phase’s ordinary input. The dtype is explicit because an external image has no producing chain from which the planner can infer its type.

An operation’s SourceInput declarations add operands while preserving its primary input. A pointwise mask or background map can use SourceInput::voxelwise(image). A fitted spot that reads raw pixels around a candidate needs a source declaration with the fitting window’s reach instead. The primary response image and raw-source image can therefore require different neighborhoods.

For a supplied operand, use SourceInput::holding to state the dtype. For an image produced within the plan, its type can be derived and a stated type is checked against that derived value. This catches a label/intensity mixup before a worker decodes a block.

flowchart TB
  A["Response image: candidate neighborhood"] --> K["Fitting operation"]
  B["Raw intensity: fitting window"] --> K
  C["Validity image: declared source"] --> K
  K --> O["Result and diagnostics"]
Figure 1: Each source has its own dependency: raw fitting pixels need a neighborhood, while a co-located validity map may be pointwise.

Several outputs at one voxel

mixing::TupleOp applies a kernel to co-located arrays and can produce side outputs. Camera correction, for example, can produce a corrected intensity and a validity value. NNLS unmixing can produce several component values plus a residual and convergence diagnostics. These outputs share one per-voxel solve; repeating the solve independently for each output would waste computation and could complicate consistent failure handling.

This tuple arity is separate from spatial reach. Many inputs can still be pointwise; one input can require a very large neighborhood. Account for both the number of resident operands and the spatial extent of each.

Physical compatibility remains explicit

Ordinary co-located operands must satisfy the plan’s shape and lattice contracts. They also need compatible physical registration for the calculation to be meaningful. Check axis order, origin, spacing, units and channel/time selection at the application boundary. A source with a 0.5-pixel translation cannot be repaired by choosing the same compute blocks.

Different resolutions require explicit resampling, separate runs with a small calibration passed between them, or a transform-aware sampling route. Do not pretend the same integer voxel index names the same physical point in both images. See registration and geometry for examples that make these coordinate maps visible.