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

import typing
import pathlib
from styxdefs import *

ANTS_NEUROIMAGING_BATTERY_METADATA = Metadata(
    id="3c073ef3644ad5eb7696969346c7947932d963ad.boutiques",
    name="antsNeuroimagingBattery",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


_AntsNeuroimagingBatteryParamsDictNoTag = typing.TypedDict('_AntsNeuroimagingBatteryParamsDictNoTag', {
    "input_directory": str,
    "output_directory": str,
    "output_name": str,
    "anatomical_image": InputPathType,
    "anatomical_mask": InputPathType,
    "template": typing.NotRequired[InputPathType | None],
    "template_transform_name": typing.NotRequired[str | None],
    "template_labels": typing.NotRequired[InputPathType | None],
    "dti_flag": typing.NotRequired[str | None],
    "pcasl_flag": typing.NotRequired[str | None],
    "pasl_flag": typing.NotRequired[str | None],
    "pasl_m0_flag": typing.NotRequired[str | None],
    "bold_flag": typing.NotRequired[str | None],
    "rsbold_flag": typing.NotRequired[str | None],
    "mt_flag": typing.NotRequired[str | None],
    "no_mt_flag": typing.NotRequired[str | None],
    "temp_directory": typing.NotRequired[str | None],
    "help": bool,
    "info_only": bool,
})
AntsNeuroimagingBatteryParamsDictTagged = typing.TypedDict('AntsNeuroimagingBatteryParamsDictTagged', {
    "@type": typing.Literal["ants/antsNeuroimagingBattery"],
    "input_directory": str,
    "output_directory": str,
    "output_name": str,
    "anatomical_image": InputPathType,
    "anatomical_mask": InputPathType,
    "template": typing.NotRequired[InputPathType | None],
    "template_transform_name": typing.NotRequired[str | None],
    "template_labels": typing.NotRequired[InputPathType | None],
    "dti_flag": typing.NotRequired[str | None],
    "pcasl_flag": typing.NotRequired[str | None],
    "pasl_flag": typing.NotRequired[str | None],
    "pasl_m0_flag": typing.NotRequired[str | None],
    "bold_flag": typing.NotRequired[str | None],
    "rsbold_flag": typing.NotRequired[str | None],
    "mt_flag": typing.NotRequired[str | None],
    "no_mt_flag": typing.NotRequired[str | None],
    "temp_directory": typing.NotRequired[str | None],
    "help": bool,
    "info_only": bool,
})
AntsNeuroimagingBatteryParamsDict = _AntsNeuroimagingBatteryParamsDictNoTag | AntsNeuroimagingBatteryParamsDictTagged


class AntsNeuroimagingBatteryOutputs(typing.NamedTuple):
    """
    Output object returned when calling `AntsNeuroimagingBatteryParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_directory: OutputPathType
    """Directory containing output transform files."""


def ants_neuroimaging_battery_params(
    input_directory: str,
    output_directory: str,
    output_name: str,
    anatomical_image: InputPathType,
    anatomical_mask: InputPathType,
    template: InputPathType | None = None,
    template_transform_name: str | None = None,
    template_labels: InputPathType | None = None,
    dti_flag: str | None = None,
    pcasl_flag: str | None = None,
    pasl_flag: str | None = None,
    pasl_m0_flag: str | None = None,
    bold_flag: str | None = None,
    rsbold_flag: str | None = None,
    mt_flag: str | None = None,
    no_mt_flag: str | None = None,
    temp_directory: str | None = None,
    help_: bool = False,
    info_only: bool = False,
) -> AntsNeuroimagingBatteryParamsDictTagged:
    """
    Build parameters.
    
    Args:
        input_directory: Directory where to look for modality images.
        output_directory: Directory where output goes (where\
            antsCorticalThickness output lives).
        output_name: File prefix for outputs.
        anatomical_image: Reference subject image (usually T1).
        anatomical_mask: Mask of anatomical image, should contain cerebrum,\
            cerebellum, and brainstem.
        template: Template image.
        template_transform_name: Basename of transforms from anatomical to\
            template space (must be in output base dir).
        template_labels: Labels in template space.
        dti_flag: DTI flag in DIRNAME/fileflag/outid format.
        pcasl_flag: pCASL flag in DIRNAME/fileflag/outid format.
        pasl_flag: PASL flag in DIRNAME/fileflag/outid format.
        pasl_m0_flag: PASL M0 flag in DIRNAME/fileflag/outid format.
        bold_flag: BOLD flag in DIRNAME/fileflag/outid format.
        rsbold_flag: RSBOLD flag in DIRNAME/fileflag/outid format.
        mt_flag: MT flag in DIRNAME/fileflag/outid format.
        no_mt_flag: No MT flag in DIRNAME/fileflag/outid format.
        temp_directory: Temporary directory.
        help_: Display help information.
        info_only: Look for inputs, output what is there, but don't process any\
            data.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "ants/antsNeuroimagingBattery",
        "input_directory": input_directory,
        "output_directory": output_directory,
        "output_name": output_name,
        "anatomical_image": anatomical_image,
        "anatomical_mask": anatomical_mask,
        "help": help_,
        "info_only": info_only,
    }
    if template is not None:
        params["template"] = template
    if template_transform_name is not None:
        params["template_transform_name"] = template_transform_name
    if template_labels is not None:
        params["template_labels"] = template_labels
    if dti_flag is not None:
        params["dti_flag"] = dti_flag
    if pcasl_flag is not None:
        params["pcasl_flag"] = pcasl_flag
    if pasl_flag is not None:
        params["pasl_flag"] = pasl_flag
    if pasl_m0_flag is not None:
        params["pasl_m0_flag"] = pasl_m0_flag
    if bold_flag is not None:
        params["bold_flag"] = bold_flag
    if rsbold_flag is not None:
        params["rsbold_flag"] = rsbold_flag
    if mt_flag is not None:
        params["mt_flag"] = mt_flag
    if no_mt_flag is not None:
        params["no_mt_flag"] = no_mt_flag
    if temp_directory is not None:
        params["temp_directory"] = temp_directory
    return params


