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

import typing
import pathlib
from styxdefs import *
import dataclasses

FSLSLICE_METADATA = Metadata(
    id="a89f4489f329457c259411cef949573bce403a21.boutiques",
    name="fslslice",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class FslsliceOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fslslice(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_slices: OutputPathType | None
    """Extracted 2D slices from the 3D volume"""


def fslslice(
    volume: InputPathType,
    output_basename: str | None = None,
    runner: Runner | None = None,
) -> FslsliceOutputs:
    """
    Tool to extract all slices from a 3D volume and store as 2D images.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        volume: Input 3D volume (e.g. volume.nii.gz).
        output_basename: Output basename for extracted slices.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FslsliceOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FSLSLICE_METADATA)
    cargs = []
    cargs.append("fslslice")
    cargs.append(execution.input_file(volume))
    if output_basename is not None:
        cargs.append(output_basename)
    ret = FslsliceOutputs(
        root=execution.output_file("."),
        output_slices=execution.output_file(output_basename + "_slice*.nii.gz") if (output_basename is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FSLSLICE_METADATA",
    "FslsliceOutputs",
    "fslslice",
]
