Skip to content

Fix order-match-crop pipeline review findings - #12

Open
nathan-cain15 wants to merge 2 commits into
Imageomics:image-proceesingfrom
nathan-cain15:order-match-crop-review-fixes
Open

Fix order-match-crop pipeline review findings#12
nathan-cain15 wants to merge 2 commits into
Imageomics:image-proceesingfrom
nathan-cain15:order-match-crop-review-fixes

Conversation

@nathan-cain15

Copy link
Copy Markdown
  • merge_annotations.py: correct parse_cvat_xml return type/docstring to reflect the (annotations, dimensions) tuple; make dry-run simulation mirror the real merge path's skip-on-unexpected-trayID behavior for -and- images
  • crop_and_link.py: use individual_ids to write a sidecar {stem}_ids.csv linking each crop's position/filename to its individualID; return actual saved-crop count instead of the ordered box count
  • run_pipeline.sh: clean up temp SLURM job scripts on exit; fix output description to match actual {tray}_{N}.png + sidecar CSV naming
  • README.md: update docs to match the sidecar-CSV linking behavior

- merge_annotations.py: correct parse_cvat_xml return type/docstring
  to reflect the (annotations, dimensions) tuple; make dry-run
  simulation mirror the real merge path's skip-on-unexpected-trayID
  behavior for -and- images
- crop_and_link.py: use individual_ids to write a sidecar
  {stem}_ids.csv linking each crop's position/filename to its
  individualID; return actual saved-crop count instead of the
  ordered box count
- run_pipeline.sh: clean up temp SLURM job scripts on exit; fix
  output description to match actual {tray}_{N}.png + sidecar CSV
  naming
- README.md: update docs to match the sidecar-CSV linking behavior

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 03:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses review findings in the “order-match-crop” pipeline by aligning behavior and documentation around CVAT merge semantics and crop-to-individualID linkage, while improving operational hygiene for SLURM job-script temp files.

Changes:

  • Updates CVAT XML parsing/typing and makes dry-run simulation match real merge “skip on unexpected trayID” behavior for -and- images.
  • Adds sidecar {stem}_ids.csv generation to map crop position/filename → individualID, and returns the actual number of crops saved.
  • Cleans up temporary SLURM job scripts on exit and updates pipeline docs/messages to reflect the sidecar mapping.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
order_match_crop_for_order_finalized/run_pipeline.sh Adds temp-script cleanup on exit and updates user-facing output descriptions.
order_match_crop_for_order_finalized/README.md Updates pipeline documentation to describe sidecar _ids.csv linkage behavior.
order_match_crop_for_order_finalized/merge_annotations.py Corrects parse_cvat_xml return type/docstring and aligns dry-run simulation with real merge behavior for unexpected trayIDs.
order_match_crop_for_order_finalized/crop_and_link.py Writes {stem}_ids.csv sidecar mapping and returns actual saved-crop count; updates count mismatch messaging.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +31 to +33
TMP_FILES=()
cleanup() { rm -f "${TMP_FILES[@]}"; }
trap cleanup EXIT
Comment on lines +40 to +44
def parse_cvat_xml(
xml_path: Path,
) -> tuple[dict[str, list[tuple[float, float, float, float]]], dict[str, tuple[int, int]]]:
"""
Return a dict mapping image name → list of (xtl, ytl, xbr, ybr) float tuples.
Return a 2-tuple of:
Comment on lines +297 to +302
if id_rows:
ids_csv = output_dir / f"{file_stem}_ids.csv"
with open(ids_csv, "w", newline="") as fh:
writer = csv.writer(fh)
writer.writerow(["position", "filename", "individualID"])
writer.writerows(id_rows)
echo ""
echo "Output subfolders:"
echo " ${OUTPUT}/cropped/ — beetle crops named {individualID}.png"
echo " ${OUTPUT}/cropped/ — beetle crops named {tray}_{N}.png, plus a {tray}_ids.csv linking each crop to its individualID"
```
Cropped/
├── cropped/ # beetle crops named {tray}_{N}.png, in spatial order
├── cropped/ # beetle crops named {tray}_{N}.png, in spatial order, plus {tray}_ids.csv linking each crop to its individualID
- run_pipeline.sh: guard EXIT cleanup trap so an empty TMP_FILES
  array doesn't call rm with no operands; clarify that cropped/
  output uses per-tray subfolders, not flat files
- merge_annotations.py: tighten parse_cvat_xml's local variable
  annotations to match its declared precise return types
- crop_and_link.py: only write the {stem}_ids.csv sidecar when every
  ordered box was actually saved (none skipped as out-of-bounds), so
  a partial crop set never produces a misleadingly-partial mapping
- README.md: fix output tree to reflect per-tray subfolders

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants