Application Utilities

This submodule contains utility functions for the application module.

cl.app.util

def run_migrations( config_dict: dict[str, typing.Any], migrations: dict[int, Callable[[dict[str, typing.Any]], None]]) -> dict[str, typing.Any] | None:

Apply a sequence of versioned migration functions to a config dictionary.

Each key in migrations is a target config version, and the value is a function that mutates the config dict in place to bring it up to that version. Migrations are applied in ascending version order, and config_version is updated automatically after each step.

Returns the migrated config dict, or None if no migration was needed.

def migrate_biphasic_to_stim_design( section: dict[str, typing.Any], current_key: str = 'current_ua', phase_width_key: str = 'phase_width_us', stim_design_key: str = 'stim_design') -> None:

In-place migration of legacy biphasic stimulation parameters to a StimDesignModel-compatible dict.

Pops current_key and phase_width_key from section and replaces them with a stim_design_key entry containing a symmetric biphasic pulse with equivalent amplitude and phase width.