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

import typing
import pathlib
from styxdefs import *

METRIC_ESTIMATE_FWHM_METADATA = Metadata(
    id="1dc8ef5c509e7c0da3d3148fdee937da14d79caf.boutiques",
    name="metric-estimate-fwhm",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


MetricEstimateFwhmWholeFileParameters = typing.TypedDict('MetricEstimateFwhmWholeFileParameters', {
    "@type": typing.NotRequired[typing.Literal["whole_file"]],
    "opt_demean": bool,
})
MetricEstimateFwhmWholeFileParametersTagged = typing.TypedDict('MetricEstimateFwhmWholeFileParametersTagged', {
    "@type": typing.Literal["whole_file"],
    "opt_demean": bool,
})


MetricEstimateFwhmParameters = typing.TypedDict('MetricEstimateFwhmParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/metric-estimate-fwhm"]],
    "surface": InputPathType,
    "metric_in": InputPathType,
    "opt_roi_roi_metric": typing.NotRequired[InputPathType | None],
    "opt_column_column": typing.NotRequired[str | None],
    "whole_file": typing.NotRequired[MetricEstimateFwhmWholeFileParameters | None],
})
MetricEstimateFwhmParametersTagged = typing.TypedDict('MetricEstimateFwhmParametersTagged', {
    "@type": typing.Literal["workbench/metric-estimate-fwhm"],
    "surface": InputPathType,
    "metric_in": InputPathType,
    "opt_roi_roi_metric": typing.NotRequired[InputPathType | None],
    "opt_column_column": typing.NotRequired[str | None],
    "whole_file": typing.NotRequired[MetricEstimateFwhmWholeFileParameters | None],
})


def metric_estimate_fwhm_whole_file_params(
    opt_demean: bool = False,
) -> MetricEstimateFwhmWholeFileParametersTagged:
    """
    Build parameters.
    
    Args:
        opt_demean: subtract the mean image before estimating smoothness.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "whole_file",
        "opt_demean": opt_demean,
    }
    return params


def metric_estimate_fwhm_whole_file_cargs(
    params: MetricEstimateFwhmWholeFileParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-whole-file")
    if params.get("opt_demean", False):
        cargs.append("-demean")
    return cargs


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


def metric_estimate_fwhm_params(
    surface: InputPathType,
    metric_in: InputPathType,
    opt_roi_roi_metric: InputPathType | None = None,
    opt_column_column: str | None = None,
    whole_file: MetricEstimateFwhmWholeFileParameters | None = None,
) -> MetricEstimateFwhmParametersTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to use for distance and neighbor information.
        metric_in: the input metric.
        opt_roi_roi_metric: use only data within an ROI: the metric file to use\
            as an ROI.
        opt_column_column: select a single column to estimate smoothness of:\
            the column number or name.
        whole_file: estimate for the whole file at once, not each column\
            separately.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/metric-estimate-fwhm",
        "surface": surface,
        "metric_in": metric_in,
    }
    if opt_roi_roi_metric is not None:
        params["opt_roi_roi_metric"] = opt_roi_roi_metric
    if opt_column_column is not None:
        params["opt_column_column"] = opt_column_column
    if whole_file is not None:
        params["whole_file"] = whole_file
    return params


def metric_estimate_fwhm_cargs(
    params: MetricEstimateFwhmParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("wb_command")
    cargs.append("-metric-estimate-fwhm")
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(execution.input_file(params.get("metric_in", None)))
    if params.get("opt_roi_roi_metric", None) is not None:
        cargs.extend([
            "-roi",
            execution.input_file(params.get("opt_roi_roi_metric", None))
        ])
    if params.get("opt_column_column", None) is not None:
        cargs.extend([
            "-column",
            params.get("opt_column_column", None)
        ])
    if params.get("whole_file", None) is not None:
        cargs.extend(metric_estimate_fwhm_whole_file_cargs(params.get("whole_file", None), execution))
    return cargs


def metric_estimate_fwhm_outputs(
    params: MetricEstimateFwhmParameters,
    execution: Execution,
) -> MetricEstimateFwhmOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = MetricEstimateFwhmOutputs(
        root=execution.output_file("."),
    )
    return ret


def metric_estimate_fwhm_execute(
    params: MetricEstimateFwhmParameters,
    runner: Runner | None = None,
) -> MetricEstimateFwhmOutputs:
    """
    metric-estimate-fwhm
    
    Estimate fwhm smoothness of a metric file.
    
    Estimates the smoothness of the metric columns, printing the estimates to
    standard output. These estimates ignore variation in vertex spacing.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetricEstimateFwhmOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(METRIC_ESTIMATE_FWHM_METADATA)
    params = execution.params(params)
    cargs = metric_estimate_fwhm_cargs(params, execution)
    ret = metric_estimate_fwhm_outputs(params, execution)
    execution.run(cargs)
    return ret


def metric_estimate_fwhm(
    surface: InputPathType,
    metric_in: InputPathType,
    opt_roi_roi_metric: InputPathType | None = None,
    opt_column_column: str | None = None,
    whole_file: MetricEstimateFwhmWholeFileParameters | None = None,
    runner: Runner | None = None,
) -> MetricEstimateFwhmOutputs:
    """
    metric-estimate-fwhm
    
    Estimate fwhm smoothness of a metric file.
    
    Estimates the smoothness of the metric columns, printing the estimates to
    standard output. These estimates ignore variation in vertex spacing.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        surface: the surface to use for distance and neighbor information.
        metric_in: the input metric.
        opt_roi_roi_metric: use only data within an ROI: the metric file to use\
            as an ROI.
        opt_column_column: select a single column to estimate smoothness of:\
            the column number or name.
        whole_file: estimate for the whole file at once, not each column\
            separately.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetricEstimateFwhmOutputs`).
    """
    params = metric_estimate_fwhm_params(
        surface=surface,
        metric_in=metric_in,
        opt_roi_roi_metric=opt_roi_roi_metric,
        opt_column_column=opt_column_column,
        whole_file=whole_file,
    )
    return metric_estimate_fwhm_execute(params, runner)


__all__ = [
    "METRIC_ESTIMATE_FWHM_METADATA",
    "MetricEstimateFwhmOutputs",
    "metric_estimate_fwhm",
    "metric_estimate_fwhm_execute",
    "metric_estimate_fwhm_params",
    "metric_estimate_fwhm_whole_file_params",
]
