Skip to main content

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.]

Metadata

Release files for fw-gear-monai-transforms 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for fw-gear-monai-transforms 0.1.3
File Interpreter ABI Platform
fw_gear_monai_transforms-0.1.3-py3-none-any.whl Python 3 none any Details

Release files / fw_gear_monai_transforms-0.1.3-py3-none-any.whl

Download URL fw_gear_monai_transforms-0.1.3-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b8a402c6a4b9ed0835c7f4f808a93c61e37e6a7ca52da98af6db6457c8ba06c
BLAKE2b-256 checksum
How to use checksums
c314da9c30fd1b17d321c1dd64f711db5d7ecfb70f4f5e3e810e7e03fb12fbdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.24.1","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page