Skip to content

constants

tit.constants

Project-wide constants for TI-Toolbox.

Centralises all hard-coded values, magic numbers, and configuration defaults used across the TI-Toolbox codebase. Constants are grouped by domain:

Sections

Directory Names BIDS-compliant directory structure names (DIR_*). File Names and Extensions Configuration and NIfTI filenames (FILE_*) and EXT_CSV. Subject and Naming Patterns BIDS prefixes (PREFIX_*). Environment Variables Expected os.environ keys (ENV_*). Docker and Mount Paths Container-specific path constants. Analysis Constants Field names (FIELD_*), the output-field registry and the fsaverage node counts. Simulation Constants Electrode-pair counts and brain tissue tags. Numerical Constants White-matter conductivity (S/m) for the DTI advisories. QSI Integration QSIPrep / QSIRecon Docker images, recon specs, atlases, and resource defaults. Telemetry Constants GA4 Measurement Protocol settings and operation event names.

See Also

tit.paths : Uses many of these constants for BIDS path resolution.

FieldSpec dataclass

FieldSpec(name: str, label: str, kind: str, units: str, description: str)

Metadata for one output field quantity (mesh/NIfTI field name).

Attributes

name : str Exact on-disk / in-mesh field name (matches a FIELD_* constant). label : str Display name, X_{sub} for a subscript (TI_{max}, HF_{rms}): the desktop app, the TetraVox scene and the docs render the braces as a subscript. Values, IDs and file names always use name. kind : str FIELD_KIND_FUNCTIONAL or FIELD_KIND_SAFETY. units : str Physical units of the field values. description : str One-line tooltip text.

get_field_names

get_field_names(kind: str | None = None) -> tuple[str, ...]

Return registered field names in registry order.

Parameters

kind : str, optional If given, restrict to FIELD_KIND_FUNCTIONAL or FIELD_KIND_SAFETY.

Source code in tit/constants.py
def get_field_names(kind: str | None = None) -> tuple[str, ...]:
    """Return registered field names in registry order.

    Parameters
    ----------
    kind : str, optional
        If given, restrict to ``FIELD_KIND_FUNCTIONAL`` or ``FIELD_KIND_SAFETY``.
    """
    if kind is None:
        return tuple(spec.name for spec in FIELD_REGISTRY)
    return tuple(spec.name for spec in FIELD_REGISTRY if spec.kind == kind)

get_field_spec

get_field_spec(name: str) -> FieldSpec

Look up a :class:FieldSpec by its exact field name.

Raises

KeyError If name is not in :data:FIELD_REGISTRY.

Source code in tit/constants.py
def get_field_spec(name: str) -> FieldSpec:
    """Look up a :class:`FieldSpec` by its exact field name.

    Raises
    ------
    KeyError
        If ``name`` is not in :data:`FIELD_REGISTRY`.
    """
    for spec in FIELD_REGISTRY:
        if spec.name == name:
            return spec
    raise KeyError(f"Unknown field name: {name!r}")

is_valid_pair_count

is_valid_pair_count(n: int) -> bool

Is n an allowed electrode-pair (channel) count?

True for even counts of at least MIN_ELECTRODE_PAIRS: 2, 4, 6, 8, … Odd counts leave a channel with nothing to beat against, and a single pair is tACS, not TI.

Source code in tit/constants.py
def is_valid_pair_count(n: int) -> bool:
    """Is *n* an allowed electrode-pair (channel) count?

    ``True`` for even counts of at least `MIN_ELECTRODE_PAIRS`: 2, 4, 6, 8, …
    Odd counts leave a channel with nothing to beat against, and a single
    pair is tACS, not TI.
    """
    return n >= MIN_ELECTRODE_PAIRS and n % 2 == 0