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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRMETRIC_METADATA = Metadata(
    id="68993bab707571cc9c043c8d06d2a16330445585.boutiques",
    name="mrmetric",
    package="mrtrix",
    container_image_tag="mrtrix3/mrtrix3:3.0.4",
)


@dataclasses.dataclass
class MrmetricConfig:
    """
    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 MrmetricOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mrmetric(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mrmetric(
    image1: InputPathType,
    image2: InputPathType,
    space: str | None = None,
    interp: str | None = None,
    metric: str | None = None,
    mask1: InputPathType | None = None,
    mask2: InputPathType | None = None,
    nonormalisation: bool = False,
    overlap: bool = False,
    info: bool = False,
    quiet: bool = False,
    debug: bool = False,
    force: bool = False,
    nthreads: int | None = None,
    config: list[MrmetricConfig] | None = None,
    help_: bool = False,
    version: bool = False,
    runner: Runner | None = None,
) -> MrmetricOutputs:
    """
    Computes a dissimilarity metric between two images.
    
    Currently only the mean squared difference is fully implemented.
    
    References:
    
    .
    
    Author: MRTrix3 Developers
    
    URL: https://www.mrtrix.org/
    
    Args:
        image1: the first input image.
        image2: the second input image.
        space: voxel (default): per voxel image1: scanner space of image 1\
            image2: scanner space of image 2 average: scanner space of the average\
            affine transformation of image 1 and 2.
        interp: set the interpolation method to use when reslicing (choices:\
            nearest, linear, cubic, sinc. Default: linear).
        metric: define the dissimilarity metric used to calculate the cost.\
            Choices: diff (squared differences), cc (non-normalised negative cross\
            correlation aka negative cross covariance). Default: diff). cc is only\
            implemented for -space average and -interp linear and cubic.
        mask1: mask for image 1.
        mask2: mask for image 2.
        nonormalisation: do not normalise the dissimilarity metric to the\
            number of voxels.
        overlap: output number of voxels that were used.
        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 `MrmetricOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRMETRIC_METADATA)
    cargs = []
    cargs.append("mrmetric")
    if space is not None:
        cargs.extend([
            "-space",
            space
        ])
    if interp is not None:
        cargs.extend([
            "-interp",
            interp
        ])
    if metric is not None:
        cargs.extend([
            "-metric",
            metric
        ])
    if mask1 is not None:
        cargs.extend([
            "-mask1",
            execution.input_file(mask1)
        ])
    if mask2 is not None:
        cargs.extend([
            "-mask2",
            execution.input_file(mask2)
        ])
    if nonormalisation:
        cargs.append("-nonormalisation")
    if overlap:
        cargs.append("-overlap")
    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(image1))
    cargs.append(execution.input_file(image2))
    ret = MrmetricOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRMETRIC_METADATA",
    "MrmetricConfig",
    "MrmetricOutputs",
    "mrmetric",
]
