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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRIS_SIMULATE_ATROPHY_METADATA = Metadata(
    id="9e01b9ada9b0b4569fbd5e16610a336ed0c78036.boutiques",
    name="mris_simulate_atrophy",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MrisSimulateAtrophyOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mris_simulate_atrophy(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Atrophy simulation output volume."""


def mris_simulate_atrophy(
    subject: str,
    hemi: str,
    label: str,
    atrophy_fraction: float,
    output_volume: InputPathType,
    atrophy_percent: float | None = None,
    noise_level: float | None = None,
    runner: Runner | None = None,
) -> MrisSimulateAtrophyOutputs:
    """
    Simulate atrophy on brain structures.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject: Subject identifier.
        hemi: Hemisphere (e.g. lh or rh).
        label: Label of the brain region.
        atrophy_fraction: Target atrophy fraction.
        output_volume: Output volume file.
        atrophy_percent: Percentage atrophy to simulate of structure.
        noise_level: Gaussian noise level to add.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MrisSimulateAtrophyOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRIS_SIMULATE_ATROPHY_METADATA)
    cargs = []
    cargs.append("mris_simulate_atrophy")
    cargs.append(subject)
    cargs.append(hemi)
    cargs.append(label)
    cargs.append(str(atrophy_fraction))
    cargs.append(execution.input_file(output_volume))
    if atrophy_percent is not None:
        cargs.extend([
            "-a",
            str(atrophy_percent)
        ])
    if noise_level is not None:
        cargs.extend([
            "-n",
            str(noise_level)
        ])
    ret = MrisSimulateAtrophyOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(pathlib.Path(output_volume).name),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRIS_SIMULATE_ATROPHY_METADATA",
    "MrisSimulateAtrophyOutputs",
    "mris_simulate_atrophy",
]
