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

import typing
import pathlib
from styxdefs import *
import dataclasses

SLICETIMER_METADATA = Metadata(
    id="0643001d0af973bc2b812f49825965703708a3cb.boutiques",
    name="slicetimer",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class SlicetimerOutputs(typing.NamedTuple):
    """
    Output object returned when calling `slicetimer(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_timeseries: OutputPathType | None
    """Output timeseries"""


def slicetimer(
    infile: InputPathType,
    outfile: InputPathType | None = None,
    verbose_flag: bool = False,
    down_flag: bool = False,
    tr_value: float | None = None,
    direction: str | None = None,
    odd_flag: bool = False,
    tcustom_file: InputPathType | None = None,
    tglobal_value: float | None = None,
    ocustom_file: InputPathType | None = None,
    runner: Runner | None = None,
) -> SlicetimerOutputs:
    """
    FMRIB's Interpolation for Slice Timing.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        infile: Filename of input timeseries.
        outfile: Filename of output timeseries.
        verbose_flag: Switch on diagnostic messages.
        down_flag: Reverse slice indexing (default is: slices were acquired\
            bottom-up).
        tr_value: Specify TR of data - default is 3s.
        direction: Direction of slice acquisition (x=1,y=2,z=3) - default is z.
        odd_flag: Use interleaved acquisition.
        tcustom_file: Filename of single-column slice timings, in fractions of\
            TR, +ve values shift slices forward in time.
        tglobal_value: Global shift in fraction of TR, (default is 0).
        ocustom_file: Filename of single-column custom interleave order file\
            (first slice is referred to as 1 not 0).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SlicetimerOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SLICETIMER_METADATA)
    cargs = []
    cargs.append("slicetimer")
    cargs.extend([
        "-i",
        execution.input_file(infile)
    ])
    if outfile is not None:
        cargs.extend([
            "-o",
            execution.input_file(outfile)
        ])
    if verbose_flag:
        cargs.append("-v")
    if down_flag:
        cargs.append("--down")
    if tr_value is not None:
        cargs.extend([
            "-r",
            str(tr_value)
        ])
    if direction is not None:
        cargs.extend([
            "-d",
            direction
        ])
    if odd_flag:
        cargs.append("--odd")
    if tcustom_file is not None:
        cargs.extend([
            "--tcustom",
            execution.input_file(tcustom_file)
        ])
    if tglobal_value is not None:
        cargs.extend([
            "--tglobal",
            str(tglobal_value)
        ])
    if ocustom_file is not None:
        cargs.extend([
            "--ocustom",
            execution.input_file(ocustom_file)
        ])
    ret = SlicetimerOutputs(
        root=execution.output_file("."),
        output_timeseries=execution.output_file(pathlib.Path(outfile).name) if (outfile is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SLICETIMER_METADATA",
    "SlicetimerOutputs",
    "slicetimer",
]
