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

import typing
import pathlib
from styxdefs import *
import dataclasses

SHCONV_METADATA = Metadata(
    id="3c84c5743ea66d880048dc5dc975db440966a75e.boutiques",
    name="shconv",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


@dataclasses.dataclass
class ShconvVariousString:
    obj: str
    """String object."""
    
    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(self.obj)
        return cargs


@dataclasses.dataclass
class ShconvVariousFile:
    obj: InputPathType
    """File object."""
    
    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.obj))
        return cargs


@dataclasses.dataclass
class ShconvConfig:
    """
    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 ShconvOutputs(typing.NamedTuple):
    """
    Output object returned when calling `shconv(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    sh_out: OutputPathType
    """the output spherical harmonics coefficients image."""


def shconv(
    odf_response: list[str],
    sh_out: str,
    datatype: str | None = None,
    strides: typing.Union[ShconvVariousString, ShconvVariousFile] | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[ShconvConfig] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> ShconvOutputs:
    """
    Perform spherical convolution.
    
    Provided with matching pairs of response function and ODF images (containing
    SH coefficients), perform spherical convolution to provide the corresponding
    SH coefficients of the signal.
    
    If multiple pairs of inputs are provided, their contributions will be summed
    into a single output.
    
    If the responses are multi-shell (with one line of coefficients per shell),
    the output will be a 5-dimensional image, with the SH coefficients of the
    signal in each shell stored at different indices along the 5th dimension.
    
    The spherical harmonic coefficients are stored according the conventions
    described the main documentation, which can be found at the following link:
    https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
    
    The spherical harmonic coefficients are stored according the conventions
    described the main documentation, which can be found at the following link:
    https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        odf_response: pairs of input ODF image and corresponding responses.
        sh_out: the output spherical harmonics coefficients image.
        datatype: specify output image data type. Valid choices are: float32,\
            float32le, float32be, float64, float64le, float64be, int64, uint64,\
            int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
            int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
            cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
            int8, uint8, bit.
        strides: specify the strides of the output data in memory; either as a\
            comma-separated list of (signed) integers, or as a template image from\
            which the strides shall be extracted and used. The actual strides\
            produced will depend on whether the output image format can support it.
        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 `ShconvOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SHCONV_METADATA)
    cargs = []
    cargs.append("shconv")
    if datatype is not None:
        cargs.extend([
            "-datatype",
            datatype
        ])
    if strides is not None:
        cargs.extend([
            "-strides",
            *strides.run(execution)
        ])
    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.extend(odf_response)
    cargs.append(sh_out)
    ret = ShconvOutputs(
        root=execution.output_file("."),
        sh_out=execution.output_file(sh_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SHCONV_METADATA",
    "ShconvConfig",
    "ShconvOutputs",
    "ShconvVariousFile",
    "ShconvVariousString",
    "shconv",
]
