# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *

ANTS_TRANSFORM_INFO_METADATA = Metadata(
    id="28abd0b38cba101254396942e6a9c4a39383ae1d.boutiques",
    name="antsTransformInfo",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


_AntsTransformInfoParamsDictNoTag = typing.TypedDict('_AntsTransformInfoParamsDictNoTag', {
    "transform_file": InputPathType,
})
AntsTransformInfoParamsDictTagged = typing.TypedDict('AntsTransformInfoParamsDictTagged', {
    "@type": typing.Literal["ants/antsTransformInfo"],
    "transform_file": InputPathType,
})
AntsTransformInfoParamsDict = _AntsTransformInfoParamsDictNoTag | AntsTransformInfoParamsDictTagged


class AntsTransformInfoOutputs(typing.NamedTuple):
    """
    Output object returned when calling `AntsTransformInfoParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_info: OutputPathType
    """Information of the provided transform file."""


def ants_transform_info_params(
    transform_file: InputPathType,
) -> AntsTransformInfoParamsDictTagged:
    """
    Build parameters.
    
    Args:
        transform_file: The transform file to read. Supported formats include\
            HDF5, MINC, Matlab, and Txt.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "ants/antsTransformInfo",
        "transform_file": transform_file,
    }
    return params


def ants_transform_info_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `AntsTransformInfoParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("transform_file", None) is None:
        raise StyxValidationError("`transform_file` must not be None")
    if not isinstance(params["transform_file"], (pathlib.Path, str)):
        raise StyxValidationError(f'`transform_file` has the wrong type: Received `{type(params.get("transform_file", None))}` expected `InputPathType`')


def ants_transform_info_cargs(
    params: AntsTransformInfoParamsDict,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("antsTransformInfo")
    cargs.extend([
        "--file",
        execution.input_file(params.get("transform_file", None))
    ])
    return cargs


def ants_transform_info_outputs(
    params: AntsTransformInfoParamsDict,
    execution: Execution,
) -> AntsTransformInfoOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = AntsTransformInfoOutputs(
        root=execution.output_file("."),
        output_info=execution.output_file("transform_info.txt"),
    )
    return ret


def ants_transform_info_execute(
    params: AntsTransformInfoParamsDict,
    runner: Runner | None = None,
) -> AntsTransformInfoOutputs:
    """
    antsTransformInfo
    
    Provide information about an ITK transform file.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsTransformInfoOutputs`).
    """
    ants_transform_info_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANTS_TRANSFORM_INFO_METADATA)
    params = execution.params(params)
    cargs = ants_transform_info_cargs(params, execution)
    ret = ants_transform_info_outputs(params, execution)
    execution.run(cargs)
    return ret


def ants_transform_info(
    transform_file: InputPathType,
    runner: Runner | None = None,
) -> AntsTransformInfoOutputs:
    """
    antsTransformInfo
    
    Provide information about an ITK transform file.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        transform_file: The transform file to read. Supported formats include\
            HDF5, MINC, Matlab, and Txt.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsTransformInfoOutputs`).
    """
    params = ants_transform_info_params(
        transform_file=transform_file,
    )
    return ants_transform_info_execute(params, runner)


__all__ = [
    "ANTS_TRANSFORM_INFO_METADATA",
    "AntsTransformInfoOutputs",
    "AntsTransformInfoParamsDict",
    "AntsTransformInfoParamsDictTagged",
    "ants_transform_info",
    "ants_transform_info_execute",
    "ants_transform_info_params",
]
