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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSL_ENTS_METADATA = Metadata(
    id="f66a5a56bce20baecbbcffc7deaf985412131450.boutiques",
    name="fsl_ents",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class FslEntsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fsl_ents(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    out_time_series: OutputPathType | None
    """File to save time series to"""


def fsl_ents(
    icadir: str,
    components: list[str],
    outfile: InputPathType | None = None,
    overwrite: bool = False,
    conffile: list[InputPathType] | None = None,
    runner: Runner | None = None,
) -> FslEntsOutputs:
    """
    Extract component time series from a MELODIC .ica directory.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        icadir: .ica directory to extract time series from.
        components: Component number or FIX/AROMA file specifying components to\
            extract.
        outfile: File to save time series to.
        overwrite: Overwrite output file if it exists.
        conffile: Extra files to append to output file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslEntsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSL_ENTS_METADATA)
    cargs = []
    cargs.append("fsl_ents")
    cargs.append(icadir)
    cargs.extend(components)
    if outfile is not None:
        cargs.extend([
            "-o",
            execution.input_file(outfile)
        ])
    if overwrite:
        cargs.append("-ow")
    if conffile is not None:
        cargs.extend([
            "-c",
            *[execution.input_file(f) for f in conffile]
        ])
    cargs.append("[-h]")
    ret = FslEntsOutputs(
        root=execution.output_file("."),
        out_time_series=execution.output_file(pathlib.Path(outfile).name) if (outfile is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSL_ENTS_METADATA",
    "FslEntsOutputs",
    "fsl_ents",
]
