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

import typing
import pathlib
from styxdefs import *
import dataclasses

REGISTER_ELDERLY_SUBJECT_METADATA = Metadata(
    id="537220baa60ce5febcf14be16d4b791c3cbbebb9.boutiques",
    name="register_elderly_subject",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class RegisterElderlySubjectOutputs(typing.NamedTuple):
    """
    Output object returned when calling `register_elderly_subject(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    transformed_fsamples_output: OutputPathType
    """Transformed control points output"""
    normalized_volume_output: OutputPathType
    """Intensity normalized volume"""


def register_elderly_subject(
    output_fsamples: str,
    output_norm: str,
    input_volume: InputPathType,
    gca_file: InputPathType,
    transform_file: InputPathType,
    sampling_percentage: float | None = 0.5,
    runner: Runner | None = None,
) -> RegisterElderlySubjectOutputs:
    """
    Tool for registering MRI images of elderly subjects using Freesurfer's
    mri_em_register.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        output_fsamples: Output path for transformed control points.
        output_norm: Output path for intensity normalized volume.
        input_volume: Input MRI volume to register.
        gca_file: GCA file for registration.
        transform_file: Output transform file.
        sampling_percentage: Percentage of white matter points to use as\
            control points.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `RegisterElderlySubjectOutputs`).
    """
    if sampling_percentage is not None and not (0 <= sampling_percentage <= 1): 
        raise ValueError(f"'sampling_percentage' must be between 0 <= x <= 1 but was {sampling_percentage}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(REGISTER_ELDERLY_SUBJECT_METADATA)
    cargs = []
    cargs.append("mri_em_register")
    if sampling_percentage is not None:
        cargs.extend([
            "-p",
            str(sampling_percentage)
        ])
    cargs.extend([
        "-fsamples",
        output_fsamples
    ])
    cargs.extend([
        "-norm",
        output_norm
    ])
    cargs.append(execution.input_file(input_volume))
    cargs.append(execution.input_file(gca_file))
    cargs.append(execution.input_file(transform_file))
    ret = RegisterElderlySubjectOutputs(
        root=execution.output_file("."),
        transformed_fsamples_output=execution.output_file(output_fsamples),
        normalized_volume_output=execution.output_file(output_norm),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "REGISTER_ELDERLY_SUBJECT_METADATA",
    "RegisterElderlySubjectOutputs",
    "register_elderly_subject",
]
