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

import typing
import pathlib
from styxdefs import *
import dataclasses

WMSASEG_METADATA = Metadata(
    id="70413a8a1c01bd4a41bdede39664427061f28431.boutiques",
    name="wmsaseg",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class WmsasegOutputs(typing.NamedTuple):
    """
    Output object returned when calling `wmsaseg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    t1_canorm: OutputPathType | None
    """CA normalized T1 output"""
    wmsa_lta: OutputPathType | None
    """Linear transform to average space"""


def wmsaseg(
    subject: str,
    source_orig: str | None = None,
    source_long: bool = False,
    output_subdir: str | None = None,
    gca_file: InputPathType | None = None,
    no_reg: bool = False,
    no_canorm: bool = False,
    init_spm: bool = False,
    reg_only: bool = False,
    halo1: bool = False,
    halo2: bool = False,
    runner: Runner | None = None,
) -> WmsasegOutputs:
    """
    White Matter Hyperintensity Segmentation Tool.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: Subject identifier.
        source_orig: Use T2 and PD images from original subject.
        source_long: Use T2 and PD images from longitudinal subject.
        output_subdir: Output subdirectory name (default is wmsa).
        gca_file: GCA file path.
        no_reg: Do not register mode to anatomical image.
        no_canorm: Do not run mri_ca_normalize.
        init_spm: Initialize SPM (default is FSL).
        reg_only: Only perform registration.
        halo1: Halo 1 option.
        halo2: Halo 2 option.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `WmsasegOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(WMSASEG_METADATA)
    cargs = []
    cargs.append("wmsaseg")
    cargs.extend([
        "-s",
        "-" + subject
    ])
    if source_orig is not None:
        cargs.extend([
            "--s+orig",
            source_orig
        ])
    if source_long:
        cargs.append("--s+long")
    if output_subdir is not None:
        cargs.extend([
            "--sub",
            output_subdir
        ])
    if gca_file is not None:
        cargs.extend([
            "--gca",
            execution.input_file(gca_file)
        ])
    if no_reg:
        cargs.append("--no-reg")
    if no_canorm:
        cargs.append("--no-canorm")
    if init_spm:
        cargs.append("--init-spm")
    if reg_only:
        cargs.append("--reg-only")
    if halo1:
        cargs.append("--halo1")
    if halo2:
        cargs.append("--halo2")
    ret = WmsasegOutputs(
        root=execution.output_file("."),
        t1_canorm=execution.output_file(output_subdir + "/T1.canorm.mgz") if (output_subdir is not None) else None,
        wmsa_lta=execution.output_file(output_subdir + "/wmsa.lta") if (output_subdir is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "WMSASEG_METADATA",
    "WmsasegOutputs",
    "wmsaseg",
]
