Skip to content

feat: seg2fil stores editable Catmull-Rom curves by default (v2.0) - #117

Merged
uermel merged 1 commit into
v2.0from
uermel/seg2fil-catmull-rom-v2
Oct 6, 2026
Merged

uermel merged 1 commit into
v2.0from
uermel/seg2fil-catmull-rom-v2

Conversation

@uermel

@uermel uermel commented Oct 6, 2026

Copy link
Copy Markdown
Member

Port of the main-line change to v2.0.

copick convert seg2fil stored every filament as its exact B-spline fit. Editors can move a B-spline's control points but not add or remove them, so curating automatic traces in ChimeraX-copick or napari-copick began with Convert to Catmull-Rom on each filament.

Change: seg2fil now stores a Catmull-Rom curve through the fitted spline by default. It is the same conversion the editors' Convert button does (CopickFilament.editable_curve): control points a voxel apart, within half a voxel of the fit. --curve bspline stores the exact fit as before, and metadata["fit"]["stored_curve"] records which one was stored.

On dataset 10521, run 35962, the three traced microtubules (370–740 nm) get 11–24 Catmull-Rom control points instead of 12–44 B-spline handles. The converted centrelines deviate from the fit by at most 6.5 Å (mean 2–3 Å), less than the fit's own smoothing (half a voxel RMS) and under one voxel.

fit-spline --filaments is unchanged and still stores B-splines.

Tests

  • The seg2fil test now expects Catmull-Rom curves.
  • A new test traces with --curve bspline: the stored curve is the exact fit, and the default Catmull-Rom points lie within half a voxel of it.
  • Full suite: 85 passed on main and 108 on v2.0 (locked environment).

🤖 Generated with Claude Code

seg2fil stored each filament as its exact B-spline fit, whose many control points editors can move but not add or
remove, so curating traces in ChimeraX-copick or napari-copick started with a manual conversion. It now stores a
Catmull-Rom curve through the fit by default: the editors' own conversion, with points a voxel apart and within half a
voxel of the fit, which is below the fit's smoothing and has fewer control points (12-24 instead of 23-44 for the
microtubules of dataset 10521 run 35962). `--curve bspline` stores the exact fit as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@uermel
uermel merged commit e768a0d into v2.0 Oct 6, 2026
6 checks passed
uermel pushed a commit that referenced this pull request Oct 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.0.0-alpha.4](copick-utils-v2.0.0-alpha.3...copick-utils-v2.0.0-alpha.4)
(2026-10-06)


### ✨ Features

* seg2fil stores editable Catmull-Rom curves by default (v2.0)
([#117](#117))
([e768a0d](e768a0d))

---
Merging this PR will publish a copick-utils alpha prerelease to PyPI.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
uermel added a commit that referenced this pull request Oct 19, 2026
…127)

The v2.0 counterpart of #126; the patch is identical.

Two filaments that touch end to end skeletonize as one bent branch with
no junction: a V, or one filament ending against another at an acute
angle. The pairing at junctions never sees the turn, so seg2fil traced
them as one hairpin filament. On dataset 10426 with easymode actin, such
joins turned by up to 159 degrees.

**Change**
- A chain from a semantic segmentation is now split wherever it turns by
more than `--max-bend` between its directions over the direction window
before and after a point. This is the same rule and window that
junctions use.
- Each piece loses one label radius at the split, as a branch does at a
junction, and the new ends are not extended.
- Closed chains and instance segmentations are kept whole.
- The run summary reports how many filaments were split.
- The split happens before fitting, so each piece is stored with the
default Catmull-Rom curve from #117 like any other filament.

**Effect**
- 10426 actin, run 16853 at threshold 0.2: kinks over 45 degrees drop
from 4.9% to 1.5% of filaments, and length-weighted straightness rises
from 0.956 to 0.987, with no change in traced length.
- 10521: none of the 102 microtubules traced on 58 tomograms changes.

**Tests**
- New `test_two_filaments_touching_end_to_end_are_two_filaments`: a V
traces as two straight filaments, with one split counted.
- Checked by hand: default seg2fil on the same V stores two straight
Catmull-Rom filaments.
- `test_filaments.py`, `test_converter_signatures.py` and
`test_run_names_option.py`: 53 passed on v2.0 with the locked
environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.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.

1 participant