Skip to content

Commit 2438b79

Browse files
authored
Merge pull request #75 from DeepLabCut/color_config
Update color scheme to match the config's colormap
2 parents 1adae07 + 80ec4ea commit 2438b79

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Only when saving segmentation masks does a save file dialog pop up to name the d
6262
keypoint annotations are otherwise automatically saved in the corresponding folder as `CollectedData_<ScorerName>.h5`.
6363
- As a reminder, DLC will only use the H5 file; so be sure if you open already labeled images you save/overwrite the H5.
6464
- Note, before saving a layer, make sure the points layer is selected. If the user clicked on the image(s) layer first, does `Save As`, then closes the window, any labeling work during that session will be lost!
65-
- Modifying and then saving points in a `machinelabels...` layer will add to or overwrite the existing `CollectedData` layer and will **not** save to the `machinelabels` file.
65+
- Modifying and then saving points in a `machinelabels...` layer will add to or overwrite the existing `CollectedData` layer and will **not** save to the `machinelabels` file.
6666

6767

6868
### Video frame extraction and prediction refinement
@@ -105,14 +105,16 @@ Suggested workflows, depending on the image folder contents:
105105

106106
***Note that if a new body part has been added to the `config.yaml` file after having started to label, loading the config in the GUI is necessary to update the dropdown menus and other metadata.***
107107

108+
***As `viridis` is `napari-deeplabcut` default colormap, loading the config in the GUI is also needed to update the color scheme.***
109+
108110
3. **Refining labels** – the image folder contains a `machinelabels-iter<#>.h5` file.
109111

110112
The process is analog to *2*.
111113
Open *napari* and open an image folder.
112-
If the video was originally labeled, *and* had outliers extracted it will contain a `CollectedData_<ScorerName>.h5` file and a `machinelabels-iter<#>.h5` file. In this case, select the `machinelabels` layer in the GUI, and type `e` to show edges. Red indicates likelihood < 0.6. As you navigate through frames, images with labels with edges will need to be refined (moved, deleted, etc). Images with labels without edges will be on the `CollectedData` (previous manual annotations) layer and shouldn't need refining. However, you can switch to that layer and fix errors. You can also right-click on the `CollectedData` layer and select `toggle visibility` to hide that layer. Select the `machinelabels` layer before saving which will append your refined annoations to `CollectedData`.
113-
114-
If the folder only had outliers extracted and wasn't originally labeled, it will not have a `CollectedData` layer. Work with the `machinelabels` layer selected to refine annoation positions, then save.
115-
114+
If the video was originally labeled, *and* had outliers extracted it will contain a `CollectedData_<ScorerName>.h5` file and a `machinelabels-iter<#>.h5` file. In this case, select the `machinelabels` layer in the GUI, and type `e` to show edges. Red indicates likelihood < 0.6. As you navigate through frames, images with labels with edges will need to be refined (moved, deleted, etc). Images with labels without edges will be on the `CollectedData` (previous manual annotations) layer and shouldn't need refining. However, you can switch to that layer and fix errors. You can also right-click on the `CollectedData` layer and select `toggle visibility` to hide that layer. Select the `machinelabels` layer before saving which will append your refined annotations to `CollectedData`.
115+
116+
If the folder only had outliers extracted and wasn't originally labeled, it will not have a `CollectedData` layer. Work with the `machinelabels` layer selected to refine annotation positions, then save.
117+
116118
In this case, it is not necessary to open the DLC project's `config.yaml` file, as all necessary metadata is read from the `h5` data file.
117119

118120
Saving works as described in *1*.
@@ -134,14 +136,14 @@ graph TD
134136
id4[Add labels to, or modify in, \n `CollectedData...` layer and save that layer]
135137
id5[Modify labels in `machinelabels` layer and save \n which will create a `CollectedData...` file]
136138
id6[Have you refined some labels from the most recent iteration and saved already?]
137-
id7["All extracted frames are already saved in `CollectedData...`.
139+
id7["All extracted frames are already saved in `CollectedData...`.
138140
1. Hide or trash all `machinelabels` layers.
139141
2. Then modify in and save `CollectedData`"]
140142
id8["
141-
1. hide or trash all `machinelabels` layers except for the most recent.
142-
2. Select most recent `machinelabels` and hit `e` to show edges.
143+
1. hide or trash all `machinelabels` layers except for the most recent.
144+
2. Select most recent `machinelabels` and hit `e` to show edges.
143145
3. Modify only in `machinelabels` and skip frames with labels without edges shown.
144-
4. Save `machinelabels` layer, which will add data to `CollectedData`.
146+
4. Save `machinelabels` layer, which will add data to `CollectedData`.
145147
- If you need to revisit this video later, ignore `machinelabels` and work only in `CollectedData`"]
146148
147149
id1 -->|I need to manually label new frames \n or fix my labels|id2

src/napari_deeplabcut/_widgets.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,17 +524,20 @@ def on_insert(self, event):
524524
self.viewer.status = f"New keypoint{'s' if len(diff) > 1 else ''} {', '.join(diff)} found."
525525
for _layer, store in self._stores.items():
526526
_layer.metadata["header"] = layer.metadata["header"]
527-
_layer.metadata["face_color_cycles"] = layer.metadata["face_color_cycles"]
528-
_layer.face_color = "label"
529-
_layer.face_color_cycle = layer.metadata["face_color_cycles"]["label"]
530-
_layer.events.face_color()
531527
store.layer = _layer
532528

533529
for menu in self._menus:
534530
menu._map_individuals_to_bodyparts()
535531
menu._update_items()
536532

537-
self._update_color_scheme()
533+
# Always update the colormap to reflect the one in the config.yaml file
534+
for _layer, store in self._stores.items():
535+
_layer.metadata["face_color_cycles"] = layer.metadata["face_color_cycles"]
536+
_layer.face_color = "label"
537+
_layer.face_color_cycle = layer.metadata["face_color_cycles"]["label"]
538+
_layer.events.face_color()
539+
store.layer = _layer
540+
self._update_color_scheme()
538541

539542
# Remove the unnecessary layer newly added
540543
QTimer.singleShot(10, self.viewer.layers.pop)

0 commit comments

Comments
 (0)