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

import typing
import pathlib
from styxdefs import *
import dataclasses

TENSOR2METRIC_METADATA = Metadata(
    id="ce3b6c1eb5966c84af85ddfef969868689c115fb.boutiques",
    name="tensor2metric",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


@dataclasses.dataclass
class Tensor2metricConfig:
    """
    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 Tensor2metricOutputs(typing.NamedTuple):
    """
    Output object returned when calling `tensor2metric(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    adc: OutputPathType | None
    """compute the mean apparent diffusion coefficient (ADC) of the diffusion
    tensor. (sometimes also referred to as the mean diffusivity (MD)) """
    fa: OutputPathType | None
    """compute the fractional anisotropy (FA) of the diffusion tensor. """
    ad: OutputPathType | None
    """compute the axial diffusivity (AD) of the diffusion tensor. (equivalent
    to the principal eigenvalue) """
    rd: OutputPathType | None
    """compute the radial diffusivity (RD) of the diffusion tensor. (equivalent
    to the mean of the two non-principal eigenvalues) """
    cl: OutputPathType | None
    """compute the linearity metric of the diffusion tensor. (one of the three
    Westin shape metrics) """
    cp: OutputPathType | None
    """compute the planarity metric of the diffusion tensor. (one of the three
    Westin shape metrics) """
    cs: OutputPathType | None
    """compute the sphericity metric of the diffusion tensor. (one of the three
    Westin shape metrics) """
    value: OutputPathType | None
    """compute the selected eigenvalue(s) of the diffusion tensor. """
    vector: OutputPathType | None
    """compute the selected eigenvector(s) of the diffusion tensor. """


def tensor2metric(
    tensor: InputPathType,
    adc: str | None = None,
    fa: str | None = None,
    ad: str | None = None,
    rd: str | None = None,
    cl: str | None = None,
    cp: str | None = None,
    cs: str | None = None,
    value: str | None = None,
    vector: str | None = None,
    num: list[int] | None = None,
    modulate: str | None = None,
    mask: InputPathType | None = None,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[Tensor2metricConfig] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> Tensor2metricOutputs:
    """
    Generate maps of tensor-derived parameters.
    
    
    
    References:
    
    Basser, P. J.; Mattiello, J. & Lebihan, D. MR diffusion tensor spectroscopy
    and imaging. Biophysical Journal, 1994, 66, 259-267
    
    Westin, C. F.; Peled, S.; Gudbjartsson, H.; Kikinis, R. & Jolesz, F. A.
    Geometrical diffusion measures for MRI from tensor basis analysis. Proc Intl
    Soc Mag Reson Med, 1997, 5, 1742.
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        tensor: the input tensor image.
        adc: compute the mean apparent diffusion coefficient (ADC) of the\
            diffusion tensor. (sometimes also referred to as the mean diffusivity\
            (MD)).
        fa: compute the fractional anisotropy (FA) of the diffusion tensor.
        ad: compute the axial diffusivity (AD) of the diffusion tensor.\
            (equivalent to the principal eigenvalue).
        rd: compute the radial diffusivity (RD) of the diffusion tensor.\
            (equivalent to the mean of the two non-principal eigenvalues).
        cl: compute the linearity metric of the diffusion tensor. (one of the\
            three Westin shape metrics).
        cp: compute the planarity metric of the diffusion tensor. (one of the\
            three Westin shape metrics).
        cs: compute the sphericity metric of the diffusion tensor. (one of the\
            three Westin shape metrics).
        value: compute the selected eigenvalue(s) of the diffusion tensor.
        vector: compute the selected eigenvector(s) of the diffusion tensor.
        num: specify the desired eigenvalue/eigenvector(s). Note that several\
            eigenvalues can be specified as a number sequence. For example, '1,3'\
            specifies the principal (1) and minor (3) eigenvalues/eigenvectors\
            (default = 1).
        modulate: specify how to modulate the magnitude of the eigenvectors.\
            Valid choices are: none, FA, eigval (default = FA).
        mask: only perform computation within the specified binary brain mask\
            image.
        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 `Tensor2metricOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(TENSOR2METRIC_METADATA)
    cargs = []
    cargs.append("tensor2metric")
    if adc is not None:
        cargs.extend([
            "-adc",
            adc
        ])
    if fa is not None:
        cargs.extend([
            "-fa",
            fa
        ])
    if ad is not None:
        cargs.extend([
            "-ad",
            ad
        ])
    if rd is not None:
        cargs.extend([
            "-rd",
            rd
        ])
    if cl is not None:
        cargs.extend([
            "-cl",
            cl
        ])
    if cp is not None:
        cargs.extend([
            "-cp",
            cp
        ])
    if cs is not None:
        cargs.extend([
            "-cs",
            cs
        ])
    if value is not None:
        cargs.extend([
            "-value",
            value
        ])
    if vector is not None:
        cargs.extend([
            "-vector",
            vector
        ])
    if num is not None:
        cargs.extend([
            "-num",
            *map(str, num)
        ])
    if modulate is not None:
        cargs.extend([
            "-modulate",
            modulate
        ])
    if mask is not None:
        cargs.extend([
            "-mask",
            execution.input_file(mask)
        ])
    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(tensor))
    ret = Tensor2metricOutputs(
        root=execution.output_file("."),
        adc=execution.output_file(adc) if (adc is not None) else None,
        fa=execution.output_file(fa) if (fa is not None) else None,
        ad=execution.output_file(ad) if (ad is not None) else None,
        rd=execution.output_file(rd) if (rd is not None) else None,
        cl=execution.output_file(cl) if (cl is not None) else None,
        cp=execution.output_file(cp) if (cp is not None) else None,
        cs=execution.output_file(cs) if (cs is not None) else None,
        value=execution.output_file(value) if (value is not None) else None,
        vector=execution.output_file(vector) if (vector is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "TENSOR2METRIC_METADATA",
    "Tensor2metricConfig",
    "Tensor2metricOutputs",
    "tensor2metric",
]
