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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_CA_TRAIN_METADATA = Metadata(
    id="432e0861913c8c1346f736846e22c0107ee5337f.boutiques",
    name="mri_ca_train",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriCaTrainOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_ca_train(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def mri_ca_train(
    subjects: list[str],
    output_gca: str,
    segmentation: str,
    transform: str | None = None,
    mask_volume: str | None = None,
    node_spacing: str | None = None,
    prior_spacing: str | None = None,
    input_training: list[str] | None = None,
    makesym: list[str] | None = None,
    check_symmetry: list[str] | None = None,
    sanity_check: bool = False,
    threads: int | None = None,
    done_file: str | None = None,
    runner: Runner | None = None,
) -> MriCaTrainOutputs:
    """
    Trains GCA data with multiple subjects using provided segmentation volumes and
    other configuration.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subjects: List of subject directories under the SUBJECTS_DIR. Each is a\
            path relative to the subject's MRI directory.
        output_gca: Output GCA file name.
        segmentation: Segmentation volume directory relative to each subject's\
            MRI path.
        transform: Atlas transform path relative to each subject's MRI\
            transforms directory.
        mask_volume: Volume name used as a mask, path relative to each\
            subject's MRI directory.
        node_spacing: Spacing of classifiers in canonical space.
        prior_spacing: Spacing of class priors in canonical space.
        input_training: Specifying training data, path relative to each\
            subject's MRI directory. Can specify multiple inputs.
        makesym: Symmetrize an already existing atlas. Specify input GCA and\
            symmetrized GCA.
        check_symmetry: Check the symmetry of an already existing atlas.\
            Specify input GCA and symmetrized GCA.
        sanity_check: Conduct sanity-check of labels for obvious edit errors.
        threads: Specify number of threads to use (also known as -nthreads).
        done_file: Create DoneFile when done (contents: 0=ok, 1=error).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriCaTrainOutputs`).
    """
    if not (1 <= len(subjects)): 
        raise ValueError(f"Length of 'subjects' must be greater than 1 but was {len(subjects)}")
    if makesym is not None and not (len(makesym) <= 2): 
        raise ValueError(f"Length of 'makesym' must be less than 2 but was {len(makesym)}")
    if check_symmetry is not None and not (len(check_symmetry) <= 2): 
        raise ValueError(f"Length of 'check_symmetry' must be less than 2 but was {len(check_symmetry)}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_CA_TRAIN_METADATA)
    cargs = []
    cargs.append("mri_ca_train")
    cargs.extend(subjects)
    cargs.append(output_gca)
    cargs.extend([
        "-seg",
        segmentation
    ])
    if transform is not None:
        cargs.extend([
            "-xform",
            transform
        ])
    if mask_volume is not None:
        cargs.extend([
            "-mask",
            mask_volume
        ])
    if node_spacing is not None:
        cargs.extend([
            "-node_spacing",
            node_spacing
        ])
    if prior_spacing is not None:
        cargs.extend([
            "-prior_spacing",
            prior_spacing
        ])
    if input_training is not None:
        cargs.extend([
            "-input",
            *input_training
        ])
    if makesym is not None:
        cargs.extend([
            "-makesym",
            *makesym
        ])
    if check_symmetry is not None:
        cargs.extend([
            "-checksym",
            *check_symmetry
        ])
    if sanity_check:
        cargs.append("-check")
    if threads is not None:
        cargs.extend([
            "-threads",
            str(threads)
        ])
    if done_file is not None:
        cargs.extend([
            "-done",
            done_file
        ])
    ret = MriCaTrainOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_CA_TRAIN_METADATA",
    "MriCaTrainOutputs",
    "mri_ca_train",
]
