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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_RESAMPLE_METADATA = Metadata(
    id="58c882ffaf4fe37d2d5aa57751a90cb1600aab80.boutiques",
    name="mris_resample",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisResampleOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_resample(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    resampled_surface_output: OutputPathType
    """Resampled surface output"""
    resampled_annotation_output: OutputPathType | None
    """Output annotation for the resampled atlas"""


def mris_resample(
    atlas_reg: InputPathType,
    subject_reg: InputPathType,
    subject_surf: InputPathType,
    output: InputPathType,
    annot_in: InputPathType | None = None,
    annot_out: InputPathType | None = None,
    runner: Runner | None = None,
) -> MrisResampleOutputs:
    """
    Resample cortical surfaces in FreeSurfer.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        atlas_reg: Atlas spherical registration file.
        subject_reg: Subject spherical registration file.
        subject_surf: Subject actual surface.
        output: Output resampled surface.
        annot_in: Input annotation (for the subject). If present, output\
            annotation must be present as well.
        annot_out: Output annotation (for the resampled atlas). If present,\
            input annotation must be present as well.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisResampleOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_RESAMPLE_METADATA)
    cargs = []
    cargs.append("mris_resample")
    cargs.extend([
        "-atlas_reg",
        execution.input_file(atlas_reg)
    ])
    cargs.extend([
        "-subject_reg",
        execution.input_file(subject_reg)
    ])
    cargs.extend([
        "-subject_surf",
        execution.input_file(subject_surf)
    ])
    cargs.extend([
        "-out",
        execution.input_file(output)
    ])
    if annot_in is not None:
        cargs.extend([
            "--annot_in",
            execution.input_file(annot_in)
        ])
    if annot_out is not None:
        cargs.extend([
            "--annot_out",
            execution.input_file(annot_out)
        ])
    ret = MrisResampleOutputs(
        root=execution.output_file("."),
        resampled_surface_output=execution.output_file(pathlib.Path(output).name),
        resampled_annotation_output=execution.output_file(pathlib.Path(annot_out).name) if (annot_out is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_RESAMPLE_METADATA",
    "MrisResampleOutputs",
    "mris_resample",
]
