convert_config_versions#

class ExperimentConfigConverter(root: Path, app: QApplication)[source]#

Bases: object

run()[source]#
class ExperimentUpgrade_2_1_to_3_0(root: Path, app: QApplication)[source]#

Bases: ExperimentConfigConverter

Handles upgrade of a full experiment folder from 2.1 → 3.0.

static fix_stray_underscore(name: str) str[source]#

remove stray underscore before extension in name

verify_renaming(files_to_rename: dict[str, str] = None)[source]#
class ExperimentUpgrade_3_0_to_3_1(root: Path, app: QApplication)[source]#

Bases: ExperimentConfigConverter

Handles upgrade of a full experiment folder from 3.0 → 3.1.

For this step, the only changes are: - switch configs from .cfg → .yml - add clearmap_schema: 3 - bump clearmap_version to 3.1.0

cfg_converter(from_v: str, to_v: str, config_type: str)[source]#

Register a file-level converter.

Parameters:
  • from_v (str) – The version the converter expects as input.

  • to_v (str) – The version the converter produces as output.

  • config_type (str) – The canonical name of the config type (e.g. ‘sample’, ‘alignment’, ‘cell_map’, ‘machine’).

Examples

@register_file_converter('3.0', '3.1', 'sample')
def convert_sample_3_0_to_3_1(cfg_path: Path) -> Path:
...
convert(cfg_path, *, prev_v: str | Version = '2.1', new_v: str | Version = '3.0', backup: bool = False, overwrite: bool = False)[source]#

Convert a single config file between versions.

  • Detects type & scope via ALTERNATIVES_REG.

  • Chains multiple conversion steps if needed (2.1 → 3.0 → 3.1).

convert_2_1_to_3_0(main_folder='', create_app=True)[source]#
convert_3_0_to_3_1(main_folder: str | Path = '', create_app: bool = True)[source]#
convert_alignment_2_1_to_3_0(v1_path, v2_path='', sample_config=None)[source]#
convert_batch_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_cell_map_2_1_to_3_0(v1_path, v2_path='', channel_name='channel_0')[source]#
convert_cell_map_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_colocalization_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_group_analysis_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_machine_2_1_to_3_0(v1_path, v2_path='')[source]#
convert_machine_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_registration_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_sample_2_1_to_3_0(v1_path, v2_path='')[source]#
convert_sample_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_stitching_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_tract_map_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_vasculature_3_0_to_3_1(v1_path, v2_path='', sample_config=None)#
convert_versions(previous_version: str, new_version: str, *, exp_dir: str | Path = '', create_app: bool = True)[source]#
detect_config_type(cfg_path: Path) tuple[str, str][source]#

Return (canonical_name, scope) where scope is ‘experiment’ or ‘global’.

get_configs(v1_path, v2_path='')[source]#
get_conversion_steps(previous_version: Version, new_version: Version) list[tuple[Version, Version]][source]#

Return a list of (from_v, to_v) steps to go from previous_version to new_version.

Uses SUPPORTED_VERSIONS ordering; only upgrades are supported.

global_cfg_converter(from_v, to_v, config_type: str)[source]#
make_generic_3_0_to_3_1_converter(config_type: str, migration_func: Callable[[dict, dict, dict], None] | None = None)[source]#

Factory for trivial 3.0 → 3.1 converters, for both experiment and global configs.

  • Uses ALTERNATIVES_REG to decide whether to register as experiment or global.

  • Calls migration_func if provided

  • Writes to .yml (if no explicit v2_path is given).

migrate_vasculature_performance_v3_0_to_v3_1(old_cfg: dict, merged: dict, default_cfg: dict, sample_config: dict) None[source]#
migrate_vasculature_postprocessing_v3_0_to_v3_1(old_cfg: dict, merged: dict, default_cfg: dict, sample_cfg: dict | None = None) None[source]#

Rename vessel_type_postprocessing thresholds from voxels to µm, and fix the arteries_min_radius misnomer.

Conversion: old_vox × mean(spacing). spacing is read from sample config if available, otherwise falls back to a documented default with a warning.

migrate_vasculature_v3_0_to_v3_1(old_cfg, merged, default_cfg, sample_config)[source]#
project_converter(from_v: str, to_v: str)[source]#

Register a project-level converter.

Usage#

@register_project_converter('3.0', '3.1')
def convert_project_3_0_to_3_1(exp_dir: Path) -> None:
    ...
read_cfg(path: Path | str, must_exist: bool = True)[source]#
test()[source]#
version_guard(from_v, to_v, key: str = 'clearmap_version')[source]#

Wrap a converter that expects config_v1, *args, **kwargs.

  • Raises if version != from_v

  • Warns & returns filename if version == to_v