Skip to main content

Apply the MONAI tranforms as specified by the user input script and save output in the destination container

Project description

MONAI Transforms

Overview

Summary

Apply MONAI transforms to input file as specified by the user defined transform script and save the transformed output in the destination container.

Cite

https://doi.org/10.5281/zenodo.4323058 License: MIT

Classification

Category: converter

Gear Level:

  • Project
  • Subject
  • Session
  • Acquisition
  • Analysis

Support

  • input-file

    • Name: The input-file.
    • Type: nifti, dicom, image
    • Optional: False
    • Description: Input NIfTI file for the transform.
  • transform-script

    • Name: The transform module.py.
    • Type: nifti
    • Optional: False
    • Description: The Python module containing the definition of the transforms to apply.

Config

  • debug

    • Name: debug
    • Type: boolean
    • Description: Log debug messages
    • Default: False
  • number-of-iterations

    • Name: number-of-iterations
    • Type: integer
    • Description: Number of times the transform will be applied to the image.
    • Default: False

Outputs

Files

  • transformed-file
    • Name: The transformed file
    • Type: Whatever is specified in the SaveImaged transform

Usage

Description

This gear takes as input an image file (e.g. nii, nii.gz, dcm, png, jpg, bmp), loads the transform defined by the input transform-script, applies this transform to the input image and saved the transformed image in the destination acquisition container.

File Specifications

transform-script

The transform-script python file must:

  • define an object called transform from the Compose class
  • start with a LoadImaged transform
  • end with a SaveImaged transform
  • apply the transformation(s) on the key img

It is recommended to validate the transform first outside of the gear environment for faster/easier debugging/iteration. For example, the following code snippet will let you test your transform on a NIfTI file and inspect the saved output:

from monai.transforms import (
    Compose, LoadImaged, EnsureChannelFirstd, RandGaussianNoised, SaveImaged
)

transform = Compose(
    [
        LoadImaged(["img"]),
        EnsureChannelFirstd(["img"], channel_dim="no_channel"),
        RandGaussianNoised(["img"]),
        SaveImaged(["img"], output_postfix="t", output_ext=".nii.gz"),
    ]
)

transform({"img": "path/to/my/input/nifti.nii.gz"})

Examples of transforms can be found in the examples folder.

Workflow

A picture and description of the workflow

graph LR;
    A[input-file]:::input --> E((Gear));
    B[transform-script]:::input --> E((Gear));
    E:::gear --> F[Transformed file]:::container;

    classDef container fill:#57d,color:#fff
    classDef input fill:#7a9,color:#fff
    classDef gear fill:#659,color:#fff

Contributing

[For more information about how to get started contributing to that gear, checkout CONTRIBUTING.md.]

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

fw_gear_monai_transforms-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file fw_gear_monai_transforms-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fw_gear_monai_transforms-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2630baff5c31e47c8477f2f951649da6ab62159cbff793166f6a224a33a9a65c
MD5 3138a8c45f413f8f886c2c2654cb0add
BLAKE2b-256 bb8af1f25ad030e8ab3cab2e669350ef7c2f0c14b5c4b0e032b6dd054f82ef05

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