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

import typing
import pathlib
from styxdefs import *
import dataclasses

RCBF_PREP_METADATA = Metadata(
    id="1a26630009bc7f6431b9c45507dba269ec5c416e.boutiques",
    name="rcbf-prep",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class RcbfPrepOutputs(typing.NamedTuple):
    """
    Output object returned when calling `rcbf_prep(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    hemisphere_rcbf: OutputPathType
    """Registered and resampled rCBF volume for both hemispheres."""
    mni305_rcbf: OutputPathType
    """rCBF volume resampled to MNI305 space."""
    roi_stats: OutputPathType
    """Stats file summarizing the ROIs."""


def rcbf_prep(
    outdir: str,
    rcbfvol: InputPathType,
    subject: str | None = None,
    roitab: InputPathType | None = None,
    register: InputPathType | None = None,
    template: InputPathType | None = None,
    runner: Runner | None = None,
) -> RcbfPrepOutputs:
    """
    Performs integration of rCBF as produced by Siemens scanners with FreeSurfer
    analysis in preparation for group analysis.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        outdir: Output directory where results will be stored.
        rcbfvol: Input rCBF volume to be registered to the FreeSurfer\
            anatomical.
        subject: Subject identifier for FreeSurfer anatomical registration.
        roitab: ROI table specifying which ROIs will be summarized, e.g.,\
            FreeSurferColorLUT.txt.
        register: Registration data file instead of a subject.
        template: Template file used instead of rCBF itself.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `RcbfPrepOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(RCBF_PREP_METADATA)
    cargs = []
    cargs.append("rcbf-prep")
    cargs.extend([
        "--o",
        outdir
    ])
    cargs.extend([
        "--rcbf",
        execution.input_file(rcbfvol)
    ])
    if subject is not None:
        cargs.extend([
            "--s",
            subject
        ])
    if roitab is not None:
        cargs.extend([
            "--roitab",
            execution.input_file(roitab)
        ])
    if register is not None:
        cargs.extend([
            "--reg",
            execution.input_file(register)
        ])
    if template is not None:
        cargs.extend([
            "--t",
            execution.input_file(template)
        ])
    ret = RcbfPrepOutputs(
        root=execution.output_file("."),
        hemisphere_rcbf=execution.output_file(outdir + "/?h.rcbf.mgh"),
        mni305_rcbf=execution.output_file(outdir + "/rcbf.mni305.nii"),
        roi_stats=execution.output_file(outdir + "/roi.dat"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "RCBF_PREP_METADATA",
    "RcbfPrepOutputs",
    "rcbf_prep",
]
