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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_VOL2SURF_METADATA = Metadata(
    id="9b1f4f0a610312351db96a33b3de116be9ef57ae.boutiques",
    name="mri_vol2surf",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriVol2surfOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_vol2surf(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    resampled_volume_output: OutputPathType
    """Output file containing the resampled volume onto the surface"""


def mri_vol2surf(
    input_volume: InputPathType,
    registration_file: InputPathType,
    output_path: str,
    reference_volume: str | None = None,
    regheader_subject: str | None = None,
    mni152reg_flag: bool = False,
    target_subject: str | None = None,
    hemisphere: typing.Literal["lh", "rh"] | None = None,
    surface: str | None = None,
    runner: Runner | None = None,
) -> MriVol2surfOutputs:
    """
    This program resamples a volume onto a surface of a subject or the sphere. The
    output can be viewed on the surface (using tksurfer) or can be used for
    surface-based intersubject averaging.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        input_volume: Path to input volume file.
        registration_file: Registration file as computed by tkregister,\
            spmregister, bbregister, etc.
        output_path: Output path for the resampled volume.
        reference_volume: Reference volume name, default is orig.mgz.
        regheader_subject: Compute registration from header information,\
            aligning the current volume with the subject/mri/orig.mgz.
        mni152reg_flag: Use MNI152 registration:\
            $FREESURFER_HOME/average/mni152.register.dat.
        target_subject: Target subject for resampling, can be a subject name or\
            'ico' for icosahedron.
        hemisphere: Hemisphere to process: lh = left hemisphere or rh = right\
            hemisphere.
        surface: Target surface on which to resample, default is 'white'.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriVol2surfOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_VOL2SURF_METADATA)
    cargs = []
    cargs.append("mri_vol2surf")
    cargs.extend([
        "--mov",
        execution.input_file(input_volume)
    ])
    cargs.extend([
        "--reg",
        execution.input_file(registration_file)
    ])
    cargs.extend([
        "--o",
        output_path
    ])
    if reference_volume is not None:
        cargs.extend([
            "--ref",
            reference_volume
        ])
    if regheader_subject is not None:
        cargs.extend([
            "--regheader",
            regheader_subject
        ])
    if mni152reg_flag:
        cargs.append("--mni152reg")
    if target_subject is not None:
        cargs.extend([
            "--trgsubject",
            target_subject
        ])
    if hemisphere is not None:
        cargs.extend([
            "--hemi",
            hemisphere
        ])
    if surface is not None:
        cargs.extend([
            "--surf",
            surface
        ])
    ret = MriVol2surfOutputs(
        root=execution.output_file("."),
        resampled_volume_output=execution.output_file(output_path),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_VOL2SURF_METADATA",
    "MriVol2surfOutputs",
    "mri_vol2surf",
]
