Skip to content

Labeling Guide: What to Label, Shape Choices & Common Pitfalls

When you first open a recording in Annolid, the hardest question is rarely which button to click—it is what to label, which shape type to use, and how to avoid subtle annotation mistakes that break tracking or COCO/YOLO export later.

This guide walks through how to choose shapes, worked lab examples, step-by-step GUI controls, and the most common pitfalls to avoid.

Annolid desktop GUI displaying mouse083_task1_annotator1 with instance polygons, keypoints, behavior overlay pill, Flags dock, and Label Instances

1. Decide Your Goal Before Drawing

Your downstream task determines how you name labels and which shapes you draw:

Downstream Goal What to Draw How to Name Labels Typical Seed Volume
Track specific individuals across one video (Cutie, SAM3, DINOv3) Polygon (or AI-Polygon) per animal, plus optional Points for keypoints Unique identity per animal (resident, intruder, mouse_1, mouse_2) Start with 1 clean frame, then add correction frames only where drift or swaps occur
Train a reusable detector / segmenter across many animals or videos (YOLO, Mask R-CNN, COCO) Polygon (for segmentation) or Rectangle (for detection) around every target instance Shared class name across individuals (mouse, object, feeder) Start with 20–50 diverse frames spanning poses, lighting, and positions
Measure animal–object or social interactions Polygons for each actor/object + Rectangle enclosing the interaction region (and/or Frame Flags / Timeline bouts) Distinct actor/object classes + explicit interaction label (mouse, object, interaction) Depends on model vs. rule-based distance/overlap analysis
Estimate body-part pose / kinematics Animal Polygon or Rectangle + named Point keypoints sharing the same group_id Canonical anatomical names (nose, left_ear, right_ear, neck, tail_base) 1+ seed frame for DINOv3/TAPNext/CoWTracker; 30–100+ diverse frames for trained pose models
Quantify arena occupancy / place preference Closed Polygon, Rectangle, or Circle created via Video Tools → Zones Stable chamber names (left_chamber, center, right_chamber) tagged as semantic_type=zone Drawn once on 1 frame and saved as a reusable *_zones.json file
Score temporal ethogram behaviors Flags dock checkboxes or Timeline intervals (optional spatial shapes) Shared ethogram catalog in project.annolid.json (grooming, rearing, investigation) Scored continuously across time bouts

2. Choosing the Right Shape Tool

Every shape saved by Annolid uses standard LabelMe-compatible geometry:

Shape Tool Shortcut / Menu How to Draw Best Used For Export Notes
AI-Polygon Right-click → Create AI-Polygon (or toolbar) Click inside the target (add Shift+Click negative points to exclude background), then Ctrl+Left-Click (Cmd+Click on macOS) to finish Fast, tight outlines of animals, organs, and irregular arena objects Saves as a standard simplified polygon (>= 3 vertices)
Polygon Ctrl+N Click at least 3 distinct vertices around the boundary; click back on the first vertex, double-click, or press Enter to close Manual outlines of animals, novel objects, bedding regions, or irregular zones Must have at least 3 distinct vertices and non-zero area for COCO/YOLO segmentation
Rectangle Ctrl+R Two separate clicks: click one corner, move the cursor, and click the opposite corner (not click-and-drag) Interaction/contact regions, bounding-box detection datasets, rectangular arena chambers Converted to a 4-corner polygon + tight bbox on COCO export
Oriented Rectangle Edit menu / toolbar → Oriented Rectangle 3 clicks (first edge endpoints + perpendicular extent); drag corners to resize or Shift+Drag to rotate Elongated animals or rotated objects where tight aligned boxes matter Exported as a 4-vertex polygon in COCO and OBB/polygon in YOLO
Point Ctrl+I (or Keypoint Sequencer Ctrl+Shift+K) Single left-click per landmark (Shift+Click marks an occluded keypoint) Anatomical keypoints (nose, ears, tail_base) or single-point centers Use Point mode—never Polygon mode—for single-point markers
Circle / Circle (3-Point) Edit menu / toolbar Center + edge click (2 clicks) or 3 points on the circumference Circular dishes, cylinders, burrow openings, circular zones Sampled to a 32-vertex polygon during COCO export
Line / Line Strip Edit menu / toolbar 2 clicks for a straight segment; multiple clicks + Ctrl+Click or double-click for an open polyline Scale bars (pixel-to-cm calibration), arena dividers, open midline/spine traces Open shapes; not exported as closed COCO segmentation masks
Flags & Timeline Flags / Timeline docks Toggle checkboxes or mark start/stop intervals Temporal behavior states (grooming, rearing, investigation, freezing) Exported to *_events.csv and BORIS/time-budget workflows

