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

import typing
import pathlib
from styxdefs import *
import dataclasses

MRI_Z2P_METADATA = Metadata(
    id="993304b1f6f275d376d70048d9e4d541fe6daff2.boutiques",
    name="mri_z2p",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class MriZ2pOutputs(typing.NamedTuple):
    """
    Output object returned when calling `mri_z2p(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_p_volume: OutputPathType
    """Output P volume file."""
    output_sig_volume: OutputPathType
    """Output significance volume file."""


def mri_z2p(
    z_volume: InputPathType,
    p_volume: str,
    sig_volume: str,
    mask_volume: InputPathType | None = None,
    two_sided: bool = False,
    one_sided: bool = False,
    signed: bool = False,
    feat: str | None = None,
    feat_format: str | None = None,
    img_format: bool = False,
    debug: bool = False,
    check_opts: bool = False,
    runner: Runner | None = None,
) -> MriZ2pOutputs:
    """
    Converts Z-statistic volumes to P-value volumes.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        z_volume: Z volume file.
        p_volume: P volume file.
        sig_volume: Significance volume file.
        mask_volume: Mask volume file.
        two_sided: Assume a two-sided, unsigned test (keeps sign of input).
        one_sided: Assume a one-sided, signed test.
        signed: Two-sided/signed p-value (p = 2*(1-p)).
        feat: Convert all z-stats and zf-stats to sigs in the specified\
            directory.
        feat_format: Use specified format for output (e.g., nii, nii.gz, mgh).
        img_format: Use Analyze output format.
        debug: Turn on debugging.
        check_opts: Don't run anything, just check options and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MriZ2pOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(MRI_Z2P_METADATA)
    cargs = []
    cargs.append("mri_z2p")
    cargs.extend([
        "--z",
        execution.input_file(z_volume)
    ])
    cargs.extend([
        "--p",
        p_volume
    ])
    cargs.extend([
        "--log10p",
        sig_volume
    ])
    if mask_volume is not None:
        cargs.extend([
            "--mask",
            execution.input_file(mask_volume)
        ])
    if two_sided:
        cargs.append("--two-sided")
    if one_sided:
        cargs.append("--one-sided")
    if signed:
        cargs.append("--signed")
    if feat is not None:
        cargs.extend([
            "--feat",
            feat
        ])
    if feat_format is not None:
        cargs.extend([
            "--featfmt",
            feat_format
        ])
    if img_format:
        cargs.append("--img")
    if debug:
        cargs.append("--debug")
    if check_opts:
        cargs.append("--checkopts")
    ret = MriZ2pOutputs(
        root=execution.output_file("."),
        output_p_volume=execution.output_file(p_volume),
        output_sig_volume=execution.output_file(sig_volume),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "MRI_Z2P_METADATA",
    "MriZ2pOutputs",
    "mri_z2p",
]