def ants_neuroimaging_battery_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `AntsNeuroimagingBatteryParamsDict` 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("input_directory", None) is None:
        raise StyxValidationError("`input_directory` must not be None")
    if not isinstance(params["input_directory"], str):
        raise StyxValidationError(f'`input_directory` has the wrong type: Received `{type(params.get("input_directory", None))}` expected `str`')
    if params.get("output_directory", None) is None:
        raise StyxValidationError("`output_directory` must not be None")
    if not isinstance(params["output_directory"], str):
        raise StyxValidationError(f'`output_directory` has the wrong type: Received `{type(params.get("output_directory", None))}` expected `str`')
    if params.get("output_name", None) is None:
        raise StyxValidationError("`output_name` must not be None")
    if not isinstance(params["output_name"], str):
        raise StyxValidationError(f'`output_name` has the wrong type: Received `{type(params.get("output_name", None))}` expected `str`')
    if params.get("anatomical_image", None) is None:
        raise StyxValidationError("`anatomical_image` must not be None")
    if not isinstance(params["anatomical_image"], (pathlib.Path, str)):
        raise StyxValidationError(f'`anatomical_image` has the wrong type: Received `{type(params.get("anatomical_image", None))}` expected `InputPathType`')
    if params.get("anatomical_mask", None) is None:
        raise StyxValidationError("`anatomical_mask` must not be None")
    if not isinstance(params["anatomical_mask"], (pathlib.Path, str)):
        raise StyxValidationError(f'`anatomical_mask` has the wrong type: Received `{type(params.get("anatomical_mask", None))}` expected `InputPathType`')
    if params.get("template", None) is not None:
        if not isinstance(params["template"], (pathlib.Path, str)):
            raise StyxValidationError(f'`template` has the wrong type: Received `{type(params.get("template", None))}` expected `InputPathType | None`')
    if params.get("template_transform_name", None) is not None:
        if not isinstance(params["template_transform_name"], str):
            raise StyxValidationError(f'`template_transform_name` has the wrong type: Received `{type(params.get("template_transform_name", None))}` expected `str | None`')
    if params.get("template_labels", None) is not None:
        if not isinstance(params["template_labels"], (pathlib.Path, str)):
            raise StyxValidationError(f'`template_labels` has the wrong type: Received `{type(params.get("template_labels", None))}` expected `InputPathType | None`')
    if params.get("dti_flag", None) is not None:
        if not isinstance(params["dti_flag"], str):
            raise StyxValidationError(f'`dti_flag` has the wrong type: Received `{type(params.get("dti_flag", None))}` expected `str | None`')
    if params.get("pcasl_flag", None) is not None:
        if not isinstance(params["pcasl_flag"], str):
            raise StyxValidationError(f'`pcasl_flag` has the wrong type: Received `{type(params.get("pcasl_flag", None))}` expected `str | None`')
    if params.get("pasl_flag", None) is not None:
        if not isinstance(params["pasl_flag"], str):
            raise StyxValidationError(f'`pasl_flag` has the wrong type: Received `{type(params.get("pasl_flag", None))}` expected `str | None`')
    if params.get("pasl_m0_flag", None) is not None:
        if not isinstance(params["pasl_m0_flag"], str):
            raise StyxValidationError(f'`pasl_m0_flag` has the wrong type: Received `{type(params.get("pasl_m0_flag", None))}` expected `str | None`')
    if params.get("bold_flag", None) is not None:
        if not isinstance(params["bold_flag"], str):
            raise StyxValidationError(f'`bold_flag` has the wrong type: Received `{type(params.get("bold_flag", None))}` expected `str | None`')
    if params.get("rsbold_flag", None) is not None:
        if not isinstance(params["rsbold_flag"], str):
            raise StyxValidationError(f'`rsbold_flag` has the wrong type: Received `{type(params.get("rsbold_flag", None))}` expected `str | None`')
    if params.get("mt_flag", None) is not None:
        if not isinstance(params["mt_flag"], str):
            raise StyxValidationError(f'`mt_flag` has the wrong type: Received `{type(params.get("mt_flag", None))}` expected `str | None`')
    if params.get("no_mt_flag", None) is not None:
        if not isinstance(params["no_mt_flag"], str):
            raise StyxValidationError(f'`no_mt_flag` has the wrong type: Received `{type(params.get("no_mt_flag", None))}` expected `str | None`')
    if params.get("temp_directory", None) is not None:
        if not isinstance(params["temp_directory"], str):
            raise StyxValidationError(f'`temp_directory` has the wrong type: Received `{type(params.get("temp_directory", None))}` expected `str | None`')
    if params.get("help", False) is None:
        raise StyxValidationError("`help` must not be None")
    if not isinstance(params["help"], bool):
        raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
    if params.get("info_only", False) is None:
        raise StyxValidationError("`info_only` must not be None")
    if not isinstance(params["info_only"], bool):
        raise StyxValidationError(f'`info_only` has the wrong type: Received `{type(params.get("info_only", False))}` expected `bool`')


