MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / convert2_maDLC

Function convert2_maDLC

deeplabcut/utils/auxfun_multianimal.py:236–361  ·  view source on GitHub ↗

Converts single animal annotation file into a multianimal annotation file, by introducing an individuals column with either the first individual in individuals list in config.yaml or whatever is passed via "forceindividual". ---------- config : string Full path of the c

(config, userfeedback=True, forceindividual=None)

Source from the content-addressed store, hash-verified

234
235
236def convert2_maDLC(config, userfeedback=True, forceindividual=None):
237 """
238 Converts single animal annotation file into a multianimal annotation file,
239 by introducing an individuals column with either the first individual
240 in individuals list in config.yaml or whatever is passed via "forceindividual".
241
242 ----------
243 config : string
244 Full path of the config.yaml file as a string.
245
246 userfeedback: bool, optional
247 If this is set to false during automatic mode then frames for all videos are extracted. The user can set
248 this to true, which will result in a dialog,
249 where the user is asked for each video if (additional/any) frames from this video should be extracted. Use
250 this, e.g. if you have already labeled
251 some folders and want to extract data for new videos.
252
253 forceindividual: None default
254 If a string is given that is used in the individuals column.
255
256 Examples
257 --------
258 Converts mulianimalbodyparts under the 'first individual' in individuals list in config.yaml
259 and uniquebodyparts under 'single'
260 >>> deeplabcut.convert2_maDLC('/socialrearing-task/config.yaml')
261
262 --------
263 Converts mulianimalbodyparts under the individual label mus17 and uniquebodyparts under 'single'
264 >>> deeplabcut.convert2_maDLC('/socialrearing-task/config.yaml', forceindividual='mus17')
265 """
266
267 cfg = auxiliaryfunctions.read_config(config)
268 videos = cfg["video_sets"].keys()
269 video_names = [trainingsetmanipulation._robust_path_split(i)[1] for i in videos]
270 folders = [Path(config).parent / "labeled-data" / Path(i) for i in video_names]
271
272 individuals, uniquebodyparts, multianimalbodyparts = extractindividualsandbodyparts(cfg)
273
274 if forceindividual is None:
275 if len(individuals) == 0:
276 print("At least one individual should exist...")
277 folders = []
278 forceindividual = ""
279 else:
280 forceindividual = individuals[0] # note that single is added at then end!
281
282 if forceindividual == "single": # no specific individual ()
283 if len(multianimalbodyparts) > 0: # there should be an individual name...
284 print("At least one individual should exist beyond 'single', as there are multianimalbodyparts...")
285 folders = []
286
287 for folder in folders:
288 if userfeedback:
289 print("Do you want to convert the annotation file in folder:", folder, "?")
290 askuser = input("yes/no")
291 else:
292 askuser = "yes"
293

Callers

nothing calls this directly

Calls 3

keysMethod · 0.80
read_configMethod · 0.45

Tested by

no test coverage detected