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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_REFINE_SURFACES_METADATA = Metadata(
    id="afa5fdcf50348032d468a3e07292675e06d5374e.boutiques",
    name="mris_refine_surfaces",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisRefineSurfacesOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_refine_surfaces(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    pial_surface: OutputPathType
    """Refined pial surface for the specified region"""
    white_surface: OutputPathType
    """Refined white matter surface for the specified region"""


def mris_refine_surfaces(
    subject_name: str,
    hemi: str,
    hires_volume: str,
    label_file: str,
    low_to_hires_xfm: str | None = None,
    sdir: str | None = None,
    use_mgz: bool = False,
    suffix: str | None = None,
    runner: Runner | None = None,
) -> MrisRefineSurfacesOutputs:
    """
    Refines cortical surfaces around the region specified by the label file.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject_name: The name of the subject.
        hemi: The hemisphere to process ('lh' for left hemisphere, 'rh' for\
            right hemisphere).
        hires_volume: The high-resolution volume filename.
        label_file: The label file specifying the region to refine.
        low_to_hires_xfm: The optional low to high resolution transform file.
        sdir: Specify the SUBJECTS_DIR.
        use_mgz: Use .mgz volumes.
        suffix: Add specified suffix to the final surfaces.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisRefineSurfacesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_REFINE_SURFACES_METADATA)
    cargs = []
    cargs.append("mris_refine_surfaces")
    cargs.append(subject_name)
    cargs.append(hemi)
    cargs.append(hires_volume)
    cargs.append(label_file)
    if low_to_hires_xfm is not None:
        cargs.append(low_to_hires_xfm)
    if sdir is not None:
        cargs.extend([
            "-sdir",
            sdir
        ])
    if use_mgz:
        cargs.append("-mgz")
    if suffix is not None:
        cargs.extend([
            "-suffix",
            suffix
        ])
    ret = MrisRefineSurfacesOutputs(
        root=execution.output_file("."),
        pial_surface=execution.output_file("$(SUBJECTS_DIR)/" + subject_name + "/surf/" + hemi + ".pialhires"),
        white_surface=execution.output_file("$(SUBJECTS_DIR)/" + subject_name + "/surf/" + hemi + ".whitehires"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_REFINE_SURFACES_METADATA",
    "MrisRefineSurfacesOutputs",
    "mris_refine_surfaces",
]
