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

import typing
import pathlib
from styxdefs import *
import dataclasses

RESPONSEMEAN_METADATA = Metadata(
    id="a8fd34348625b3b1fa9e865a3af1f57c9158d343.boutiques",
    name="responsemean",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


class ResponsemeanOutputs(typing.NamedTuple):
    """
    Output object returned when calling `responsemean(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_response_file: OutputPathType
    """File containing the averaged tissue response function"""


def responsemean(
    input_response: list[InputPathType],
    output_response: InputPathType,
    legacy: bool = False,
    nocleanup: bool = False,
    scratch_dir: InputPathType | None = None,
    continue_scratch_dir: list[InputPathType] | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: float | None = None,
    config: list[str] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> ResponsemeanOutputs:
    """
    Calculate the mean response function from a set of text files.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        input_response: Input response functions.
        output_response: Output mean response function.
        legacy: Calculate the mean response function from a set of text files.
        nocleanup: Do not delete intermediate files during script execution,\
            and do not delete scratch directory at script completion.
        scratch_dir: Manually specify the path in which to generate the scratch\
            directory.
        continue_scratch_dir: Continue the script from a previous execution;\
            must provide the scratch directory path.
        info: Display information messages.
        quiet: Do not display information messages or progress status.
        debug: Display debugging messages.
        force: Force overwrite of output files.
        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 help information and exit.
        version: Display version information and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ResponsemeanOutputs`).
    """
    if continue_scratch_dir is not None and (len(continue_scratch_dir) != 2): 
        raise ValueError(f"Length of 'continue_scratch_dir' must be 2 but was {len(continue_scratch_dir)}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(RESPONSEMEAN_METADATA)
    cargs = []
    cargs.append("responsemean")
    cargs.extend([execution.input_file(f) for f in input_response])
    cargs.append(execution.input_file(output_response))
    if legacy:
        cargs.append("-legacy")
    if nocleanup:
        cargs.append("-nocleanup")
    if scratch_dir is not None:
        cargs.extend([
            "-scratch",
            execution.input_file(scratch_dir)
        ])
    if continue_scratch_dir is not None:
        cargs.extend([
            "-continue",
            *[execution.input_file(f) for f in continue_scratch_dir]
        ])
    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([
            "-config",
            *config
        ])
    if help_:
        cargs.append("-help")
    if version:
        cargs.append("-version")
    ret = ResponsemeanOutputs(
        root=execution.output_file("."),
        output_response_file=execution.output_file(pathlib.Path(output_response).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "RESPONSEMEAN_METADATA",
    "ResponsemeanOutputs",
    "responsemean",
]
