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

import typing
import pathlib
from styxdefs import *
import dataclasses

SCCAN_METADATA = Metadata(
    id="26f604003de4aee5a1d0df471af2893515e5b091.boutiques",
    name="sccan",
    package="ants",
    container_image_tag="antsx/ants:v2.5.3",
)


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


def sccan(
    output: str | None = None,
    n_permutations: int | None = None,
    smoother: int | None = None,
    row_sparseness: int | None = None,
    iterations: int | None = None,
    n_eigenvectors: int | None = None,
    robustify: int | None = None,
    covering: int | None = None,
    uselong: int | None = None,
    l1: float | None = None,
    pclusterthresh: float | None = None,
    qclusterthresh: float | None = None,
    ridge_cca: float | None = None,
    initialization: str | None = None,
    initialization2: str | None = None,
    mask: InputPathType | None = None,
    mask2: InputPathType | None = None,
    partial_scca_option: str | None = None,
    prior_weight: float | None = None,
    get_small: float | None = None,
    verbose: float | None = None,
    imageset_to_matrix: str | None = None,
    timeseriesimage_to_matrix: str | None = None,
    vector_to_image: str | None = None,
    imageset_to_projections: str | None = None,
    scca: str | None = None,
    svd: str | None = None,
    runner: Runner | None = None,
) -> SccanOutputs:
    """
    A tool for sparse statistical analysis on images : scca, pscca (with options),
    mscca. Can also convert an imagelist/mask pair to a binary matrix image.
    
    Author: ANTs Developers
    
    URL: https://github.com/ANTsX/ANTs
    
    Args:
        output: Output dependent on which option is called.
        n_permutations: Number of permutations to use in scca.
        smoother: Smoothing function for variates.
        row_sparseness: Row sparseness - if (+) then keep values (+) otherwise\
            allow +/- values --- always L1.
        iterations: Max iterations for scca optimization (min 20).
        n_eigenvectors: Number of eigenvectors to compute in scca/spca.
        robustify: Rank-based scca.
        covering: Try to make the decomposition cover the whole domain, if\
            possible.
        uselong: Use longitudinal formulation (> 0) or not (<= 0).
        l1: Use l1 (> 0) or l0 (< 0) penalty, also sets gradient step size.
        pclusterthresh: Cluster threshold on view P.
        qclusterthresh: Cluster threshold on view Q.
        ridge_cca: Ridge cca.
        initialization: Initialization file list for Eigenanatomy - must also\
            pass mask option.
        initialization2: Initialization file list for SCCAN-Eigenanatomy - must\
            also pass mask option.
        mask: Mask file for Eigenanatomy initialization.
        mask2: Mask file for Eigenanatomy initialization 2.
        partial_scca_option: Choices for pscca: PQ, PminusRQ, PQminusR,\
            PminusRQminusR.
        prior_weight: Scalar value weight on prior between 0 (prior is weak)\
            and 1 (prior is strong). Only engaged if initialization is used.
        get_small: Find smallest eigenvectors.
        verbose: Set whether output is verbose.
        imageset_to_matrix: Takes a list of image files names (one per line)\
            and converts it to a 2D matrix/image in binary or csv format.
        timeseriesimage_to_matrix: Takes a timeseries (4D) image and converts\
            it to a 2D matrix csv format.
        vector_to_image: Converts the 1st column vector in a csv file back to\
            an image.
        imageset_to_projections: Takes a list of image and projection files\
            names and writes them to a csv file.
        scca: Matrix-based scca operations for 2 and 3 views.
        svd: A sparse SVD implementation.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SccanOutputs`).
    """
    if iterations is not None and not (20 <= iterations): 
        raise ValueError(f"'iterations' must be greater than 20 <= x but was {iterations}")
    runner = runner or get_global_runner()
    execution = runner.start_execution(SCCAN_METADATA)
    cargs = []
    cargs.append("sccan")
    if output is not None:
        cargs.extend([
            "-o",
            output
        ])
    if n_permutations is not None:
        cargs.extend([
            "-p",
            str(n_permutations)
        ])
    if smoother is not None:
        cargs.extend([
            "-s",
            str(smoother)
        ])
    if row_sparseness is not None:
        cargs.extend([
            "-z",
            str(row_sparseness)
        ])
    if iterations is not None:
        cargs.extend([
            "-i",
            str(iterations)
        ])
    if n_eigenvectors is not None:
        cargs.extend([
            "-n",
            str(n_eigenvectors)
        ])
    if robustify is not None:
        cargs.extend([
            "-r",
            str(robustify)
        ])
    if covering is not None:
        cargs.extend([
            "-c",
            str(covering)
        ])
    if uselong is not None:
        cargs.extend([
            "-g",
            str(uselong)
        ])
    if l1 is not None:
        cargs.extend([
            "-l",
            str(l1)
        ])
    if pclusterthresh is not None:
        cargs.extend([
            "--PClusterThresh",
            str(pclusterthresh)
        ])
    if qclusterthresh is not None:
        cargs.extend([
            "--QClusterThresh",
            str(qclusterthresh)
        ])
    if ridge_cca is not None:
        cargs.extend([
            "-e",
            str(ridge_cca)
        ])
    if initialization is not None:
        cargs.extend([
            "--initialization",
            initialization
        ])
    if initialization2 is not None:
        cargs.extend([
            "--initialization2",
            initialization2
        ])
    if mask is not None:
        cargs.extend([
            "--mask",
            execution.input_file(mask)
        ])
    if mask2 is not None:
        cargs.extend([
            "--mask2",
            execution.input_file(mask2)
        ])
    if partial_scca_option is not None:
        cargs.extend([
            "--partial-scca-option",
            partial_scca_option
        ])
    if prior_weight is not None:
        cargs.extend([
            "--prior-weight",
            str(prior_weight)
        ])
    if get_small is not None:
        cargs.extend([
            "--get-small",
            str(get_small)
        ])
    if verbose is not None:
        cargs.extend([
            "-v",
            str(verbose)
        ])
    if imageset_to_matrix is not None:
        cargs.extend([
            "--imageset-to-matrix",
            imageset_to_matrix
        ])
    if timeseriesimage_to_matrix is not None:
        cargs.extend([
            "--timeseriesimage-to-matrix",
            timeseriesimage_to_matrix
        ])
    if vector_to_image is not None:
        cargs.extend([
            "--vector-to-image",
            vector_to_image
        ])
    if imageset_to_projections is not None:
        cargs.extend([
            "--imageset-to-projections",
            imageset_to_projections
        ])
    if scca is not None:
        cargs.extend([
            "--scca",
            scca
        ])
    if svd is not None:
        cargs.extend([
            "--svd",
            svd
        ])
    ret = SccanOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "SCCAN_METADATA",
    "SccanOutputs",
    "sccan",
]
