Introducing a new way to review your PRs.

Read the announcement

insightsoftwareconsortium / itk

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.

View on GitHub

19 documents · Updated Nov 23, 2026

docs / pipeline-execution

Demand-driven pipeline execution

ITK runs data processing as a demand-driven pipeline. A downstream request for data travels upstream only as far as needed, then the pipeline returns the requested result while using modification times and regions to avoid work that is already current. This execution model connects ProcessObject data flow with image region data and the filtering framework.

Pipeline roles

The pipeline links ProcessObject instances to DataObject instances. A ProcessObject accepts named or indexed inputs and exposes outputs. Each output keeps a link to the process object that can generate it, so a downstream data request can reach its source without the downstream object knowing the full upstream path. The primary input and primary output are the default path that drives a process object.

Inputs and outputs define the data contract between neighboring process objects. Required inputs are checked before an update can proceed. A process object can have more than one input or output when a filter combines data or produces related results.

References: Modules/…/itkProcessObject.h• L47-91 Modules/…/itkDataObject.h• L133-168 Modules/…/itkDataObject.cxx• L202-217

Demand-driven updates

An update starts at the data object or process object that the application needs. Connecting objects and setting filter parameters does not generate bulk data. The first update performs only the work needed to make the requested output current, and a later update can reuse that result when neither the data nor the request requires new work.

The update follows three related passes. Information moves through the pipeline before bulk data is calculated. The pipeline then negotiates the needed region. It finally asks only the affected process objects to generate data.

This diagram shows how a request moves upstream and how the result is produced on the way back through the pipeline.

flowchart TD
    A[Downstream output request] --> B[Update output information]
    B --> C[Compare modification times]
    C --> D[Propagate requested region upstream]
    D --> E[Check buffered data]
    E -->|Missing or stale| F[Update upstream data]
    E -->|Current| G[Reuse buffered data]
    F --> H[Generate needed filter output]
    G --> I[Return current data]
    H --> I

Update() uses the output's current requested region. If no request exists, the first update uses the largest possible region. Use UpdateLargestPossibleRegion() when the goal is the complete output rather than the region from a prior request.

References: Modules/…/itkDataObject.h• L144-168 Modules/…/itkDataObject.h• L382-405 Modules/…/itkDataObject.cxx• L285-295 Modules/…/itkProcessObject.cxx• L1271-1277 Modules/…/itkProcessObject.cxx• L1801-1810 Modules/…/itkProcessObject.h• L357-391

Output information

Output information describes a result before its bulk values exist. It includes metadata such as image size, spacing, origin, and direction. The pipeline gathers the newest upstream state, then passes that information down so each process object can describe the data that it can produce.

The default process behavior copies information from the primary input to its outputs. Filters that change the data extent or its physical meaning must define the corresponding output information. This pass lets later region requests use valid output bounds.

References: Modules/…/itkProcessObject.h• L393-409 Modules/…/itkProcessObject.h• L854-865 Modules/…/itkProcessObject.cxx• L1354-1460 Modules/…/itkProcessObject.cxx• L1778-1798

Requested regions

A requested region is the part of a data object that the caller or downstream filter needs. Image data also tracks the largest possible region and the buffered region. The largest possible region is the full data extent. The buffered region is the part in memory. A valid request must fit inside the largest possible region, and the requested region must fit inside the buffered region before a current result can be reused.

Process objects translate the output request into input requests. A point-wise image filter can request the same region from its input. A neighborhood filter requests a larger input area so it can compute edge values without false boundaries. A filter can also enlarge its output request when it must produce more data than the caller asked for.

The three region roles form this relationship:

RegionMeaningEffect on execution
Largest possible regionFull extent that the data object can representDefines the valid request boundary
Buffered regionExtent currently available in memoryDetermines whether existing data can satisfy a request
Requested regionExtent needed for the current updateDrives upstream requests and generated output

The region negotiation moves from the downstream output toward upstream inputs. It can stop a filter from running when its buffer already covers the request. An invalid request raises an InvalidRequestedRegionError instead of producing an incomplete result.

References: Modules/…/itkDataObject.h• L170-205 Modules/…/itkDataObject.h• L465-500 Modules/…/itkImageBase.h• L264-328 Modules/…/itkDataObject.cxx• L323-347 Modules/…/itkProcessObject.h• L420-431 Modules/…/itkProcessObject.h• L836-864 Modules/…/itkProcessObject.cxx• L1464-1533

Modified times

Modified times provide the change signal for lazy execution. A TimeStamp is a monotonically increasing value recorded when an object changes. A data object also stores the time of its last generated result and a pipeline time that represents the newest relevant state upstream.

During the information pass, each process object combines its own modification time with the modification state of its inputs. During the data pass, a source is asked to regenerate data when the stored update time is older than that pipeline time. The same check also accounts for released data and for a request outside the current buffer.

Generating data marks each output as current and records a new update time. Releasing the bulk data does not mark the data object as modified. It only causes a later request to regenerate the missing buffer when needed.

References: Modules/…/itkTimeStamp.h• L38-55 Modules/…/itkDataObject.h• L421-463 Modules/…/itkDataObject.cxx• L327-365 Modules/…/itkDataObject.cxx• L368-381 Modules/…/itkProcessObject.cxx• L1379-1460

Update propagation

Update propagation lets a downstream need control upstream work. The output first ensures that its source has current information. The source then maps the output request to its other outputs and inputs. Only after that negotiation does the source update the input data and generate its own output.

For image filters, the usual contract is that input and output regions correspond. Filters with a different dependency must change the request mapping. Multiple inputs are checked for compatible image space by default so that one requested index has the same physical meaning across inputs.

When a pipeline update fails or is aborted, its internal update state can remain incomplete. Calling ResetPipeline() clears that state through the connected inputs so a later update can start again.

References: Modules/…/itkDataObject.h• L323-325 Modules/…/itkDataObject.h• L382-419 Modules/…/itkImageToImageFilter.h• L56-75 Modules/…/itkProcessObject.h• L411-440 Modules/…/itkProcessObject.cxx• L1616-1738 Modules/…/itkProcessObject.cxx• L1280-1316

Streaming execution

Streaming processes a large requested result as several smaller input regions. A StreamingProcessObject selects the number of input regions, sets each region in turn, updates the upstream pipeline for that region, and combines the pieces into the final output. This lowers the amount of data that must be held and processed at one time.

StreamingImageFilter is the image-specific form of this process. It produces one complete output image while upstream filters process smaller pieces. The requested number of divisions is user-controlled, but the region splitter can reduce it when the requested region has fewer valid pieces.

Streaming changes the timing of region propagation. The streaming process manages the per-piece requests during generation, then invokes its piece-processing step for each region. A filter that cannot split its input can use one region instead. The current request number identifies the piece being processed while streaming is active.

This diagram shows the repeated upstream update that makes streaming different from one full-region update.

sequenceDiagram
    participant D as Downstream request
    participant S as Streaming process
    participant U as Upstream pipeline
    D->>S: Request output region
    S->>S: Divide request into pieces
    loop Each piece
        S->>U: Set input requested region
        U-->>S: Produce current piece
        S->>S: Process piece into output
    end
    S-->>D: Complete requested output

References: Modules/…/itkStreamingProcessObject.h• L26-35 Modules/…/itkStreamingProcessObject.h• L54-116 Modules/…/itkStreamingProcessObject.cxx• L25-105 Modules/…/itkStreamingProcessObject.cxx• L224-260 Modules/…/itkStreamingImageFilter.h• L26-37 Modules/…/itkStreamingImageFilter.h• L81-107 Modules/…/itkStreamingImageFilter.hxx• L148-178

Multithreaded filter execution

Multithreading divides one requested image region into independent work units inside a filter. It is separate from streaming: streaming divides the pipeline request into successive pieces, while multithreading works on parts of the current piece at the same time.

ImageSource supplies the common execution pattern for threaded image filters. It allocates the output, prepares optional before-work state, sends non-overlapping regions to worker work units, and runs optional after-work state. A threaded filter must write only its assigned region. A filter that cannot use this pattern provides a single generation path instead.

The process object controls the requested number of work units through its selected multithreader. That threader may clamp the accepted count to its limit. A thread ratio sets the count immediately, but the ratio is not retained for later threader changes. Each work unit must be safe to run with the others. Progress can be reported by the threader or by the filter, and an abort request stops generation through the process object's abort state.

References: Modules/…/itkProcessObject.h• L295-355 Modules/…/itkProcessObject.h• L501-528 Modules/…/itkImageSource.h• L235-247 Modules/…/itkImageSource.h• L259-305 Modules/…/itkMultiThreaderBase.h• L90-98 Modules/…/itkMultiThreaderBase.h• L125-143

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to output information must preserve the largest possible region used by downstream request checks.
  • Changes to a filter's input dependency must keep output-to-input region mapping valid for both full and partial requests.
  • Changes to streaming piece selection must preserve the order of request setup, upstream update, and piece generation.
  • Changes to threaded region splitting must keep work units non-overlapping and restrict each worker to its assigned output region.
  • Changes to modification or update times must keep stale data distinguishable from released data and from data that already covers the request.
  • Changes to abort or exception paths must leave the pipeline resettable before the next update.

Important failure modes

TriggerConsequenceGuard
A required input is not setThe update stops before upstream executionConfigure all required inputs before requesting output data
A requested region lies outside the largest possible regionThe pipeline raises InvalidRequestedRegionErrorKeep requests within the advertised output extent
A filter requests too little input for its dependencyBoundary or neighborhood results can be wrongMap each output region to the full input support that the filter needs
A filter writes outside its worker regionConcurrent execution can corrupt output dataKeep threaded work units non-overlapping and region-local
An update throws or is abortedPipeline update state can block a later updateCall ResetPipeline() before retrying
A stale or released buffer is treated as currentDownstream code can read missing or old dataUse the update-time and buffered-region checks before reuse

Key files

FileWhy to read it
Modules/…/itkProcessObject.hDefines the process object contract for inputs, outputs, updates, regions, and work units
Modules/…/itkDataObject.hDefines source links, update state, region checks, and generated-data state
Modules/Core/Common/src/itkProcessObject.cxxShows the high-level information, request, and data propagation sequence
Modules/Core/Common/src/itkDataObject.cxxShows when a data object forwards a request or reuses its current buffer
Modules/…/itkStreamingProcessObject.hDefines the contract for piece-by-piece pipeline execution
Modules/Core/Common/src/itkStreamingProcessObject.cxxShows the streaming lifecycle and per-piece upstream updates
Modules/…/itkStreamingImageFilter.hDescribes image streaming as one complete output assembled from upstream pieces
Modules/…/itkImageSource.hDescribes the shared threaded image generation model
Modules/…/itkMultiThreaderBase.hDefines work-unit and region-parallel execution controls