Skip to content

Old keypoints are erased when resuming labelling if config.yaml is loaded before labeled-data #161

@johnmbarrett

Description

@johnmbarrett

Surprised this issue hasn't been reported before, but I went through every issue title on this repository and couldn't find an obvious match

If you partially label frames with napari, then save and close to come back later, the new labels added in a later session erase the old ones if you load config.yaml before loading the frames to be labelled. This is, to my mind, counter-intuitive behaviour that is not adequately explained in the UI and can cause catastrophic data loss without warning.

Steps to reproduce

  1. Download and unzip this DLC project folder
  2. Open napari by typing napari on the command line (after having activated any necessary virtual environments)
  3. Select Plugins->Keypoint controls (napari-deeplabcut) from the menu bar
  4. Drag and drop the config.yaml from the attached folder into the central panel of the napari window
  5. Drag and drop the folder labeled-data/test from the attached folder into the central panel of the napari window
  6. Click somewhere to label bodypart1
  7. Save by pressing Ctrl+S
  8. Close napari
  9. Repeat steps 2-5
  10. Verify that bodypart1 is still labelled
  11. Select bodypart2 from the Keypoint selection drop down on the rightmost panel
  12. Click somewhere else to label bodypart 2
  13. Repeat steps 7-9

Expected behaviour

bodypart1 and bodypart2 are both labelled and both pairs of coordinates appear in labeled-data/test/CollectedData_John.csv

Actual behaviour

Only bodypart2 is labelled when you open the third time and bodypart1's coordinates are erased from labeled-data/test/CollectedData_John.csv

Additional info

While this behaviour is implied by the prompt that appears in the middle panel when loading the napari-deeplabcut plugin ("Drop a folder from within a DeepLabCut's labeled-data directory, and, if labeling from scratch, the corresponding project's config.yaml file" (emphasis mine)), I find this behaviour unsatisfactory, counter-intuitive, and inadequately sign-posted in a way that can cause users to lose data (indeed, already has in my case).

First, as a general user interaction principle, users should be warned and given the option to abort when operations have potentially catastrophic side effects (in this case, overwriting existing data). The most common comparison would be in most programs, the Save As... dialogue box warns you if you try to save a new file the same name as an old one.

Second, it is counter-intuitive that the way you open the data should affect how the data is saved. As I say, this is implied by the prompt, but understanding what is about to happen requires careful reading of an ambiguously worded prompt written in dark grey text on a black background. It's better not to rely on users reading things at all, but if you are going to make them read things, the behaviour should be spelled out more explicitly.

In my opinion, the default behaviour when labelling new keypoints/frames in an existing dataset should always be to add to that dataset, not overwrite the old keypoints. If the current behaviour is intended or there's some technical reason why it cannot be changed, it should be explicitly spelled out* and users should be warned when loading and/or saving (ideally both) a dataset in such a way that will cause old labels to be erased, and given the option to abort. If the current behaviour is going to remain, and there is a warning on saving, ideally the warning would give three options: overwrite (current behaviour), merge (old and new are both saved, my preferred default behaviour), cancel (nothing happens).

*i.e. the prompt should be something like "To label a dataset from scratch, drop the config.yaml from a DeepLabCut project and a folder from within its labeled-data directory (warning: this will erase any existing labels). To continue labeling a dataset, drop only a folder from within a DeepLabCut project's labeled-data directory".

Environment info

OS: Windows 11 Enterprise version 24H2 build 26100.7462 experience 1000.26100.275.0
Python version: 3.10.14
conda version: 24.5.0
deeplabcut version: 3.0.0rc1
napari version: 0.4.18
napari-deeplabcut version: 0.2.1.7

Please let me know if you need any more info

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghigh priorityShould be addressed ASAP

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions