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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_MOTION_CORRECT2_METADATA = Metadata(
    id="a581289aa8203d417a44a5b02cbe1c9a50b8b234.boutiques",
    name="mri_motion_correct2",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriMotionCorrect2Outputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_motion_correct2(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """The aligned and averaged output file or directory"""


def mri_motion_correct2(
    output_spec: str,
    input_files: list[InputPathType],
    target: InputPathType | None = None,
    wild: bool = False,
    tmp_dir: str | None = None,
    nocleanup: bool = False,
    umask: str | None = None,
    cm: bool = False,
    version: bool = False,
    debug: bool = False,
    runner: Runner | None = None,
) -> MriMotionCorrect2Outputs:
    """
    Aligns and averages two or more volumes using minctracc for alignment and
    mincresample and mincaverage for resampling.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        output_spec: Output file or directory (for COR format).
        input_files: Input volume files, specified multiple times for multiple\
            files.
        target: Use the specified target instead of the first input file.
        wild: Assume unmatched arguments are input files.
        tmp_dir: Directory for temporary files.
        nocleanup: Do not delete temporary files.
        umask: Set UNIX file permission mask.
        cm: Make COR volumes conform to minimum voxel size.
        version: Print version information and exit.
        debug: Print detailed debug information to screen.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriMotionCorrect2Outputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_MOTION_CORRECT2_METADATA)
    cargs = []
    cargs.append("mri_motion_correct2")
    cargs.extend([
        "-o",
        output_spec
    ])
    cargs.extend([
        "-i",
        *[execution.input_file(f) for f in input_files]
    ])
    if target is not None:
        cargs.extend([
            "-t",
            execution.input_file(target)
        ])
    if wild:
        cargs.append("-wild")
    if tmp_dir is not None:
        cargs.extend([
            "-tmpdir",
            tmp_dir
        ])
    if nocleanup:
        cargs.append("-nocleanup")
    if umask is not None:
        cargs.extend([
            "-umask",
            umask
        ])
    if cm:
        cargs.append("-cm")
    if version:
        cargs.append("-version")
    if debug:
        cargs.append("-debug")
    ret = MriMotionCorrect2Outputs(
        root=execution.output_file("."),
        output_file=execution.output_file(output_spec),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_MOTION_CORRECT2_METADATA",
    "MriMotionCorrect2Outputs",
    "mri_motion_correct2",
]
