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

import typing
import pathlib
from styxdefs import *
import dataclasses

SLICETIMER_FSL_METADATA = Metadata(
    id="27673c86089b795cd88a005218734e798ec23211.boutiques",
    name="slicetimer.fsl",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class SlicetimerFslOutputs(typing.NamedTuple):
    """
    Output object returned when calling `slicetimer_fsl(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    corrected_timeseries: OutputPathType | None
    """Corrected output timeseries"""


def slicetimer_fsl(
    infile: InputPathType,
    outfile: str | None = None,
    tr: float | None = None,
    direction: typing.Literal["x", "y", "z"] | None = None,
    interleaved: bool = False,
    reverse: bool = False,
    custom_timings: InputPathType | None = None,
    global_shift: float | None = None,
    custom_interleave_order: InputPathType | None = None,
    verbose: bool = False,
    runner: Runner | None = None,
) -> SlicetimerFslOutputs:
    """
    FMRIB's Interpolation for Slice Timing correction in FMRI data.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        infile: Filename of input timeseries.
        outfile: Filename of output corrected timeseries.
        tr: Specify TR of data, default is 3s.
        direction: Direction of slice acquisition (x=1, y=2, z=3); default is z.
        interleaved: Use interleaved acquisition.
        reverse: Reverse slice indexing (default is slices were acquired\
            bottom-up).
        custom_timings: Filename of single-column slice timings in fractions of\
            TR, positive values shift slices forwards in time.
        global_shift: Global shift in fraction of TR, default is 0.
        custom_interleave_order: Filename of single-column custom interleave\
            order file (first slice is referred to as 1 not 0).
        verbose: Switch on diagnostic messages.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SlicetimerFslOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SLICETIMER_FSL_METADATA)
    cargs = []
    cargs.append("slicetimer")
    cargs.append("--in")
    cargs.extend([
        "-i",
        execution.input_file(infile)
    ])
    if outfile is not None:
        cargs.extend([
            "-o",
            outfile
        ])
    if tr is not None:
        cargs.extend([
            "-r",
            str(tr)
        ])
    if direction is not None:
        cargs.extend([
            "-d",
            direction
        ])
    if interleaved:
        cargs.append("--odd")
    if reverse:
        cargs.append("--down")
    if custom_timings is not None:
        cargs.extend([
            "--tcustom",
            execution.input_file(custom_timings)
        ])
    if global_shift is not None:
        cargs.extend([
            "--tglobal",
            str(global_shift)
        ])
    if custom_interleave_order is not None:
        cargs.extend([
            "--ocustom",
            execution.input_file(custom_interleave_order)
        ])
    if verbose:
        cargs.append("-v")
    ret = SlicetimerFslOutputs(
        root=execution.output_file("."),
        corrected_timeseries=execution.output_file(outfile) if (outfile is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SLICETIMER_FSL_METADATA",
    "SlicetimerFslOutputs",
    "slicetimer_fsl",
]
