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

import typing
import pathlib
from styxdefs import *

CONVERT_FIBER_ORIENTATIONS_METADATA = Metadata(
    id="848dea6b577ee4b94a5e883dc7976a17d71a95af.boutiques",
    name="convert-fiber-orientations",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


ConvertFiberOrientationsFiberParameters = typing.TypedDict('ConvertFiberOrientationsFiberParameters', {
    "@type": typing.NotRequired[typing.Literal["fiber"]],
    "mean_f": InputPathType,
    "stdev_f": InputPathType,
    "theta": InputPathType,
    "phi": InputPathType,
    "psi": InputPathType,
    "ka": InputPathType,
    "kb": InputPathType,
})
ConvertFiberOrientationsFiberParametersTagged = typing.TypedDict('ConvertFiberOrientationsFiberParametersTagged', {
    "@type": typing.Literal["fiber"],
    "mean_f": InputPathType,
    "stdev_f": InputPathType,
    "theta": InputPathType,
    "phi": InputPathType,
    "psi": InputPathType,
    "ka": InputPathType,
    "kb": InputPathType,
})


ConvertFiberOrientationsParameters = typing.TypedDict('ConvertFiberOrientationsParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/convert-fiber-orientations"]],
    "label_volume": InputPathType,
    "fiber_out": str,
    "fiber": typing.NotRequired[list[ConvertFiberOrientationsFiberParameters] | None],
})
ConvertFiberOrientationsParametersTagged = typing.TypedDict('ConvertFiberOrientationsParametersTagged', {
    "@type": typing.Literal["workbench/convert-fiber-orientations"],
    "label_volume": InputPathType,
    "fiber_out": str,
    "fiber": typing.NotRequired[list[ConvertFiberOrientationsFiberParameters] | None],
})


def convert_fiber_orientations_fiber_params(
    mean_f: InputPathType,
    stdev_f: InputPathType,
    theta: InputPathType,
    phi: InputPathType,
    psi: InputPathType,
    ka: InputPathType,
    kb: InputPathType,
) -> ConvertFiberOrientationsFiberParametersTagged:
    """
    Build parameters.
    
    Args:
        mean_f: mean fiber strength.
        stdev_f: standard deviation of fiber strength.
        theta: theta angle.
        phi: phi angle.
        psi: psi angle.
        ka: ka bingham parameter.
        kb: kb bingham parameter.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "fiber",
        "mean_f": mean_f,
        "stdev_f": stdev_f,
        "theta": theta,
        "phi": phi,
        "psi": psi,
        "ka": ka,
        "kb": kb,
    }
    return params


def convert_fiber_orientations_fiber_cargs(
    params: ConvertFiberOrientationsFiberParameters,
    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("-fiber")
    cargs.append(execution.input_file(params.get("mean_f", None)))
    cargs.append(execution.input_file(params.get("stdev_f", None)))
    cargs.append(execution.input_file(params.get("theta", None)))
    cargs.append(execution.input_file(params.get("phi", None)))
    cargs.append(execution.input_file(params.get("psi", None)))
    cargs.append(execution.input_file(params.get("ka", None)))
    cargs.append(execution.input_file(params.get("kb", None)))
    return cargs


class ConvertFiberOrientationsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `ConvertFiberOrientationsParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    fiber_out: OutputPathType
    """the output fiber orientation file"""


def convert_fiber_orientations_params(
    label_volume: InputPathType,
    fiber_out: str,
    fiber: list[ConvertFiberOrientationsFiberParameters] | None = None,
) -> ConvertFiberOrientationsParametersTagged:
    """
    Build parameters.
    
    Args:
        label_volume: volume of cifti structure labels.
        fiber_out: the output fiber orientation file.
        fiber: specify the parameter volumes for a fiber.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/convert-fiber-orientations",
        "label_volume": label_volume,
        "fiber_out": fiber_out,
    }
    if fiber is not None:
        params["fiber"] = fiber
    return params


