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

import typing
import pathlib
from styxdefs import *
import dataclasses

SS3T_CSD_BETA1_METADATA = Metadata(
    id="3d7ce53d5c0f3941cd5c3621352793549ea67b37.boutiques",
    name="ss3t_csd_beta1",
    package="mrtrix3tissue",
    container_image_tag="brainlife/3tissue:5.2.8",
)


@dataclasses.dataclass
class Ss3tCsdBeta1Config:
    """
    temporarily set the value of an MRtrix config file entry.
    """
    key: str
    """temporarily set the value of an MRtrix config file entry."""
    value: str
    """temporarily set the value of an MRtrix config file entry."""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-config")
        cargs.append(self.key)
        cargs.append(self.value)
        return cargs


class Ss3tCsdBeta1ResponseOdfOutputs(typing.NamedTuple):
    """
    Output object returned when calling `list[Ss3tCsdBeta1ResponseOdf](...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    odf: OutputPathType
    """output ODF image"""


@dataclasses.dataclass
class Ss3tCsdBeta1ResponseOdf:
    """
    pairs of input tissue response and output ODF images.
    """
    response: InputPathType
    """input tissue response"""
    odf: str
    """output ODF image"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append(execution.input_file(self.response))
        cargs.append(self.odf)
        return cargs
    
    def outputs(
        self,
        execution: Execution,
    ) -> Ss3tCsdBeta1ResponseOdfOutputs:
        """
        Collect output file paths.
        
        Args:
            execution: The execution object.
        Returns:
            NamedTuple of outputs (described in `Ss3tCsdBeta1ResponseOdfOutputs`).
        """
        ret = Ss3tCsdBeta1ResponseOdfOutputs(
            root=execution.output_file("."),
            odf=execution.output_file(self.odf),
        )
        return ret


class Ss3tCsdBeta1Outputs(typing.NamedTuple):
    """
    Output object returned when calling `ss3t_csd_beta1(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    response_odf: list[Ss3tCsdBeta1ResponseOdfOutputs]
    """Outputs from `Ss3tCsdBeta1ResponseOdf`.This is a list of outputs with the
    same length and order as the inputs."""


def ss3t_csd_beta1(
    dwi: InputPathType,
    response_odf: list[Ss3tCsdBeta1ResponseOdf],
    mask: InputPathType | None = None,
    bzero_pct: float | None = None,
    niter: int | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Ss3tCsdBeta1Config] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> Ss3tCsdBeta1Outputs:
    """
    SS3T-CSD: beta 1 implementation
    
    * Dhollander, T. & Connelly, A. A novel iterative approach to reap the
    benefits of multi-tissue CSD from just single-shell (+b=0) diffusion MRI
    data. Proc Intl Soc Mag Reson Med, 2016, 3010.
    
    Author: MRTrix3Tissue Developers
    
    URL: https://3tissue.github.io/
    
    Args:
        dwi: the input diffusion-weighted image.
        response_odf: pairs of input tissue response and output ODF images.
        mask: only perform computation within the specified binary brain mask\
            image.
        bzero_pct: the threshold below which the amplitude of the FOD is\
            assumed to be zero, expressed as an absolute amplitude (default = 0).
        niter: the maximum number of iterations to perform for each voxel\
            (default = 50). Use '-niter 0' for a linear unconstrained spherical\
            deconvolution.
        info: display information messages.
        quiet: do not display information messages or progress status;\
            alternatively, this can be achieved by setting the MRTRIX_QUIET\
            environment variable to a non-empty string.
        debug: display debugging messages.
        force: force overwrite of output files (caution: using the same file as\
            input and output might cause unexpected behaviour).
        nthreads: use this number of threads in multi-threaded applications\
            (set to 0 to disable multi-threading).
        config: temporarily set the value of an MRtrix config file entry.
        help_: display this information page and exit.
        version: display version information and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `Ss3tCsdBeta1Outputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SS3T_CSD_BETA1_METADATA)
    cargs = []
    cargs.append("ss3t_csd_beta1")
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    if bzero_pct is not None:
        cargs.extend([
            "-bzero_pct",
            str(bzero_pct)
        ])
    if niter is not None:
        cargs.extend([
            "-niter",
            str(niter)
        ])
    if info:
        cargs.append("-info")
    if quiet:
        cargs.append("-quiet")
    if debug:
        cargs.append("-debug")
    if force:
        cargs.append("-force")
    if nthreads is not None:
        cargs.extend([
            "-nthreads",
            str(nthreads)
        ])
    if config is not None:
        cargs.extend([a for c in [s.run(execution) for s in config] for a in c])
    if help_:
        cargs.append("-help")
    if version:
        cargs.append("-version")
    cargs.append(execution.input_file(dwi))
    cargs.extend([a for c in [s.run(execution) for s in response_odf] for a in c])
    ret = Ss3tCsdBeta1Outputs(
        root=execution.output_file("."),
        response_odf=[i.outputs(execution) if hasattr(i, "outputs") else None for i in response_odf],
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SS3T_CSD_BETA1_METADATA",
    "Ss3tCsdBeta1Config",
    "Ss3tCsdBeta1Outputs",
    "Ss3tCsdBeta1ResponseOdf",
    "Ss3tCsdBeta1ResponseOdfOutputs",
    "ss3t_csd_beta1",
]
