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

import typing
import pathlib
from styxdefs import *

CONVERT_TO_JPG_METADATA = Metadata(
    id="5bc8a9ac227d992d762dc5365725a949c90f5c17.boutiques",
    name="ConvertToJpg",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


ConvertToJpgParameters = typing.TypedDict('ConvertToJpgParameters', {
    "__STYX_TYPE__": typing.Literal["ConvertToJpg"],
    "infile": InputPathType,
    "outfile": str,
})


def dyn_cargs(
    t: str,
) -> typing.Any:
    """
    Get build cargs function by command type.
    
    Args:
        t: Command type.
    Returns:
        Build cargs function.
    """
    return {
        "ConvertToJpg": convert_to_jpg_cargs,
    }.get(t)


def dyn_outputs(
    t: str,
) -> typing.Any:
    """
    Get build outputs function by command type.
    
    Args:
        t: Command type.
    Returns:
        Build outputs function.
    """
    return {
        "ConvertToJpg": convert_to_jpg_outputs,
    }.get(t)


class ConvertToJpgOutputs(typing.NamedTuple):
    """
    Output object returned when calling `convert_to_jpg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_jpg: OutputPathType
    """The converted JPG image."""


def convert_to_jpg_params(
    infile: InputPathType,
    outfile: str,
) -> ConvertToJpgParameters:
    """
    Build parameters.
    
    Args:
        infile: The input file in NIfTI format.
        outfile: The output file in JPG format.
    Returns:
        Parameter dictionary
    """
    params = {
        "__STYXTYPE__": "ConvertToJpg",
        "infile": infile,
        "outfile": outfile,
    }
    return params


def convert_to_jpg_cargs(
    params: ConvertToJpgParameters,
    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("ConvertToJpg" + execution.input_file(params.get("infile")) + params.get("outfile"))
    return cargs


def convert_to_jpg_outputs(
    params: ConvertToJpgParameters,
    execution: Execution,
) -> ConvertToJpgOutputs:
    """
    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 = ConvertToJpgOutputs(
        root=execution.output_file("."),
        output_jpg=execution.output_file(params.get("outfile")),
    )
    return ret


def convert_to_jpg_execute(
    params: ConvertToJpgParameters,
    execution: Execution,
) -> ConvertToJpgOutputs:
    """
    A tool to convert NIfTI images to JPG format.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        params: The parameters.
        execution: The execution object.
    Returns:
        NamedTuple of outputs (described in `ConvertToJpgOutputs`).
    """
    params = execution.params(params)
    cargs = convert_to_jpg_cargs(params, execution)
    ret = convert_to_jpg_outputs(params, execution)
    execution.run(cargs)
    return ret


def convert_to_jpg(
    infile: InputPathType,
    outfile: str,
    runner: Runner | None = None,
) -> ConvertToJpgOutputs:
    """
    A tool to convert NIfTI images to JPG format.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        infile: The input file in NIfTI format.
        outfile: The output file in JPG format.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ConvertToJpgOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CONVERT_TO_JPG_METADATA)
    params = convert_to_jpg_params(
        infile=infile,
        outfile=outfile,
    )
    return convert_to_jpg_execute(params, execution)


__all__ = [
    "CONVERT_TO_JPG_METADATA",
    "ConvertToJpgOutputs",
    "ConvertToJpgParameters",
    "convert_to_jpg",
    "convert_to_jpg_params",
]
