MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / get_conversion_table

Function get_conversion_table

deeplabcut/modelzoo/utils.py:144–175  ·  view source on GitHub ↗

Gets the conversion table from a project to a SuperAnimal model. Args: cfg: The path to a project configuration file, or directly the project config. super_animal: The SuperAnimal for which to get the configuration file. Returns: A dictionary mapping {project_bodypa

(cfg: dict | str | Path, super_animal: str)

Source from the content-addressed store, hash-verified

142
143
144def get_conversion_table(cfg: dict | str | Path, super_animal: str) -> ConversionTable:
145 """Gets the conversion table from a project to a SuperAnimal model.
146
147 Args:
148 cfg: The path to a project configuration file, or directly the project config.
149 super_animal: The SuperAnimal for which to get the configuration file.
150
151 Returns:
152 A dictionary mapping {project_bodypart: super_animal_bodypart}
153
154 Raises:
155 ValueError: If the conversion table is misconfigured (e.g., if there are
156 misnamed bodyparts in the table). See ConversionTable for more.
157 """
158 if isinstance(cfg, (str, Path)):
159 cfg = read_config(str(cfg))
160
161 conversion_tables = cfg.get("SuperAnimalConversionTables", {})
162 if conversion_tables is None or super_animal not in conversion_tables:
163 raise ValueError(
164 f"No conversion table defined in the project config for {super_animal}."
165 "Call deeplabcut.modelzoo.create_conversion_table to create one."
166 )
167
168 sa_cfg = get_super_animal_project_cfg(super_animal)
169 conversion_table = ConversionTable(
170 super_animal=super_animal,
171 project_bodyparts=get_bodyparts(cfg),
172 super_animal_bodyparts=sa_cfg["bodyparts"],
173 table=conversion_tables[super_animal],
174 )
175 return conversion_table
176
177
178def read_conversion_table_from_csv(csv_path):

Callers

nothing calls this directly

Calls 5

read_configFunction · 0.90
ConversionTableClass · 0.90
get_bodypartsFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected