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

import typing
import pathlib
from styxdefs import *
import dataclasses

EDDY_COMBINE_METADATA = Metadata(
    id="db7603668c046fb6fd5779660a9255000bc5c8af.boutiques",
    name="eddy_combine",
    package="fsl",
    container_image_tag="mcin/fsl:6.0.5",
)


class EddyCombineOutputs(typing.NamedTuple):
    """
    Output object returned when calling `eddy_combine(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    combined_data: OutputPathType
    """Combined positive and negative phase-encoded data"""
    combined_bvals: OutputPathType
    """Combined b-values file"""
    combined_bvecs: OutputPathType
    """Combined b-vectors file"""


def eddy_combine(
    pos_data: InputPathType,
    pos_bvals: InputPathType,
    pos_bvecs: InputPathType,
    pos_series_vol: float,
    neg_data: InputPathType,
    neg_bvals: InputPathType,
    neg_bvecs: InputPathType,
    neg_series_vol: float,
    output_path: str,
    only_matched_flag: int,
    runner: Runner | None = None,
) -> EddyCombineOutputs:
    """
    Combines diffusion data sets with opposite phase encoding directions for use
    with FSL's EDDY.
    
    Author: Oxford Centre for Functional MRI of the Brain (FMRIB)
    
    Args:
        pos_data: Path to the positive phase-encoded data file (e.g.\
            PosData.nii.gz).
        pos_bvals: Path to the positive phase-encoded b-values file (e.g.\
            Posbvals).
        pos_bvecs: Path to the positive phase-encoded b-vectors file (e.g.\
            Posbvecs).
        pos_series_vol: Positive series volume count.
        neg_data: Path to the negative phase-encoded data file (e.g.\
            NegData.nii.gz).
        neg_bvals: Path to the negative phase-encoded b-values file (e.g.\
            Negbvals).
        neg_bvecs: Path to the negative phase-encoded b-vectors file (e.g.\
            Negbvecs).
        neg_series_vol: Negative series volume count.
        output_path: Output directory path.
        only_matched_flag: Flag to include only matched volumes (set to 1 to\
            include only matched volumes, otherwise 0).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `EddyCombineOutputs`).
    """
    if not (0 <= only_matched_flag <= 1): 
        raise ValueError(f"'only_matched_flag' must be between 0 <= x <= 1 but was {only_matched_flag}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(EDDY_COMBINE_METADATA)
    cargs = []
    cargs.append("eddy_combine")
    cargs.append(execution.input_file(pos_data))
    cargs.append(execution.input_file(pos_bvals))
    cargs.append(execution.input_file(pos_bvecs))
    cargs.append(str(pos_series_vol))
    cargs.append(execution.input_file(neg_data))
    cargs.append(execution.input_file(neg_bvals))
    cargs.append(execution.input_file(neg_bvecs))
    cargs.append(str(neg_series_vol))
    cargs.append(output_path)
    cargs.append(str(only_matched_flag))
    ret = EddyCombineOutputs(
        root=execution.output_file("."),
        combined_data=execution.output_file(output_path + "/combined_data.nii.gz"),
        combined_bvals=execution.output_file(output_path + "/combined_bvals"),
        combined_bvecs=execution.output_file(output_path + "/combined_bvecs"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "EDDY_COMBINE_METADATA",
    "EddyCombineOutputs",
    "eddy_combine",
]
