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

import typing
import pathlib
from styxdefs import *
import dataclasses

TCKSTATS_METADATA = Metadata(
    id="2e6f7d19387564d069ab548694fef288498b97ad.boutiques",
    name="tckstats",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


@dataclasses.dataclass
class TckstatsOutput:
    """
    output only the field specified. Multiple such options can be supplied if
    required. Choices are: mean, median, std, min, max, count. Useful for use in
    scripts.
    """
    field: str
    """output only the field specified. Multiple such options can be supplied if
    required. Choices are: mean, median, std, min, max, count. Useful for use in
    scripts."""
    
    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("-output")
        cargs.append(self.field)
        return cargs


@dataclasses.dataclass
class TckstatsConfig:
    """
    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 TckstatsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `tckstats(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    histogram: OutputPathType | None
    """output a histogram of streamline lengths """
    dump: OutputPathType | None
    """dump the streamlines lengths to a text file """


def tckstats(
    tracks_in: InputPathType,
    output: list[TckstatsOutput] | None = None,
    histogram: str | None = None,
    dump: str | None = None,
    ignorezero: bool = False,
    tck_weights_in: InputPathType | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[TckstatsConfig] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> TckstatsOutputs:
    """
    Calculate statistics on streamlines lengths.
    
    
    
    References:
    
    .
    
    Author: Robert E. Smith (robert.smith@florey.edu.au)
    
    URL:
    https://mrtrix.readthedocs.io/en/latest/reference/commands/tckstats.html
    
    Args:
        tracks_in: the input track file.
        output: output only the field specified. Multiple such options can be\
            supplied if required. Choices are: mean, median, std, min, max, count.\
            Useful for use in scripts.
        histogram: output a histogram of streamline lengths.
        dump: dump the streamlines lengths to a text file.
        ignorezero: do not generate a warning if the track file contains\
            streamlines with zero length.
        tck_weights_in: specify a text scalar file containing the streamline\
            weights.
        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 `TckstatsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(TCKSTATS_METADATA)
    cargs = []
    cargs.append("tckstats")
    if output is not None:
        cargs.extend([a for c in [s.run(execution) for s in output] for a in c])
    if histogram is not None:
        cargs.extend([
            "-histogram",
            histogram
        ])
    if dump is not None:
        cargs.extend([
            "-dump",
            dump
        ])
    if ignorezero:
        cargs.append("-ignorezero")
    if tck_weights_in is not None:
        cargs.extend([
            "-tck_weights_in",
            execution.input_file(tck_weights_in)
        ])
    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(tracks_in))
    ret = TckstatsOutputs(
        root=execution.output_file("."),
        histogram=execution.output_file(histogram) if (histogram is not None) else None,
        dump=execution.output_file(dump) if (dump is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "TCKSTATS_METADATA",
    "TckstatsConfig",
    "TckstatsOutput",
    "TckstatsOutputs",
    "tckstats",
]
