Skip to content

prompter

prompter

Interactive parameter prompting for missing metadata.

This module provides interactive prompting functionality for acquiring missing acquisition parameters from the user.

ParameterPrompter

ParameterPrompter(
    modality, interactive=True, use_defaults=True
)

Interactive prompting for missing acquisition parameters.

This class provides a consistent interface for prompting users to provide missing parameters, with type validation and default value suggestions.

Examples:

>>> from osipy.common.types import Modality
>>> prompter = ParameterPrompter(Modality.ASL, interactive=True)
>>> value = prompter.prompt_for_value("post_labeling_delay")
Missing post_labeling_delay (Post-labeling delay in milliseconds)
Default: 1800.0
Enter value [1800.0]:

Initialize the prompter.

PARAMETER DESCRIPTION
modality

Perfusion imaging modality (for default values).

TYPE: Modality

interactive

Whether to prompt interactively. If False, returns defaults.

TYPE: bool DEFAULT: True

use_defaults

Whether to use default values when available.

TYPE: bool DEFAULT: True

prompt_for_value

prompt_for_value(
    param_name, expected_type=float, default=None
)

Prompt user for a missing parameter value.

PARAMETER DESCRIPTION
param_name

Name of the parameter.

TYPE: str

expected_type

Expected type of the value.

TYPE: type DEFAULT: float

default

Default value to suggest. If None, uses modality default.

TYPE: Any DEFAULT: None

RETURNS DESCRIPTION
Any

User-provided value, default value, or None.

prompt_for_missing

prompt_for_missing(current_params, missing_params)

Prompt for all missing parameters.

PARAMETER DESCRIPTION
current_params

Current parameter values.

TYPE: dict[str, Any]

missing_params

List of missing parameter names.

TYPE: list[str]

RETURNS DESCRIPTION
dict[str, Any]

Updated parameters with user-provided values.