coord2region.pipeline#

High-level analysis pipeline for Coord2Region.

This module exposes a single convenience function run_pipeline() which coordinates the existing building blocks in the package to provide an end-to-end workflow. Users can submit coordinates or region names and request different types of outputs such as atlas labels, textual summaries, generated images and the raw study metadata.

The implementation builds directly on the lower-level modules in the package. Atlas lookups are performed via coord2region.coord2region, studies are retrieved using coord2region.coord2study, and text or image generation is handled through coord2region.llm.

The function also supports exporting the produced results to a variety of formats.

Classes#

PipelineResult

Structured container returned by run_pipeline().

Functions#

run_pipeline(→ list[PipelineResult])

Run the Coord2Region analysis pipeline.

Module Contents#

class coord2region.pipeline.PipelineResult[source]#

Structured container returned by run_pipeline().

Parameters:
  • coordinate (Optional[List[float]]) – Coordinate associated with this result (if available).

  • mni_coordinates (Optional[List[float]]) – Representative MNI coordinate resolved from region name inputs when requested via outputs.

  • region_labels (Dict[str, str]) – Atlas region labels keyed by atlas name.

  • summaries (Dict[str, str]) – Mapping of language-model identifiers to their generated summaries.

  • summary (Optional[str]) – Primary summary (first entry in summaries) kept for backward compatibility.

  • studies (List[Dict[str, Any]]) – Raw study metadata dictionaries.

  • image (Optional[str]) – Primary image path (first generated), kept for backward compatibility.

  • images (Dict[str, str]) – Mapping of image backend names to generated image paths.

  • warnings (List[str]) – Non-fatal issues encountered while processing the input item.

coordinate: list[float] | None = None[source]#
mni_coordinates: list[float] | None = None[source]#
region_labels: dict[str, str][source]#
summaries: dict[str, str][source]#
summary: str | None = None[source]#
studies: list[dict[str, Any]] = [][source]#
image: str | None = None[source]#
images: dict[str, str][source]#
warnings: list[str] = [][source]#
coord2region.pipeline.run_pipeline(inputs: Sequence[Any], input_type: str, outputs: Sequence[str], output_format: str | None = None, output_name: str | None = None, image_backend: str = 'ai', *, config: dict[str, Any] | None = None, async_mode: bool = False, progress_callback: Callable[[int, int, PipelineResult], None] | None = None) list[PipelineResult][source]#

Run the Coord2Region analysis pipeline.

Parameters:
  • inputs (sequence) – Iterable containing the inputs. The interpretation depends on input_type.

  • input_type ({"coords", "region_names"}) – Specifies how to treat inputs.

  • outputs (sequence of) – {“region_labels”, “summaries”, “images”, “raw_studies”, “mni_coordinates”} Requested pieces of information for each input item. The "mni_coordinates" option is only supported when input_type == "region_names".

  • output_format ({"json", "pickle", "csv", "pdf", "directory"}, optional) – When provided, results are exported to the specified format.

  • output_name (str, optional) – File or directory name to use when exporting results. The name is created inside the working directory’s results subfolder. Required when output_format is specified.

  • image_backend ({"ai", "nilearn", "both"}, optional) – Backend used to generate images when "images" is requested.

  • prompt_template (str, optional) – Template to use for AI image generation prompts. One of: ” ‘anatomical’, ‘functional’, ‘schematic’, ‘artistic’, or ‘custom’.

  • async_mode (bool, optional) – When True, processing occurs concurrently using asyncio and summaries are generated with generate_summary_async().

  • progress_callback (callable, optional) – Function invoked after each input is processed. Receives the number of completed items, the total count and the PipelineResult for the processed item. When None, progress is logged via logging.

Returns:

One result object per item in inputs.

Return type:

list of PipelineResult