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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_FUSE_SEGMENTATIONS_METADATA = Metadata(
    id="b42ea2ffd32b62f852b2f074e21005b3ac5e5519.boutiques",
    name="mri_fuse_segmentations",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriFuseSegmentationsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_fuse_segmentations(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Resulting fused segmentation as aseg.fused.mgz file"""


def mri_fuse_segmentations(
    asegs: list[InputPathType],
    nocc_asegs: list[InputPathType],
    norm_volumes: list[InputPathType],
    input_file: InputPathType,
    transforms: list[InputPathType] | None = None,
    sigma: float | None = 3.0,
    runner: Runner | None = None,
) -> MriFuseSegmentationsOutputs:
    """
    Fuse a set of segmentations (asegs) into an initial estimate of a longitudinal
    one.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        asegs: Path to aseg.mgz files, one per TP.
        nocc_asegs: Path to aseg.auto_noCCseg.mgz files without CC labels, one\
            per TP.
        norm_volumes: Path to norm.mgz files, one per TP.
        input_file: Input norm.mgz file.
        transforms: Transform files from each TP to the input norm.mgz, can be\
            LTA, M3Z or identity.nofile.
        sigma: Cross-time sigma (default 3.0).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriFuseSegmentationsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_FUSE_SEGMENTATIONS_METADATA)
    cargs = []
    cargs.append("mri_fuse_segmentations")
    cargs.extend([
        "-a",
        *[execution.input_file(f) for f in asegs]
    ])
    cargs.extend([
        "-c",
        *[execution.input_file(f) for f in nocc_asegs]
    ])
    cargs.extend([
        "-n",
        *[execution.input_file(f) for f in norm_volumes]
    ])
    if transforms is not None:
        cargs.extend([
            "-t",
            *[execution.input_file(f) for f in transforms]
        ])
    if sigma is not None:
        cargs.extend([
            "-s",
            str(sigma)
        ])
    cargs.append(execution.input_file(input_file))
    cargs.append("[OUTPUT]")
    ret = MriFuseSegmentationsOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file("[OUTPUT]"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_FUSE_SEGMENTATIONS_METADATA",
    "MriFuseSegmentationsOutputs",
    "mri_fuse_segmentations",
]