def ants_neuroimaging_battery_cargs(
    params: AntsNeuroimagingBatteryParamsDict,
    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("antsNeuroimagingBattery")
    cargs.extend([
        "--input-directory",
        params.get("input_directory", None)
    ])
    cargs.extend([
        "--output-directory",
        params.get("output_directory", None)
    ])
    cargs.extend([
        "--output-name",
        params.get("output_name", None)
    ])
    cargs.extend([
        "--anatomical",
        execution.input_file(params.get("anatomical_image", None))
    ])
    cargs.extend([
        "--anatomical-mask",
        execution.input_file(params.get("anatomical_mask", None))
    ])
    if params.get("template", None) is not None:
        cargs.extend([
            "--template",
            execution.input_file(params.get("template", None))
        ])
    if params.get("template_transform_name", None) is not None:
        cargs.extend([
            "--template-transform-name",
            params.get("template_transform_name", None)
        ])
    if params.get("template_labels", None) is not None:
        cargs.extend([
            "--template-labels",
            execution.input_file(params.get("template_labels", None))
        ])
    if params.get("dti_flag", None) is not None:
        cargs.extend([
            "--dti-flag",
            params.get("dti_flag", None)
        ])
    if params.get("pcasl_flag", None) is not None:
        cargs.extend([
            "--pcasl-flag",
            params.get("pcasl_flag", None)
        ])
    if params.get("pasl_flag", None) is not None:
        cargs.extend([
            "--pasl-flag",
            params.get("pasl_flag", None)
        ])
    if params.get("pasl_m0_flag", None) is not None:
        cargs.extend([
            "--pasl-m0-flag",
            params.get("pasl_m0_flag", None)
        ])
    if params.get("bold_flag", None) is not None:
        cargs.extend([
            "--bold-flag",
            params.get("bold_flag", None)
        ])
    if params.get("rsbold_flag", None) is not None:
        cargs.extend([
            "--rsbold-flag",
            params.get("rsbold_flag", None)
        ])
    if params.get("mt_flag", None) is not None:
        cargs.extend([
            "--mt-flag",
            params.get("mt_flag", None)
        ])
    if params.get("no_mt_flag", None) is not None:
        cargs.extend([
            "--no-mt-flag",
            params.get("no_mt_flag", None)
        ])
    if params.get("temp_directory", None) is not None:
        cargs.extend([
            "--temp-directory",
            params.get("temp_directory", None)
        ])
    if params.get("help", False):
        cargs.append("--help")
    if params.get("info_only", False):
        cargs.append("--info-only")
    return cargs


def ants_neuroimaging_battery_outputs(
    params: AntsNeuroimagingBatteryParamsDict,
    execution: Execution,
) -> AntsNeuroimagingBatteryOutputs:
    """
    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 = AntsNeuroimagingBatteryOutputs(
        root=execution.output_file("."),
        output_directory=execution.output_file(params.get("output_directory", None)),
    )
    return ret


def ants_neuroimaging_battery_execute(
    params: AntsNeuroimagingBatteryParamsDict,
    runner: Runner | None = None,
) -> AntsNeuroimagingBatteryOutputs:
    """
    antsNeuroimagingBattery
    
    Align MR modalities to a common within-subject (and optional template)
    space.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsNeuroimagingBatteryOutputs`).
    """
    ants_neuroimaging_battery_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANTS_NEUROIMAGING_BATTERY_METADATA)
    params = execution.params(params)
    cargs = ants_neuroimaging_battery_cargs(params, execution)
    ret = ants_neuroimaging_battery_outputs(params, execution)
    execution.run(cargs)
    return ret


def ants_neuroimaging_battery(
    input_directory: str,
    output_directory: str,
    output_name: str,
    anatomical_image: InputPathType,
    anatomical_mask: InputPathType,
    template: InputPathType | None = None,
    template_transform_name: str | None = None,
    template_labels: InputPathType | None = None,
    dti_flag: str | None = None,
    pcasl_flag: str | None = None,
    pasl_flag: str | None = None,
    pasl_m0_flag: str | None = None,
    bold_flag: str | None = None,
    rsbold_flag: str | None = None,
    mt_flag: str | None = None,
    no_mt_flag: str | None = None,
    temp_directory: str | None = None,
    help_: bool = False,
    info_only: bool = False,
    runner: Runner | None = None,
) -> AntsNeuroimagingBatteryOutputs:
    """
    antsNeuroimagingBattery
    
    Align MR modalities to a common within-subject (and optional template)
    space.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        input_directory: Directory where to look for modality images.
        output_directory: Directory where output goes (where\
            antsCorticalThickness output lives).
        output_name: File prefix for outputs.
        anatomical_image: Reference subject image (usually T1).
        anatomical_mask: Mask of anatomical image, should contain cerebrum,\
            cerebellum, and brainstem.
        template: Template image.
        template_transform_name: Basename of transforms from anatomical to\
            template space (must be in output base dir).
        template_labels: Labels in template space.
        dti_flag: DTI flag in DIRNAME/fileflag/outid format.
        pcasl_flag: pCASL flag in DIRNAME/fileflag/outid format.
        pasl_flag: PASL flag in DIRNAME/fileflag/outid format.
        pasl_m0_flag: PASL M0 flag in DIRNAME/fileflag/outid format.
        bold_flag: BOLD flag in DIRNAME/fileflag/outid format.
        rsbold_flag: RSBOLD flag in DIRNAME/fileflag/outid format.
        mt_flag: MT flag in DIRNAME/fileflag/outid format.
        no_mt_flag: No MT flag in DIRNAME/fileflag/outid format.
        temp_directory: Temporary directory.
        help_: Display help information.
        info_only: Look for inputs, output what is there, but don't process any\
            data.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AntsNeuroimagingBatteryOutputs`).
    """
    params = ants_neuroimaging_battery_params(
        input_directory=input_directory,
        output_directory=output_directory,
        output_name=output_name,
        anatomical_image=anatomical_image,
        anatomical_mask=anatomical_mask,
        template=template,
        template_transform_name=template_transform_name,
        template_labels=template_labels,
        dti_flag=dti_flag,
        pcasl_flag=pcasl_flag,
        pasl_flag=pasl_flag,
        pasl_m0_flag=pasl_m0_flag,
        bold_flag=bold_flag,
        rsbold_flag=rsbold_flag,
        mt_flag=mt_flag,
        no_mt_flag=no_mt_flag,
        temp_directory=temp_directory,
        help_=help_,
        info_only=info_only,
    )
    return ants_neuroimaging_battery_execute(params, runner)


__all__ = [
    "ANTS_NEUROIMAGING_BATTERY_METADATA",
    "AntsNeuroimagingBatteryOutputs",
    "AntsNeuroimagingBatteryParamsDict",
    "AntsNeuroimagingBatteryParamsDictTagged",
    "ants_neuroimaging_battery",
    "ants_neuroimaging_battery_execute",
    "ants_neuroimaging_battery_params",
]
