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

import typing
import pathlib
from styxdefs import *
import dataclasses

CIFTI_CREATE_DENSE_FROM_TEMPLATE_METADATA = Metadata(
    id="60b32f615cad25bb9b880cab394b4361294d1f30.boutiques",
    name="cifti-create-dense-from-template",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


@dataclasses.dataclass
class CiftiCreateDenseFromTemplateSeries:
    """
    make a dtseries file instead of a dscalar.
    """
    step: float
    """increment between series points"""
    start: float
    """start value of the series"""
    opt_unit_unit: str | None = None
    """select unit for series (default SECOND): unit identifier"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-series")
        cargs.append(str(self.step))
        cargs.append(str(self.start))
        if self.opt_unit_unit is not None:
            cargs.extend([
                "-unit",
                self.opt_unit_unit
            ])
        return cargs


@dataclasses.dataclass
class CiftiCreateDenseFromTemplateVolumeAll:
    """
    specify an input volume file for all voxel data.
    """
    volume_in: InputPathType
    """the input volume file"""
    opt_from_cropped: bool = False
    """the input is cropped to the size of the voxel data in the template
    file"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-volume-all")
        cargs.append(execution.input_file(self.volume_in))
        if self.opt_from_cropped:
            cargs.append("-from-cropped")
        return cargs


@dataclasses.dataclass
class CiftiCreateDenseFromTemplateCifti:
    """
    use input data from a cifti file.
    """
    cifti_in: InputPathType
    """cifti file containing input data"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-cifti")
        cargs.append(execution.input_file(self.cifti_in))
        return cargs


@dataclasses.dataclass
class CiftiCreateDenseFromTemplateMetric:
    """
    use input data from a metric file.
    """
    structure: str
    """which structure to put the metric file into"""
    metric_in: InputPathType
    """input metric file"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-metric")
        cargs.append(self.structure)
        cargs.append(execution.input_file(self.metric_in))
        return cargs


