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

import typing
import pathlib
from styxdefs import *
import dataclasses

DCMUNPACK_METADATA = Metadata(
    id="01d871981fcfe7211d8f4250bbd352a2a097e2e7.boutiques",
    name="dcmunpack",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


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


def dcmunpack(
    src: str,
    targ: str | None = None,
    run: str | None = None,
    auto_runseq: str | None = None,
    keep_scouts: bool = False,
    scanonly: str | None = None,
    one_per_dir: bool = False,
    ext: str | None = None,
    pre: str | None = None,
    pat: str | None = None,
    no_infodump: bool = False,
    generic: bool = False,
    copy_only: bool = False,
    no_convert: bool = False,
    force_update: bool = False,
    max_: bool = False,
    base: bool = False,
    key_string: str | None = None,
    index_out: str | None = None,
    index_in: str | None = None,
    it_dicom: bool = False,
    no_exit_on_error: bool = False,
    run_skip: str | None = None,
    no_rescale_dicom: bool = False,
    rescale_dicom: bool = False,
    no_dwi: bool = False,
    iid: list[float] | None = None,
    ijd: list[float] | None = None,
    ikd: list[float] | None = None,
    extra_info: bool = False,
    first_dicom: bool = False,
    no_dcm2niix: bool = False,
    phase: bool = False,
    fips: str | None = None,
    fips_run: str | None = None,
    xml_only: bool = False,
    log: str | None = None,
    debug: bool = False,
    runner: Runner | None = None,
) -> DcmunpackOutputs:
    """
    Sorts and converts a directory of DICOM files (Siemens, GE, Philips) into an
    output hierarchy with nifti (nii), mgh, mgz, or analyze output formats.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        src: Dicom source directory. You can specify more than one.
        targ: Output directory. Do not need to include when just getting\
            information about what is in the directory.
        run: Specify unpacking rules for a given run (series). Eg, "-run 3 bold\
            nii f.nii".
        auto_runseq: Save all scans in the targetdir as runo.seqname.format.
        keep_scouts: Unpack series with 'scout' or 'setter' in the name.
        scanonly: Only scan the directory and put result in file.
        one_per_dir: Assume that there is only one dicom series in each subdir.
        ext: Input extension (eg, dcm).
        pre: Input prefix (i.e., input file name init string).
        pat: Input pattern (i.e., string that occurs in the middle of file\
            name).
        no_infodump: Do not create the fname-infodump.dat file.
        generic: Do not use FSFAST hierarchy.
        copy_only: Only copy dicom files to output directory (implies\
            -no-convert).
        no_convert: Do not convert to output format.
        force_update: Convert even if output is newer than the input dicom.
        max_: Print out max in given dicom file.
        base: Report filename without path.
        key_string: Put keystring before each run line (good for searching).
        index_out: Save index of files to index.out.dat (for re-use).
        index_in: Read index of files (can make things much faster on 2nd run).
        it_dicom: Add -it dicom to mri_convert cmd line.
        no_exit_on_error: Continue to unpack data even if there is an error in\
            conversion.
        run_skip: Skip a given run (good when using -auto-runseq).
        no_rescale_dicom: Turn off DICOM rescaling based on tags (0028,1052)\
            (0028,1053).
        rescale_dicom: Turn DICOM rescaling on.
        no_dwi: Turn off trying to read DWI parameters.
        iid: Set -iid to mri_convert.
        ijd: Set -ijd to mri_convert.
        ikd: Set -ikd to mri_convert.
        extra_info: Add session info to each line of the info file (pat, date,\
            man, scan, field, serno).
        first_dicom: Copy first dicom file into output folder.
        no_dcm2niix: Turn off dcm2niix conversion.
        phase: Add the string _phase to volumes that are phase images based on\
            ImageType.
        fips: Fips parameters: project, site, birnid, visit.
        fips_run: Fips-run parameters: run paradigm.
        xml_only: For fips, only create xml file, do not convert to output.
        log: Log output to a file.
        debug: Enable debug mode.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `DcmunpackOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(DCMUNPACK_METADATA)
    cargs = []
    cargs.append("dcmunpack")
    cargs.extend([
        "-src",
        src
    ])
    if targ is not None:
        cargs.extend([
            "-targ",
            targ
        ])
    if run is not None:
        cargs.extend([
            "-run",
            run
        ])
    if auto_runseq is not None:
        cargs.extend([
            "-auto-runseq",
            auto_runseq
        ])
    if keep_scouts:
        cargs.append("-keep-scouts")
    if scanonly is not None:
        cargs.extend([
            "-scanonly",
            scanonly
        ])
    if one_per_dir:
        cargs.append("-one-per-dir")
    if ext is not None:
        cargs.extend([
            "-ext",
            ext
        ])
    if pre is not None:
        cargs.extend([
            "-pre",
            pre
        ])
    if pat is not None:
        cargs.extend([
            "-pat",
            pat
        ])
    if no_infodump:
        cargs.append("-no-infodump")
    if generic:
        cargs.append("-generic")
    if copy_only:
        cargs.append("-copy-only")
    if no_convert:
        cargs.append("-no-convert")
    if force_update:
        cargs.append("-force-update")
    if max_:
        cargs.append("-max")
    if base:
        cargs.append("-base")
    if key_string is not None:
        cargs.extend([
            "-key",
            key_string
        ])
    if index_out is not None:
        cargs.extend([
            "-index-out",
            index_out
        ])
    if index_in is not None:
        cargs.extend([
            "-index-in",
            index_in
        ])
    if it_dicom:
        cargs.append("-itdicom")
    if no_exit_on_error:
        cargs.append("-no-exit-on-error")
    if run_skip is not None:
        cargs.extend([
            "-run-skip",
            run_skip
        ])
    if no_rescale_dicom:
        cargs.append("-no-rescale-dicom")
    if rescale_dicom:
        cargs.append("-rescale-dicom")
    if no_dwi:
        cargs.append("-no-dwi")
    if iid is not None:
        cargs.extend([
            "-iid",
            *map(str, iid)
        ])
    if ijd is not None:
        cargs.extend([
            "-ijd",
            *map(str, ijd)
        ])
    if ikd is not None:
        cargs.extend([
            "-ikd",
            *map(str, ikd)
        ])
    if extra_info:
        cargs.append("-extra-info")
    if first_dicom:
        cargs.append("-first-dicom")
    if no_dcm2niix:
        cargs.append("-no-dcm2niix")
    if phase:
        cargs.append("-phase")
    if fips is not None:
        cargs.extend([
            "-fips",
            fips
        ])
    if fips_run is not None:
        cargs.extend([
            "-fips-run",
            fips_run
        ])
    if xml_only:
        cargs.append("-xml-only")
    if log is not None:
        cargs.extend([
            "-log",
            log
        ])
    if debug:
        cargs.append("-debug")
    ret = DcmunpackOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "DCMUNPACK_METADATA",
    "DcmunpackOutputs",
    "dcmunpack",
]