def convert_fiber_orientations_cargs(
    params: ConvertFiberOrientationsParameters,
    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("-convert-fiber-orientations")
    cargs.append(execution.input_file(params.get("label_volume", None)))
    cargs.append(params.get("fiber_out", None))
    if params.get("fiber", None) is not None:
        cargs.extend([a for c in [convert_fiber_orientations_fiber_cargs(s, execution) for s in params.get("fiber", None)] for a in c])
    return cargs


def convert_fiber_orientations_outputs(
    params: ConvertFiberOrientationsParameters,
    execution: Execution,
) -> ConvertFiberOrientationsOutputs:
    """
    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 = ConvertFiberOrientationsOutputs(
        root=execution.output_file("."),
        fiber_out=execution.output_file(params.get("fiber_out", None)),
    )
    return ret


def convert_fiber_orientations_execute(
    params: ConvertFiberOrientationsParameters,
    runner: Runner | None = None,
) -> ConvertFiberOrientationsOutputs:
    """
    convert-fiber-orientations
    
    Convert bingham parameter volumes to fiber orientation file.
    
    Takes precomputed bingham parameters from volume files and converts them to
    the format workbench uses for display. The <label-volume> argument must be a
    label volume, where the labels use these strings:
    
    
    CORTEX_LEFT
    CORTEX_RIGHT
    CEREBELLUM
    ACCUMBENS_LEFT
    ACCUMBENS_RIGHT
    ALL_GREY_MATTER
    ALL_WHITE_MATTER
    AMYGDALA_LEFT
    AMYGDALA_RIGHT
    BRAIN_STEM
    CAUDATE_LEFT
    CAUDATE_RIGHT
    CEREBELLAR_WHITE_MATTER_LEFT
    CEREBELLAR_WHITE_MATTER_RIGHT
    CEREBELLUM_LEFT
    CEREBELLUM_RIGHT
    CEREBRAL_WHITE_MATTER_LEFT
    CEREBRAL_WHITE_MATTER_RIGHT
    CORTEX
    DIENCEPHALON_VENTRAL_LEFT
    DIENCEPHALON_VENTRAL_RIGHT
    HIPPOCAMPUS_LEFT
    HIPPOCAMPUS_RIGHT
    INVALID
    OTHER
    OTHER_GREY_MATTER
    OTHER_WHITE_MATTER
    PALLIDUM_LEFT
    PALLIDUM_RIGHT
    PUTAMEN_LEFT
    PUTAMEN_RIGHT
    THALAMUS_LEFT
    THALAMUS_RIGHT.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ConvertFiberOrientationsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CONVERT_FIBER_ORIENTATIONS_METADATA)
    params = execution.params(params)
    cargs = convert_fiber_orientations_cargs(params, execution)
    ret = convert_fiber_orientations_outputs(params, execution)
    execution.run(cargs)
    return ret


def convert_fiber_orientations(
    label_volume: InputPathType,
    fiber_out: str,
    fiber: list[ConvertFiberOrientationsFiberParameters] | None = None,
    runner: Runner | None = None,
) -> ConvertFiberOrientationsOutputs:
    """
    convert-fiber-orientations
    
    Convert bingham parameter volumes to fiber orientation file.
    
    Takes precomputed bingham parameters from volume files and converts them to
    the format workbench uses for display. The <label-volume> argument must be a
    label volume, where the labels use these strings:
    
    
    CORTEX_LEFT
    CORTEX_RIGHT
    CEREBELLUM
    ACCUMBENS_LEFT
    ACCUMBENS_RIGHT
    ALL_GREY_MATTER
    ALL_WHITE_MATTER
    AMYGDALA_LEFT
    AMYGDALA_RIGHT
    BRAIN_STEM
    CAUDATE_LEFT
    CAUDATE_RIGHT
    CEREBELLAR_WHITE_MATTER_LEFT
    CEREBELLAR_WHITE_MATTER_RIGHT
    CEREBELLUM_LEFT
    CEREBELLUM_RIGHT
    CEREBRAL_WHITE_MATTER_LEFT
    CEREBRAL_WHITE_MATTER_RIGHT
    CORTEX
    DIENCEPHALON_VENTRAL_LEFT
    DIENCEPHALON_VENTRAL_RIGHT
    HIPPOCAMPUS_LEFT
    HIPPOCAMPUS_RIGHT
    INVALID
    OTHER
    OTHER_GREY_MATTER
    OTHER_WHITE_MATTER
    PALLIDUM_LEFT
    PALLIDUM_RIGHT
    PUTAMEN_LEFT
    PUTAMEN_RIGHT
    THALAMUS_LEFT
    THALAMUS_RIGHT.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        label_volume: volume of cifti structure labels.
        fiber_out: the output fiber orientation file.
        fiber: specify the parameter volumes for a fiber.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ConvertFiberOrientationsOutputs`).
    """
    params = convert_fiber_orientations_params(
        label_volume=label_volume,
        fiber_out=fiber_out,
        fiber=fiber,
    )
    return convert_fiber_orientations_execute(params, runner)


__all__ = [
    "CONVERT_FIBER_ORIENTATIONS_METADATA",
    "ConvertFiberOrientationsOutputs",
    "convert_fiber_orientations",
    "convert_fiber_orientations_execute",
    "convert_fiber_orientations_fiber_params",
    "convert_fiber_orientations_params",
]