@dataclasses.dataclass
class CiftiCreateDenseFromTemplateLabel:
    """
    use input data from surface label files.
    """
    structure: str
    """which structure to put the label file into"""
    label_in: InputPathType
    """input label file"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-label")
        cargs.append(self.structure)
        cargs.append(execution.input_file(self.label_in))
        return cargs


@dataclasses.dataclass
class CiftiCreateDenseFromTemplateVolume:
    """
    use a volume file for a single volume structure's data.
    """
    structure: str
    """which structure to put the volume file into"""
    volume_in: InputPathType
    """the input volume file"""
    opt_from_cropped: bool = False
    """the input is cropped to the size of the volume structure"""
    
    def run(
        self,
        execution: Execution,
    ) -> list[str]:
        """
        Build command line arguments. This method is called by the main command.
        
        Args:
            execution: The execution object.
        Returns:
            Command line arguments
        """
        cargs = []
        cargs.append("-volume")
        cargs.append(self.structure)
        cargs.append(execution.input_file(self.volume_in))
        if self.opt_from_cropped:
            cargs.append("-from-cropped")
        return cargs


class CiftiCreateDenseFromTemplateOutputs(typing.NamedTuple):
    """
    Output object returned when calling `cifti_create_dense_from_template(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    cifti_out: OutputPathType
    """the output cifti file"""


def cifti_create_dense_from_template(
    template_cifti: InputPathType,
    cifti_out: str,
    series: CiftiCreateDenseFromTemplateSeries | None = None,
    volume_all: CiftiCreateDenseFromTemplateVolumeAll | None = None,
    opt_label_collision_action: str | None = None,
    cifti: list[CiftiCreateDenseFromTemplateCifti] | None = None,
    metric: list[CiftiCreateDenseFromTemplateMetric] | None = None,
    label: list[CiftiCreateDenseFromTemplateLabel] | None = None,
    volume: list[CiftiCreateDenseFromTemplateVolume] | None = None,
    runner: Runner | None = None,
) -> CiftiCreateDenseFromTemplateOutputs:
    """
    Create cifti with matching dense map.
    
    This command helps you make a new dscalar, dtseries, or dlabel cifti file
    that matches the brainordinate space used in another cifti file. The
    template file must have the desired brainordinate space in the mapping along
    the column direction (for dtseries, dscalar, dlabel, and symmetric dconn
    this is always the case). All input cifti files must have a brain models
    mapping along column and use the same volume space and/or surface vertex
    count as the template for structures that they contain. If any input files
    contain label data, then input files with non-label data are not allowed,
    and the -series option may not be used.
    
    Any structure that isn't covered by an input is filled with zeros or the
    unlabeled key.
    
    The <structure> argument of -metric, -label or -volume must be one of the
    following:
    
    CORTEX_LEFT
    CORTEX_RIGHT
    CEREBELLUM
    ACCUMBENS_LEFT
    ACCUMBENS_RIGHT
    ALL_GREY_MATTER
    ALL_WHITE_MATTER
    AMYGDALA_LEFT
    AMYGDALA_RIGHT
    BRAIN_STEM
    CAUDATE_LEFT
    CAUDATE_RIGHT
    CEREBELLAR_WHITE_MATTER_LEFT
    CEREBELLAR_WHITE_MATTER_RIGHT
    CEREBELLUM_LEFT
    CEREBELLUM_RIGHT
    CEREBRAL_WHITE_MATTER_LEFT
    CEREBRAL_WHITE_MATTER_RIGHT
    CORTEX
    DIENCEPHALON_VENTRAL_LEFT
    DIENCEPHALON_VENTRAL_RIGHT
    HIPPOCAMPUS_LEFT
    HIPPOCAMPUS_RIGHT
    INVALID
    OTHER
    OTHER_GREY_MATTER
    OTHER_WHITE_MATTER
    PALLIDUM_LEFT
    PALLIDUM_RIGHT
    PUTAMEN_LEFT
    PUTAMEN_RIGHT
    THALAMUS_LEFT
    THALAMUS_RIGHT
    
    The argument to -unit must be one of the following:
    
    SECOND
    HERTZ
    METER
    RADIAN.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        template_cifti: file to match brainordinates of.
        cifti_out: the output cifti file.
        series: make a dtseries file instead of a dscalar.
        volume_all: specify an input volume file for all voxel data.
        opt_label_collision_action: how to handle conflicts between label keys:\
            'ERROR', 'SURFACES_FIRST', or 'LEGACY', default 'ERROR', use 'LEGACY'\
            to match v1.4.2 and earlier.
        cifti: use input data from a cifti file.
        metric: use input data from a metric file.
        label: use input data from surface label files.
        volume: use a volume file for a single volume structure's data.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `CiftiCreateDenseFromTemplateOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(CIFTI_CREATE_DENSE_FROM_TEMPLATE_METADATA)
    cargs = []
    cargs.append("wb_command")
    cargs.append("-cifti-create-dense-from-template")
    cargs.append(execution.input_file(template_cifti))
    cargs.append(cifti_out)
    if series is not None:
        cargs.extend(series.run(execution))
    if volume_all is not None:
        cargs.extend(volume_all.run(execution))
    if opt_label_collision_action is not None:
        cargs.extend([
            "-label-collision",
            opt_label_collision_action
        ])
    if cifti is not None:
        cargs.extend([a for c in [s.run(execution) for s in cifti] for a in c])
    if metric is not None:
        cargs.extend([a for c in [s.run(execution) for s in metric] for a in c])
    if label is not None:
        cargs.extend([a for c in [s.run(execution) for s in label] for a in c])
    if volume is not None:
        cargs.extend([a for c in [s.run(execution) for s in volume] for a in c])
    ret = CiftiCreateDenseFromTemplateOutputs(
        root=execution.output_file("."),
        cifti_out=execution.output_file(cifti_out),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "CIFTI_CREATE_DENSE_FROM_TEMPLATE_METADATA",
    "CiftiCreateDenseFromTemplateCifti",
    "CiftiCreateDenseFromTemplateLabel",
    "CiftiCreateDenseFromTemplateMetric",
    "CiftiCreateDenseFromTemplateOutputs",
    "CiftiCreateDenseFromTemplateSeries",
    "CiftiCreateDenseFromTemplateVolume",
    "CiftiCreateDenseFromTemplateVolumeAll",
    "cifti_create_dense_from_template",
]
