https://github.com/dyollb/sitk-cli
Wrap SimpleITK functions as command lines
https://github.com/dyollb/sitk-cli
cli image-processing itk python simpleitk
Last synced: 2 months ago
JSON representation
Wrap SimpleITK functions as command lines
- Host: GitHub
- URL: https://github.com/dyollb/sitk-cli
- Owner: dyollb
- License: mit
- Created: 2022-07-02T08:51:28.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-24T11:50:46.000Z (12 months ago)
- Last Synced: 2025-02-27T11:44:40.784Z (3 months ago)
- Topics: cli, image-processing, itk, python, simpleitk
- Language: Python
- Homepage:
- Size: 109 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wrap SimpleITK functions as command lines
[](https://github.com/dyollb/sitk-cli/actions)
[](https://https://opensource.org/licenses/MIT)
[](https://badge.fury.io/py/sitk-cli)## Overview
Create [Typer](https://github.com/tiangolo/typer) command line interface from functions that use [SimpleITK](https://github.com/SimpleITK/SimpleITK) images (and transforms) as arguments or return type.
```Python
import SimpleITK as sitk
import typerfrom sitk_cli import register_command
app = typer.Typer()
@register_command(app)
def fill_holes_slice_by_slice(mask: sitk.Image) -> sitk.Image:
mask = mask != 0
output = sitk.Image(mask.GetSize(), mask.GetPixelID())
output.CopyInformation(mask)
for k in range(mask.GetSize()[2]):
output[:, :, k] = sitk.BinaryFillhole(mask[:, :, k], fullyConnected=False)
return outputif __name__ == "__main__":
app()
```To work, sitk-cli inspects the type annotations of the function and creates a wrapper function that loads images from file and passes these to the original function. Returned images (transforms) are written to a file by the wrapper function..
## Installation
```sh
pip install sitk-cli
```## Demo
