Wrap SimpleITK functions as command lines
Project description
Wrap SimpleITK functions as command lines
Overview
Create Typer command line interface from functions that use SimpleITK images (and transforms) as arguments or return type.
import SimpleITK as sitk
import typer
from 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 output
if __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
pip install sitk-cli
Demo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sitk_cli-0.7.0.post1.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file sitk_cli-0.7.0.post1.tar.gz
.
File metadata
- Download URL: sitk_cli-0.7.0.post1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3026a42abf08784bd8f04ff4c0e366ee102e032bb17b989da7d4101f087396ae |
|
MD5 | c760a5e0e7bb5b583f96bf82922ac213 |
|
BLAKE2b-256 | 9fedfa940b29ae57457c0d684b7a7cc057d262613ba2d7267f8153bec86c4b77 |
File details
Details for the file sitk_cli-0.7.0.post1-py3-none-any.whl
.
File metadata
- Download URL: sitk_cli-0.7.0.post1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df46aa67bac600627350d63a5a2d38ff6d983c526b373bf8f6056420a2be7a92 |
|
MD5 | 982782e585464d05fe12c37bc76f5e74 |
|
BLAKE2b-256 | 4a775b212f7cddd6eadeb5371db97b045842253fad0f626658f4cb0e24011893 |