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

import typing
import pathlib
from styxdefs import *

NIFTI_INFORMATION_METADATA = Metadata(
    id="a23892d08c899f32fc5adc3d462a0e9f07f36b16.boutiques",
    name="nifti-information",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


NiftiInformationPrintHeaderParameters = typing.TypedDict('NiftiInformationPrintHeaderParameters', {
    "@type": typing.NotRequired[typing.Literal["print_header"]],
    "opt_allow_truncated": bool,
})
NiftiInformationPrintHeaderParametersTagged = typing.TypedDict('NiftiInformationPrintHeaderParametersTagged', {
    "@type": typing.Literal["print_header"],
    "opt_allow_truncated": bool,
})


NiftiInformationPrintXmlParameters = typing.TypedDict('NiftiInformationPrintXmlParameters', {
    "@type": typing.NotRequired[typing.Literal["print_xml"]],
    "opt_version_version": typing.NotRequired[str | None],
})
NiftiInformationPrintXmlParametersTagged = typing.TypedDict('NiftiInformationPrintXmlParametersTagged', {
    "@type": typing.Literal["print_xml"],
    "opt_version_version": typing.NotRequired[str | None],
})


NiftiInformationParameters = typing.TypedDict('NiftiInformationParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/nifti-information"]],
    "nifti_file": str,
    "print_header": typing.NotRequired[NiftiInformationPrintHeaderParameters | None],
    "opt_print_matrix": bool,
    "print_xml": typing.NotRequired[NiftiInformationPrintXmlParameters | None],
})
NiftiInformationParametersTagged = typing.TypedDict('NiftiInformationParametersTagged', {
    "@type": typing.Literal["workbench/nifti-information"],
    "nifti_file": str,
    "print_header": typing.NotRequired[NiftiInformationPrintHeaderParameters | None],
    "opt_print_matrix": bool,
    "print_xml": typing.NotRequired[NiftiInformationPrintXmlParameters | None],
})


def nifti_information_print_header_params(
    opt_allow_truncated: bool = False,
) -> NiftiInformationPrintHeaderParametersTagged:
    """
    Build parameters.
    
    Args:
        opt_allow_truncated: print the header even if the data is truncated.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "print_header",
        "opt_allow_truncated": opt_allow_truncated,
    }
    return params


def nifti_information_print_header_cargs(
    params: NiftiInformationPrintHeaderParameters,
    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("-print-header")
    if params.get("opt_allow_truncated", False):
        cargs.append("-allow-truncated")
    return cargs


def nifti_information_print_xml_params(
    opt_version_version: str | None = None,
) -> NiftiInformationPrintXmlParametersTagged:
    """
    Build parameters.
    
    Args:
        opt_version_version: convert the XML to a specific CIFTI version\
            (default is the file's cifti version): the CIFTI version to use.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "print_xml",
    }
    if opt_version_version is not None:
        params["opt_version_version"] = opt_version_version
    return params


def nifti_information_print_xml_cargs(
    params: NiftiInformationPrintXmlParameters,
    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("-print-xml")
    if params.get("opt_version_version", None) is not None:
        cargs.extend([
            "-version",
            params.get("opt_version_version", None)
        ])
    return cargs


class NiftiInformationOutputs(typing.NamedTuple):
    """
    Output object returned when calling `NiftiInformationParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def nifti_information_params(
    nifti_file: str,
    print_header: NiftiInformationPrintHeaderParameters | None = None,
    opt_print_matrix: bool = False,
    print_xml: NiftiInformationPrintXmlParameters | None = None,
) -> NiftiInformationParametersTagged:
    """
    Build parameters.
    
    Args:
        nifti_file: the nifti/cifti file to examine.
        print_header: display the header contents.
        opt_print_matrix: output the values in the matrix (cifti only).
        print_xml: print the cifti XML (cifti only).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/nifti-information",
        "nifti_file": nifti_file,
        "opt_print_matrix": opt_print_matrix,
    }
    if print_header is not None:
        params["print_header"] = print_header
    if print_xml is not None:
        params["print_xml"] = print_xml
    return params


def nifti_information_cargs(
    params: NiftiInformationParameters,
    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("wb_command")
    cargs.append("-nifti-information")
    cargs.append(params.get("nifti_file", None))
    if params.get("print_header", None) is not None:
        cargs.extend(nifti_information_print_header_cargs(params.get("print_header", None), execution))
    if params.get("opt_print_matrix", False):
        cargs.append("-print-matrix")
    if params.get("print_xml", None) is not None:
        cargs.extend(nifti_information_print_xml_cargs(params.get("print_xml", None), execution))
    return cargs


def nifti_information_outputs(
    params: NiftiInformationParameters,
    execution: Execution,
) -> NiftiInformationOutputs:
    """
    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 = NiftiInformationOutputs(
        root=execution.output_file("."),
    )
    return ret


def nifti_information_execute(
    params: NiftiInformationParameters,
    runner: Runner | None = None,
) -> NiftiInformationOutputs:
    """
    nifti-information
    
    Display information about a nifti/cifti file.
    
    You must specify at least one -print-* option.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `NiftiInformationOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(NIFTI_INFORMATION_METADATA)
    params = execution.params(params)
    cargs = nifti_information_cargs(params, execution)
    ret = nifti_information_outputs(params, execution)
    execution.run(cargs)
    return ret


def nifti_information(
    nifti_file: str,
    print_header: NiftiInformationPrintHeaderParameters | None = None,
    opt_print_matrix: bool = False,
    print_xml: NiftiInformationPrintXmlParameters | None = None,
    runner: Runner | None = None,
) -> NiftiInformationOutputs:
    """
    nifti-information
    
    Display information about a nifti/cifti file.
    
    You must specify at least one -print-* option.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        nifti_file: the nifti/cifti file to examine.
        print_header: display the header contents.
        opt_print_matrix: output the values in the matrix (cifti only).
        print_xml: print the cifti XML (cifti only).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `NiftiInformationOutputs`).
    """
    params = nifti_information_params(
        nifti_file=nifti_file,
        print_header=print_header,
        opt_print_matrix=opt_print_matrix,
        print_xml=print_xml,
    )
    return nifti_information_execute(params, runner)


__all__ = [
    "NIFTI_INFORMATION_METADATA",
    "NiftiInformationOutputs",
    "nifti_information",
    "nifti_information_execute",
    "nifti_information_params",
    "nifti_information_print_header_params",
    "nifti_information_print_xml_params",
]
