Skip to content

copick process filter-components

utils

Filter connected components in segmentations by size.

Plugin command — copick-utils

This command is provided by the copick-utils plugin, not copick core. Install it to make this command available:

pip install copick-utils

See the plugin system guide for details.

copick process filter-components input
Input
copick process filter-components output
Output

Filter connected components in segmentations by size.

Usage

copick process filter-components [OPTIONS]

Description

This command identifies connected components in a segmentation and removes those that fall outside the specified size range. Sizes can be given in cubic angstroms (default) or cubic voxels via --size-unit, and component adjacency is controlled by --connectivity (face = 6-connected, face-edge = 18-connected, all = 26-connected).

Pass --keep-largest N to retain only the N largest components by voxel count, applied on top of any --min-size/--max-size limits. Run copick process seg-stats first to inspect component sizes and choose sensible thresholds.

URI Format

Segmentations: name:user_id/session_id@voxel_spacing

Options

Option Type Default Description
-c, --config path Path to the configuration file.
--debug / --no-debug boolean flag False Enable debug logging.

Input Options

Option Type Default Description
--run-names, -r text · multiple Specific run names to process (default: all runs).
--input, -i COPICK_URI required Input segmentation URI (format: name:user_id/session_id@voxel_spacing). Supports glob patterns.

Tool Options

Option Type Default Description
--connectivity, -cn choice (face | face-edge | all) all Connectivity for connected components (face=6-connected, face-edge=18-connected, all=26-connected).
--min-size float Minimum component volume to keep (optional). Unit set by --size-unit.
--max-size float Maximum component volume to keep (optional). Unit set by --size-unit.
--size-unit choice (angstrom | voxel) angstrom Unit for --min-size and --max-size: 'angstrom' for ų, 'voxel' for cubic voxels.
--keep-largest integer Keep only the N largest connected components by voxel count (e.g. 1 = keep only the single largest). Applied in addition to any --min-size/--max-size filter.
--workers, -w integer 8 Number of worker processes.

Output Options

Option Type Default Description
--output, -o COPICK_URI required Output segmentation URI. Supports smart defaults (e.g., "membrane", "membrane/my-session", or "/my-session"). Full format: object_name:user_id/session_id@voxel_spacing.

Examples

# Remove small noise components (keep only larger than 50000 ų)
copick process filter-components -i "membrane:user1/auto-001@10.0" -o "membrane_clean" --min-size 50000

# Filter by cubic voxels instead of angstroms
copick process filter-components -i "membrane:user1/auto-001@10.0" -o "membrane_clean" \
    --min-size 50 --size-unit voxel

# Keep only medium-sized components (between 10000 and 1000000 ų)
copick process filter-components -i "particles:user1/.*@10.0" -o "particles_filtered" \
    --min-size 10000 --max-size 1000000

# Keep only the single largest connected component
copick process filter-components -i "membrane:user1/auto-001@10.0" -o "membrane_main" --keep-largest 1

See also