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

import typing
import pathlib
from styxdefs import *
import dataclasses

DMRI_SAVE_HISTOGRAMS_METADATA = Metadata(
    id="ee8d1ca09c1b2241dc168157801f106029c44920.boutiques",
    name="dmri_saveHistograms",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class DmriSaveHistogramsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `dmri_save_histograms(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    histogram_csv: OutputPathType
    """CSV file containing the output histograms."""


def dmri_save_histograms(
    parcellation: InputPathType,
    number_of_bundles: float,
    vtk_bundle_list: list[InputPathType],
    output_csv: str,
    brain_bundle_flag: bool = False,
    runner: Runner | None = None,
) -> DmriSaveHistogramsOutputs:
    """
    A tool to save histograms from diffusion MRI tractography data.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        parcellation: Parcellation file for the tractography data.
        number_of_bundles: Number of bundles in the tractography data.
        vtk_bundle_list: List of VTK bundles for creating histograms.
        output_csv: Output CSV file to save histograms.
        brain_bundle_flag: Brain Bundle flag.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `DmriSaveHistogramsOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(DMRI_SAVE_HISTOGRAMS_METADATA)
    cargs = []
    cargs.append("dmri_saveHistograms")
    cargs.extend([
        "-p",
        execution.input_file(parcellation)
    ])
    cargs.extend([
        "-f",
        str(number_of_bundles)
    ])
    cargs.extend([execution.input_file(f) for f in vtk_bundle_list])
    cargs.extend([
        "-o",
        output_csv
    ])
    if brain_bundle_flag:
        cargs.append("-bb")
    ret = DmriSaveHistogramsOutputs(
        root=execution.output_file("."),
        histogram_csv=execution.output_file("histograms.csv"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "DMRI_SAVE_HISTOGRAMS_METADATA",
    "DmriSaveHistogramsOutputs",
    "dmri_save_histograms",
]