3. Worked Labeling Examples

Example 1: Mouse Interacting with an Object

Suppose you want to detect or analyze a mouse investigating a novel object (such as a block, cup, or teaball):

  1. Label the mouse with a Polygon (mouse):
  2. Use AI-Polygon (or Polygon Ctrl+N) to trace the mouse's body silhouette cleanly.
  3. Label the object with a second Polygon (object or novel_object):
  4. Trace the novel object as a separate closed polygon so its exact footprint and boundary are preserved.
  5. Label the interaction with a Rectangle (interaction or object_investigation):
  6. Switch to Rectangle (Ctrl+R), click one corner, and click the opposite corner to enclose the mouse + object contact area whenever the mouse is actively interacting with the object.
  7. Keep mouse and object labeled on all sampled frames (interacting or not), and draw the interaction rectangle only on frames where the interaction occurs.
Frame without contact:
  - polygon:   mouse
  - polygon:   object

Frame with active contact / investigation:
  - polygon:   mouse
  - polygon:   object
  - rectangle: interaction   (enclosing the contact region between mouse and object)

Alternative / Companion Pattern for Ethograms & Kinematics

If you want exact bout durations, latencies, or nose-to-object distances in addition to (or instead of) training an interaction box detector:

  • Add a nose Point (Ctrl+I) linked to the mouse, then compute nose-to-object boundary distances after tracking.
  • Score active bouts on the Timeline / Flags dock as object_investigation for BORIS-compatible time budgets and ethograms.

Example 2: Multi-Animal Social Interaction (Resident–Intruder)

Suppose two mice share a home cage and you want to track each animal and score social behavior:

  • For individual tracking (Cutie / SAM3 / DINOv3):
  • Outline mouse 1 with a Polygon labeled resident (e.g., group_id: 1).
  • Outline mouse 2 with a Polygon labeled intruder (e.g., group_id: 2).
  • Optional: add anatomical Points (nose, left_ear, right_ear, tail_base) with matching group_id (1 for resident, 2 for intruder) so multi-animal pose export keeps each animal's keypoints grouped accurately.
  • Optional: draw a Rectangle labeled social_interaction during close-contact frames, or score investigation / mount / attack in the Flags / Timeline dock.
  • For training a general mouse detector across new cages:
  • Give both mice the same shared class label (mouse) with distinct group_ids (1 and 2), so the model learns the class "mouse" rather than memorizing one specific animal.

See the Resident-Intruder End-to-End Walkthrough (mouse083_task1_annotator1) for a full real-data example.

Example 3: Spatial Zones & Place Preference

Suppose you have a 3-chamber or open-field arena:

  1. Open Video Tools → Zones (or load a 3×3 / chamber preset).
  2. Draw each arena region (left_chamber, center, right_chamber) using Polygon, Rectangle, or Circle.
  3. Save the layout as <rig>_zones.json.

Because zone shapes carry flags.semantic_type = "zone", Annolid automatically keeps them out of COCO/YOLO animal training datasets while applying them consistently to every video from that rig. See Draw Zones Quickstart.

Example 4: Pose Estimation (Instance + Keypoints)

When exporting to COCO Keypoints or YOLO Pose:

  1. Draw the animal's Polygon (or Rectangle) and set group_id (for example 1 for the first animal, 2 for the second).
  2. Switch to Point mode (Ctrl+I) or open Keypoint Sequencer (Ctrl+Shift+K).
  3. Click each anatomical landmark (nose, neck, left_hip, right_hip, tail_base) using the matching group_id (or <instance>:<keypoint> naming). Use Shift+Click for landmarks that are present but occluded (v=1).

See Pose Estimation Workflow for schema setup and skeleton edges.

4. Step-by-Step Labeling Workflow in the GUI

  1. Open your media: File → Open Video (recommended—frame extraction is optional) or File → Open Dir for extracted frames.
  2. Pick a clean seed frame: Scrub to a frame where all animals and objects are clearly visible and separated (avoid heavy motion blur or overlapping bodies on frame 0).
  3. Choose the right tool:
  4. AI-Polygon or Polygon (Ctrl+N) for outlines.
  5. Rectangle (Ctrl+R) for boxes and interaction regions.
  6. Point (Ctrl+I) for landmarks/keypoints.
  7. Correct mistakes immediately while drawing:
  8. Press Backspace or Delete while drawing to undo the last placed vertex.
  9. Press Esc to cancel the current unfinished shape.
  10. Switch to Edit Polygons (Ctrl+J) to move vertices, add a vertex on an edge (Ctrl+Shift+P), lock finished shapes (Ctrl+Shift+L), or delete a selected shape (Delete).
  11. Press Ctrl+Z to undo completed edits.
  12. Save your frame (Ctrl+S, or enable Auto Save with Ctrl+Alt+S):
  13. Annolid writes a LabelMe-compatible .json beside a sidecar .png frame inside <video_stem>/.
  14. Review in the Label Instances dock:
  15. Confirm every shape has the expected label, shape type, and group_id before running tracking or exporting to COCO/YOLO.

