{"id":17190701,"url":"https://github.com/dyollb/sitk-cli","last_synced_at":"2026-02-13T18:31:43.298Z","repository":{"id":41462528,"uuid":"509705580","full_name":"dyollb/sitk-cli","owner":"dyollb","description":"Wrap SimpleITK functions as command lines","archived":false,"fork":false,"pushed_at":"2026-02-06T21:45:07.000Z","size":126,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-06T23:14:08.146Z","etag":null,"topics":["cli","image-processing","itk","python","simpleitk"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dyollb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-02T08:51:28.000Z","updated_at":"2026-02-06T18:13:42.000Z","dependencies_parsed_at":"2025-01-26T04:34:40.694Z","dependency_job_id":null,"html_url":"https://github.com/dyollb/sitk-cli","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dyollb/sitk-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyollb%2Fsitk-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyollb%2Fsitk-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyollb%2Fsitk-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyollb%2Fsitk-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dyollb","download_url":"https://codeload.github.com/dyollb/sitk-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyollb%2Fsitk-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29414278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","image-processing","itk","python","simpleitk"],"created_at":"2024-10-15T01:23:38.342Z","updated_at":"2026-02-13T18:31:43.293Z","avatar_url":"https://github.com/dyollb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wrap SimpleITK functions as command lines\n\n[![Build Actions Status](https://github.com/dyollb/segmantic/workflows/CI/badge.svg)](https://github.com/dyollb/sitk-cli/actions)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://https://opensource.org/licenses/MIT)\n[![PyPI version](https://badge.fury.io/py/sitk-cli.svg)](https://badge.fury.io/py/sitk-cli)\n\u003cimg src=\"https://img.shields.io/pypi/dm/sitk-cli.svg?label=pypi%20downloads\u0026logo=python\u0026logoColor=green\"/\u003e\n\n## Overview\n\nCreate [Typer](https://github.com/tiangolo/typer) command line interfaces from functions that use [SimpleITK](https://github.com/SimpleITK/SimpleITK) images and transforms as arguments or return types.\n\n**Key features:**\n\n- 🔄 Automatic file I/O handling for SimpleITK images and transforms\n- 🎯 Type-safe with full type annotation support\n- 🚀 Built on Typer for modern CLI experiences\n- 🐍 Pythonic CLI design using native `*,` syntax for keyword-only parameters\n- 📁 Auto-create output directories with optional overwrite protection\n- 📝 Optional verbose logging with Rich integration\n- 🐍 Python 3.11+ with modern syntax\n\n## Installation\n\n```sh\npip install sitk-cli\n```\n\n**Optional dependencies:**\n\n```sh\n# For enhanced logging output with colors and formatting\npip install sitk-cli[rich]\n```\n\n**Requirements:** Python 3.11 or higher\n\n## Quick Start\n\n```python\nfrom __future__ import annotations\n\nimport SimpleITK as sitk\nimport typer\n\nfrom sitk_cli import register_command\n\napp = typer.Typer()\n\n\n@register_command(app)\ndef fill_holes_slice_by_slice(mask: sitk.Image) -\u003e sitk.Image:\n    \"\"\"Fill holes in a binary mask slice by slice.\"\"\"\n    mask = mask != 0\n    output = sitk.Image(mask.GetSize(), mask.GetPixelID())\n    output.CopyInformation(mask)\n    for k in range(mask.GetSize()[2]):\n        output[:, :, k] = sitk.BinaryFillhole(mask[:, :, k], fullyConnected=False)\n    return output\n\n\nif __name__ == \"__main__\":\n    app()\n```\n\n**How it works:** sitk-cli inspects the type annotations and creates a wrapper that:\n\n1. Converts CLI file path arguments to SimpleITK images/transforms\n1. Calls your function with the loaded objects\n1. Saves returned images/transforms to the specified output file\n\n## Advanced Features\n\n### Positional vs Named Arguments\n\nUse Python's native `*,` syntax to control whether CLI arguments are positional or named:\n\n```python\n@register_command(app)\ndef process(input: sitk.Image, *, mask: sitk.Image) -\u003e sitk.Image:\n    \"\"\"Mix positional and keyword-only arguments.\n\n    CLI: process INPUT OUTPUT --mask MASK\n    \"\"\"\n    return input * mask\n```\n\nBehavior:\n\n- **Required** Image/Transform parameters → **positional** by default\n- Parameters **after `*,`** → **keyword-only** (named options)\n- **Optional** parameters (with defaults) → **named options**\n- Output → **positional** if any input is positional, otherwise **named**\n\n### Verbose Logging\n\n```python\nfrom sitk_cli import logger, register_command\n\n@register_command(app, verbose=True)\ndef process_with_logging(input: sitk.Image) -\u003e sitk.Image:\n    logger.info(\"Starting processing...\")\n    result = sitk.Median(input, [2] * input.GetDimension())\n    logger.debug(f\"Result size: {result.GetSize()}\")\n    return result\n```\n\n```sh\npython script.py process-with-logging input.nii output.nii -v   # INFO level\npython script.py process-with-logging input.nii output.nii -vv  # DEBUG level\n```\n\n### Overwrite Protection\n\n```python\n@register_command(app, overwrite=False)\ndef protected_process(input: sitk.Image) -\u003e sitk.Image:\n    \"\"\"Prevent accidental overwrites.\"\"\"\n    return sitk.Median(input, [2] * input.GetDimension())\n```\n\n```sh\npython script.py protected-process input.nii output.nii\npython script.py protected-process input.nii output.nii          # Error: file exists\npython script.py protected-process input.nii output.nii --force  # OK, overwrites\n```\n\nModes: `overwrite=True` (default), `overwrite=False` (requires `--force`), `overwrite=\"prompt\"` (asks user)\n\nOptional parameters with defaults automatically become named options:\n\n```python\n@register_command(app)\ndef median_filter(input: sitk.Image, radius: int = 2) -\u003e sitk.Image:\n    \"\"\"Apply median filtering to an image.\n\n    CLI: median-filter INPUT OUTPUT [--radius 3]\n    \"\"\"\n    return sitk.Median(input, [radius] * input.GetDimension())\n```\n\n## Demo\n\n![Command line demo](https://github.com/dyollb/sitk-cli/raw/main/docs/demo.gif)\n\n## Development\n\n### Setup\n\n```sh\ngit clone https://github.com/dyollb/sitk-cli.git\ncd sitk-cli\npython -m venv .venv\nsource .venv/bin/activate  # or `.venv\\Scripts\\activate` on Windows\npip install -e '.[dev,rich]'\n```\n\n### Running Tests\n\n```sh\npytest tests/ -v --cov\n```\n\n### Code Quality\n\n```sh\nruff check .\nruff format .\nmypy src/sitk_cli\n```\n\n### Pre-commit Hooks\n\n```sh\npre-commit install\npre-commit run --all-files\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyollb%2Fsitk-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdyollb%2Fsitk-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyollb%2Fsitk-cli/lists"}