Skip to main content

Find region name for a given MNI coordinate in a selected atlas

Project description

Coord2Region

Codecov Tests Documentation Status Preprint License: BSD-3-Clause Ask DeepWiki

Coord2Region logo

Coord2Region maps brain coordinates (or atlas region names) to anatomical labels, nearby studies, LLM summaries, and optional AI-generated images. It combines NiMARE, Nilearn, and MNE under a single CLI/Python API and ships with a companion web interface for configuration authoring.

Why Coord2Region?

  • Atlas + studies in one stop. Fetch atlases, convert MNI ↔ Talairach, and query datasets such as Neurosynth, NeuroQuery, and NiMARE without wiring them up yourself.
  • Optional AI enrichments. Provide API keys once (OpenAI, Gemini, Hugging Face, etc.) and the same workflow can emit human-friendly summaries or illustrative images.
  • Reproducible outputs. Every command can emit YAML, JSON, and CSV artefacts so collaborators can re-run the exact pipeline.
  • Browser builder. The React/Vite builder mirrors the CLI schema so first-time users can generate configs and commands without installing Python up front.

Quick Start

  1. Install the package (Python 3.10+):

    python -m venv .venv
    source .venv/bin/activate
    pip install coord2region
    
  2. Configure credentials and defaults. Run the helper once to create a private config/coord2region-config.yaml. It covers atlas fetch directories as well as AI provider API keys (all optional).

    python scripts/configure_coord2region.py
    

    Prefer environment variables? Set OPENAI_API_KEY, GEMINI_API_KEY, HUGGINGFACE_API_KEY, etc. instead of generating the YAML.

  3. Run a CLI recipe.

    # Atlas labels only
    coord2region coords-to-atlas 30 -22 50 --atlas harvard-oxford
    
    # Labels + studies + LLM summary (requires API key)
    coord2region coords-to-summary 30 -22 50 --atlas harvard-oxford --model gemini-2.0-flash
    
    # Region name workflow
    coord2region region-to-insights "Left Amygdala" --atlas harvard-oxford
    
  4. Explore the builder. Visit the Config Builder to generate YAML/CLI commands interactively. Import/export configs to stay in sync with local runs.

  5. Jump into Python (optional).

    from coord2region import AtlasFetcher, AtlasMapper, AIModelInterface, generate_summary
    
    atlas = AtlasFetcher().fetch_atlas("harvard-oxford")
    mapper = AtlasMapper("harvard-oxford", atlas["vol"], atlas["hdr"], atlas["labels"])
    print(mapper.mni_to_region_name([30, -22, 50]))
    
    ai = AIModelInterface(huggingface_api_key="YOUR_KEY")
    studies = []  # populate via coord2region.coord2study helpers
    print(generate_summary(ai, studies, [30, -22, 50]))
    

CLI recipes at a glance

Goal Command
Labels only coord2region coords-to-atlas 30 -22 50 --atlas harvard-oxford
Labels + studies coord2region coords-to-study 30 -22 50 --atlas harvard-oxford --radius-mm 10
Labels + studies + summaries coord2region coords-to-summary 30 -22 50 --atlas harvard-oxford --model gemini-2.0-flash
Add nilearn anatomical figures coord2region coords-to-insights 30 -22 50 --image-backend nilearn
Region → coordinates + insights coord2region region-to-insights "Left Amygdala" --atlas harvard-oxford

All commands emit YAML/JSON/CSV outputs under coord2region-output/ by default. Use --result-dir to customise the export path.

Web interface

The web interface mirrors the CLI schema and lives at babasanfour.github.io/Coord2Region. It provides:

  • Guided forms for inputs (coordinates or region names), atlas selection, study radius, summaries, and image options.
  • Live YAML + CLI previews you can copy or download.
  • Presets to learn common workflows (single peak lookup, region → coords, multi-peak insights).
  • Import/export so you can iterate on a config in the browser and run the CLI locally.
Config Builder – inputs and atlas Config Builder – outputs and providers Runner preview
Builder (inputs & atlas) Builder (outputs & providers) Runner

To preview or hack on the web stack locally, follow web-interface/README.md (Vite dev server + Jekyll shell + Playwright tests).

Further reading

API workflow

A compact overview of the Coord2Region pipeline: shows how inputs (coordinates or region names) are mapped to atlas labels, linked to study results, optionally enriched by AI summaries/images, and exported as reproducible artifacts.

Coord2Region workflow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coord2region-0.1.4.tar.gz (8.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coord2region-0.1.4-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file coord2region-0.1.4.tar.gz.

File metadata

  • Download URL: coord2region-0.1.4.tar.gz
  • Upload date:
  • Size: 8.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coord2region-0.1.4.tar.gz
Algorithm Hash digest
SHA256 67e59405e3fdb78f68fa50fdecb59dbbae8f58e7411c940f80473b399388a30c
MD5 1dd185c58ab6f211929152690c8d345b
BLAKE2b-256 d76ca3d2f9d06fc22b9d9ecff898731381a2cb1874f7a5ec8e6a6932f0765c4c

See more details on using hashes here.

File details

Details for the file coord2region-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: coord2region-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coord2region-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1986bb629007c3ebf3ec21b55bff3c627e28bc86469efccf6c61365017843c77
MD5 0639b6307e235f12822e0cb260ae0167
BLAKE2b-256 3efed406cbc254e056eb81a5f7660b6f130448724c6c8af762b3a9bdebb62f66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page