Skip to main content

Wrap SimpleITK functions as command lines

Project description

Wrap SimpleITK functions as command lines

Build Actions Status License PyPI version

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

Command lind demo

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

sitk_cli-0.7.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

sitk_cli-0.7.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file sitk_cli-0.7.0.tar.gz.

File metadata

  • Download URL: sitk_cli-0.7.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.10

File hashes

Hashes for sitk_cli-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f7b8bdab0b224885ad970caece99d9458fac9adcb76e899c9b522e3b40e12b9e
MD5 ae712dd63d61901095182f2eca4c1d02
BLAKE2b-256 4372c38dbcb6291896a05b9dcf1bc9ef44f43848b5288c1a6985c515151c528f

See more details on using hashes here.

File details

Details for the file sitk_cli-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: sitk_cli-0.7.0-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.8.10

File hashes

Hashes for sitk_cli-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79fe7441950634381cb2a78d2771bda30d96d27b01299a4c05e82608c2d18c50
MD5 cb524bf1da6eb6ba9961a07036eb90e5
BLAKE2b-256 4d952ff5844f3e2920571d9c7a79560851d2a0799b66dbcd8c7c87ef7fdcf38a

See more details on using hashes here.

Supported by

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