Repository navigation
fix: particle centres include shifts; skip filament objects - #161
Merged
Merged
Conversation
Shifts. copick's particle centre is location + t, with t the translation of the pick's transform; the datasets cropped at the location alone, so every pick carrying a shift (RELION imports with origins, refined poses) was extracted off-centre. CopickDataset, SimpleCopickDataset and MinimalCopickDataset now crop at location + t, as does the background exclusion and slab fitting from picks. Filaments. Picks of an object declared a filament (copick's is_filament, or metadata["copick"]["filament"] on copick < 1.28) sample one continuous structure rather than separate particles, so they are no longer a particle class by default. They still keep background samples away. New options on all three datasets: include_filaments=False and object_names=None (train on these objects only; picks of the others also keep background away). The background sample count still follows the training particles. Cache files carry the object selection in their name (_objs-all, _objs-<hash>, _fil), so caches built before this change, or for another selection, are not reused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uermel
marked this pull request as ready for review
October 5, 2026 17:38
uermel
added a commit
that referenced
this pull request
Oct 6, 2026
) ## Summary `v2.0` twin of #161, cherry-picked. The description and the reasoning are in #161; in short: - **Shifts:** particle crops are taken at `location + t`, the particle centre, not at `location`. That covers `CopickDataset`, `SimpleCopickDataset`, `MinimalCopickDataset`, the background exclusion and slab fitting. - **Filaments:** filament objects are no longer a particle class by default, and their picks still keep background samples away. The new options are `include_filaments` and `object_names`. - **Caches:** cache names carry the object selection, so caches cropped without shifts are not reused. **Cherry-pick:** two conflicts, both import lines. `v2.0`'s `copick_torch/dataset.py` and `minimal_dataset.py` already import `from .storage import get_level_array`; both imports are kept. Two tests needed `v2.0`'s storage layer: - `test_pick_selection` now patches `storage.get_level_array`, which `MinimalCopickDataset` uses on `v2.0`, instead of `zarr.open`. - The pick stubs in `test_slab_shape_lookup_does_not_read_array_payload` carry an identity `transformation`, as every copick point does, since slab fitting now takes each centre as `location + t`. **Depends on** copick/copick-pipeliner#4 reaching users first, as #161 does: pick sets it stored earlier carry their position in `t` as well. ## Tests - Full suite on `v2.0`'s lock: 99 passed (`v2.0` itself: 87; the 12 new ones come from #161's `test_pick_selection`). - Lint is clean with the repo's pinned ruff 0.3.4 and black 24.3.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
uermel
pushed a commit
that referenced
this pull request
Oct 6, 2026
🤖 I have created a release *beep* *boop* --- ## [1.2.1](copick-torch-v1.2.0...copick-torch-v1.2.1) (2026-10-06) ### 🐞 Bug Fixes * bump actions/setup-python from 6 to 7 ([#133](#133)) ([d3640f1](d3640f1)) * bump chanzuckerberg/github-actions from 6.29.4 to 6.32.0 ([#135](#135)) ([057024b](057024b)) * bump chanzuckerberg/github-actions from 6.32.0 to 6.35.0 ([#143](#143)) ([27e28ac](27e28ac)) * bump chanzuckerberg/github-actions from 6.35.0 to 6.41.2 ([#160](#160)) ([4813bf1](4813bf1)) * bump dask from 2026.3.0 to 2026.7.1 ([#145](#145)) ([2e0b09d](2e0b09d)) * bump matplotlib from 3.10.9 to 3.11.1 ([#148](#148)) ([0870732](0870732)) * bump monai from 1.5.2 to 1.6.0 ([#112](#112)) ([c6a70c4](c6a70c4)) * bump pandas from 3.0.4 to 3.0.5 ([#144](#144)) ([9e615a1](9e615a1)) * bump ruff from 0.15.20 to 0.15.21 ([#129](#129)) ([a6bd111](a6bd111)) * bump scikit-learn from 1.8.0 to 1.9.0 ([#131](#131)) ([1f3c8a6](1f3c8a6)) * bump simpleitk from 2.5.3 to 2.5.6 ([#147](#147)) ([ce1911d](ce1911d)) * bump torchvision from 0.26.0 to 0.28.0 ([#128](#128)) ([e3cac53](e3cac53)) * bump tox from 4.56.1 to 4.56.4 ([#130](#130)) ([d463215](d463215)) * particle centres include shifts; skip filament objects ([#161](#161)) ([2acedb1](2acedb1)) --- Merging this PR will release copick-torch on PyPI. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Shifts. copick's particle centre is
location + t, wheretis the pick transform's translation. The datasets cropped atlocationalone, so every pick carrying a shift was extracted off-centre: for example, RELION imports with origins, or refined poses. Now crops are taken atlocation + tin:CopickDataset,SimpleCopickDatasetandMinimalCopickDataset;Filaments. Picks along a filament sample one continuous structure, not separate particles.
is_filament, ormetadata["copick"]["filament"]on copick < 1.28, see feat: filament objects, pick identity, and RELION/EM pick geometry fixes copick#479) are no longer a particle class by default.include_filaments=False, andobject_names=Noneto train on those objects only. Picks of excluded objects also keep background away.Caches. Cache files carry the object selection in their name (
_objs-all,_objs-<hash>,_fil). Caches built before this change, which were cropped without shifts, or for another selection, are not reused.test_dataset_cachingexpectations are updated accordingly.Depends on copick/copick-pipeliner#4 reaching users first. Pick sets it stored earlier carry their position in
tas well, and would now be cropped at twice their position.Tests
New
tests/test_pick_selection.py:t;include_filaments,object_names);The touched set passes (49 tests:
test_pick_selection,test_background_sampling,test_simple_dataset,test_minimal_dataset,test_dataset_caching,test_slab_fitting,test_copick_dataset).Not addressed here, noted for a follow-up:
MinimalCopickDataset._sample_background_pointsdraws in voxels, compares against particle coordinates in Å, and then extracts the result as Å.🤖 Generated with Claude Code