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

import typing
import pathlib
from styxdefs import *
import dataclasses

EXTRACT_SEG_WAVEFORM_METADATA = Metadata(
    id="871847f8fc6a902c317b011804ed6c2c847d8460.boutiques",
    name="extract_seg_waveform",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def extract_seg_waveform(
    seg_file: InputPathType,
    seg_indices: list[float],
    input_volume: InputPathType,
    reg_file: InputPathType,
    output_file: str,
    vsm_file: InputPathType | None = None,
    regheader_flag: bool = False,
    demean_flag: bool = False,
    runner: Runner | None = None,
) -> ExtractSegWaveformOutputs:
    """
    This program extracts an average waveform from an input volume where the average
    is computed over the voxels in the given segmentation indices. The input volume
    is mapped to the space of the segmentation given the registration, and if a
    voxel shift map (VSM) is supplied, it is applied simultaneously as part of the
    transform.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        seg_file: Segmentation file.
        seg_indices: Segmentation indices, one or more indices can be specified.
        input_volume: Input volume.
        reg_file: Registration file (.lta).
        output_file: Output waveform file.
        vsm_file: Voxel shift map for B0 distortion correction.
        regheader_flag: Uses the header information in the registration file.
        demean_flag: Remove mean, first, and second order trends.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ExtractSegWaveformOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(EXTRACT_SEG_WAVEFORM_METADATA)
    cargs = []
    cargs.append("extract_seg_waveform")
    cargs.extend([
        "--seg",
        execution.input_file(seg_file)
    ])
    cargs.extend([
        "--id",
        *map(str, seg_indices)
    ])
    cargs.extend([
        "--i",
        execution.input_file(input_volume)
    ])
    cargs.extend([
        "--reg",
        execution.input_file(reg_file)
    ])
    if vsm_file is not None:
        cargs.extend([
            "--vsm",
            execution.input_file(vsm_file)
        ])
    if regheader_flag:
        cargs.append("--regheader")
    if demean_flag:
        cargs.append("--demean")
    cargs.extend([
        "--o",
        output_file
    ])
    ret = ExtractSegWaveformOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "EXTRACT_SEG_WAVEFORM_METADATA",
    "ExtractSegWaveformOutputs",
    "extract_seg_waveform",
]
