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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSL_SBCA_METADATA = Metadata(
    id="199812ccc7fd2828b7a4a8dfec9e624e99e68709.boutiques",
    name="fsl_sbca",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class FslSbcaOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fsl_sbca(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_seed_mask_image: OutputPathType
    """Output seed mask image"""
    output_seed_mask_image_base: OutputPathType
    """Output seed mask image"""
    output_target_time_courses: OutputPathType
    """Output target time courses"""
    output_confound_time_courses: OutputPathType
    """Output confound time courses"""


def fsl_sbca(
    infile: InputPathType,
    seed: InputPathType,
    target: InputPathType,
    out: str,
    reg_flag: bool = False,
    conf_files: list[InputPathType] | None = None,
    seed_data: InputPathType | None = None,
    binarise_flag: bool = False,
    mean_flag: bool = False,
    abs_cc_flag: bool = False,
    order: float | None = None,
    out_seeds_flag: bool = False,
    out_seedmask_flag: bool = False,
    out_ttcs_flag: bool = False,
    out_conf_flag: bool = False,
    verbose_flag: bool = False,
    help_flag: bool = False,
    runner: Runner | None = None,
) -> FslSbcaOutputs:
    """
    Performs seed-based correlation analysis on FMRI data using either a single seed
    coordinate or a seed mask.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        infile: Input file name (4D image file).
        seed: Seed voxel coordinate or file name of seed mask (3D/4D file).
        target: File name of target mask(s) (3D or 4D file).
        out: Output file base name.
        reg_flag: Perform time series regression rather than classification to\
            targets.
        conf_files: File name (or comma-separated list of file names) for\
            confound ASCII text files.
        seed_data: File name of 4D data file for the seed.
        binarise_flag: Binarise spatial maps prior to calculation of time\
            courses.
        mean_flag: Use mean instead of Eigenvariates for calculation of time\
            courses.
        abs_cc_flag: Use maximum absolute value instead of maximum value of the\
            cross-correlations.
        order: Number of Eigenvariates (default 1).
        out_seeds_flag: Output seed mask image as <basename>_seeds.
        out_seedmask_flag: Output seed mask image as <basename>_seedmask.
        out_ttcs_flag: Output target time courses as <basename>_ttc<X>.txt.
        out_conf_flag: Output confound time courses as <basename>_confounds.txt.
        verbose_flag: Switch on diagnostic messages.
        help_flag: Display help text.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslSbcaOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSL_SBCA_METADATA)
    cargs = []
    cargs.append("fsl_sbca")
    cargs.extend([
        "--in",
        execution.input_file(infile)
    ])
    cargs.extend([
        "--seed",
        execution.input_file(seed)
    ])
    cargs.extend([
        "--target",
        execution.input_file(target)
    ])
    cargs.extend([
        "--out",
        out
    ])
    if reg_flag:
        cargs.append("--reg")
    if conf_files is not None:
        cargs.extend([
            "--conf",
            *[execution.input_file(f) for f in conf_files]
        ])
    if seed_data is not None:
        cargs.extend([
            "--seeddata",
            execution.input_file(seed_data)
        ])
    if binarise_flag:
        cargs.append("--bin")
    if mean_flag:
        cargs.append("--mean")
    if abs_cc_flag:
        cargs.append("--abscc")
    if order is not None:
        cargs.extend([
            "--order",
            str(order)
        ])
    if out_seeds_flag:
        cargs.append("--out_seeds")
    if out_seedmask_flag:
        cargs.append("--out_seedmask")
    if out_ttcs_flag:
        cargs.append("--out_ttcs")
    if out_conf_flag:
        cargs.append("--out_conf")
    if verbose_flag:
        cargs.append("-v")
    if help_flag:
        cargs.append("-h")
    ret = FslSbcaOutputs(
        root=execution.output_file("."),
        output_seed_mask_image=execution.output_file(out + "_seeds"),
        output_seed_mask_image_base=execution.output_file(out + "_seedmask"),
        output_target_time_courses=execution.output_file(out + "_ttc<X>.txt"),
        output_confound_time_courses=execution.output_file(out + "_confounds.txt"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSL_SBCA_METADATA",
    "FslSbcaOutputs",
    "fsl_sbca",
]
