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

import typing
import pathlib
from styxdefs import *
import dataclasses

BEDPOSTX_MGH_METADATA = Metadata(
    id="fb49a4fd21cd6f6cf877e9365ca0aa77e9e1a7f5.boutiques",
    name="bedpostx_mgh",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class BedpostxMghOutputs(typing.NamedTuple):
    """
    Output object returned when calling `bedpostx_mgh(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def bedpostx_mgh(
    subject_directory: str,
    fibres: float | None = None,
    ard_weight: float | None = None,
    burnin: float | None = None,
    jumps: float | None = None,
    sample_every: float | None = None,
    deconv_model: float | None = None,
    gradient_nonlin: bool = False,
    runner: Runner | None = None,
) -> BedpostxMghOutputs:
    """
    A modified version of FSL's bedpostx compatible with PBS queueing system for
    parallel computation.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        subject_directory: Subject directory containing necessary files such as\
            bvals, bvecs, data, and nodif_brain_mask.
        fibres: Number of fibres per voxel, default is 3.
        ard_weight: ARD weight, more weight means fewer secondary fibres per\
            voxel, default is 1.
        burnin: Burnin period, default is 1000.
        jumps: Number of jumps, default is 1250.
        sample_every: Sample every n steps, default is 25.
        deconv_model: Deconvolution model selection. 1: with sticks, 2: with\
            sticks with a range of diffusivities (default), 3: with zeppelins.
        gradient_nonlin: Consider gradient nonlinearities, default is off.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `BedpostxMghOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(BEDPOSTX_MGH_METADATA)
    cargs = []
    cargs.append("bedpostx_mgh")
    cargs.append(subject_directory)
    if fibres is not None:
        cargs.extend([
            "-n",
            str(fibres)
        ])
    if ard_weight is not None:
        cargs.extend([
            "-w",
            str(ard_weight)
        ])
    if burnin is not None:
        cargs.extend([
            "-b",
            str(burnin)
        ])
    if jumps is not None:
        cargs.extend([
            "-j",
            str(jumps)
        ])
    if sample_every is not None:
        cargs.extend([
            "-s",
            str(sample_every)
        ])
    if deconv_model is not None:
        cargs.extend([
            "-model",
            str(deconv_model)
        ])
    if gradient_nonlin:
        cargs.append("-g")
    ret = BedpostxMghOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "BEDPOSTX_MGH_METADATA",
    "BedpostxMghOutputs",
    "bedpostx_mgh",
]