5. Common Pitfalls & How to Avoid Them

Pitfall What Goes Wrong How to Avoid / Fix It
Triple-clicking in Polygon mode thinking it makes a point Rapidly clicking in Polygon mode looks like a dot on screen, but in legacy LabelMe it creates a degenerate 1- or 2-point polygon. External labelme2coco converters error out because COCO polygons require at least 3 vertices (6 coordinates) and non-zero area. Always switch to Point mode (Ctrl+I) for single-point markers. Annolid's canvas now prevents closing a polygon with fewer than 3 distinct vertices (keep adding vertices or press Esc to cancel), and Annolid's built-in labelme2coco converter logs a warning and skips legacy < 3-vertex polygons rather than crashing—check export logs and fix any flagged JSONs so annotations are not omitted.
Clicking and dragging to draw a Rectangle In Annolid and LabelMe, Rectangle (Ctrl+R) uses two clicks (corner 1, then opposite corner 2). Clicking and releasing in the same spot—or double-clicking one spot—can create a collapsed zero-area rectangle. Click once at the first corner, release the button, move the pointer to the opposite corner, and click a second time.
Using too few or too many polygon vertices < 3 vertices is invalid; a crude 3–4 point polygon misses curved bodies; tracing 100+ dense vertices slows editing and inflates JSON files. Aim for 8–25 vertices around curved silhouettes, or use AI-Polygon (which auto-simplifies masks to clean contours).
Inconsistent label spelling, casing, or spaces Labeling mouse_1 on frame 10, Mouse_1 on frame 20, and mouse 1 on frame 30 splits one animal into three separate classes during COCO, YOLO, and CSV export. Define canonical names once in project.annolid.json (File → Project Schema…) or pass --labels labels.txt, and select from the Labels list instead of retyping.
Choosing an occluded or overlapping seed frame If two animals touch or overlap on your first seed frame, pixel masks can bleed across boundaries and cause immediate identity swaps in Cutie or SAM3. Scrub to a frame where every subject is clearly separated. Separate touching polygons cleanly before starting tracking.
Missing group_id on multi-animal keypoints In COCO keypoints export, ungrouped point shapes without group_id (or <instance>: prefixes) are merged into one default instance per frame—mixing keypoints from two animals together. Assign a matching numeric group_id to each animal's body polygon and all of its keypoints, or use the Keypoint Sequencer dock.
Drawing arena zones as ordinary polygons Regular polygons get exported as trainable object classes during COCO/YOLO conversion. Create zones via Video Tools → Zones (which sets flags.semantic_type = "zone") so exporters exclude zones automatically.
Editing labels.txt and deleting header rows Legacy labelme converters expect __ignore__ and _background_ as the first two entries if a labels.txt file is supplied. Keep __ignore__ and _background_ intact when using legacy labels.txt files, or let Annolid's built-in exporter auto-collect labels from your JSONs / project.annolid.json.
Separating frame .json and .png files Moving .json files without their companion frame .png images causes export tools to skip frames whose imagePath cannot be resolved. Always copy or archive the whole <video_stem>/ folder (both .json and .png files together).

6. Quick Pre-Export Check (Before COCO or YOLO Conversion)

Before clicking File → COCO format (python -m annolid.main --labelme2coco <dir>) or File → Convert Labelme to YOLO format:

  1. Check the Label Instances dock on a few representative frames: remove any stray duplicate shapes or mislabeled objects.
  2. Verify shape types match your export mode:
  3. COCO segmentation (output_mode="segmentation"): polygons (>= 3 distinct vertices), rectangles, oriented rectangles, circles, or masks.
  4. COCO keypoints (output_mode="keypoints"): point shapes (grouped per animal via group_id when multiple animals appear in a frame), optionally paired with a pose_schema.json.
  5. Verify boolean flags for external LabelMe editors if you edited JSONs programmatically:
    python -m annolid.annotation.sanitize_labelme_json /path/to/annotated_dir
    
  6. Watch the export log: Annolid's labelme2coco logs a clear warning if any legacy JSON contains a polygon with fewer than 3 distinct vertices so you can open that exact file and fix it before training.