Skip to content

CopickFilament

copick.models.CopickFilament

Bases: BaseModel

One traced filament: an ordered centreline polyline in tomogram coordinates.

Attributes:

  • instance_id (int) –

    Filament ID (>= 1), unique within its file. Picks sampled from this filament use it as their instance ID.

  • points (List[Tuple[float, float, float]]) –

    Ordered vertices [[x, y, z], ...] in Angstrom, at least two. Consecutive vertices should be no further apart than the trace's voxel spacing, so that linear interpolation follows the centreline.

  • polarity_known (bool) –

    Whether the point order follows the structure's polarity (meaningful for objects whose filament spec has polar: true).

  • score (float) –

    Confidence score.

  • radius (Optional[float]) –

    Tube radius in Angstrom, if measured.

  • metadata (Dict[str, Any]) –

    Additional metadata (user-defined contents).

  • curve (Optional[CopickFilamentCurve]) –

    The editable or fitted curve points were regenerated from, if any (see CopickFilamentCurve).

instance_id

instance_id: int = Field(ge=1)

points

points: List[Tuple[float, float, float]]

polarity_known

polarity_known: bool = False

score

score: float = 1.0

radius

radius: Optional[float] = Field(None, gt=0)

metadata

metadata: Dict[str, Any] = Field(default_factory=dict)

curve

curve: Optional[CopickFilamentCurve] = None

validate_points

validate_points(v) -> List[Tuple[float, float, float]]

At least two finite vertices.

none_to_empty_dict

none_to_empty_dict(v)

from_curve

from_curve(instance_id: int, curve: CopickFilamentCurve, **fields) -> CopickFilament

A filament whose points are regenerated from curve.

Parameters:

  • instance_id (int) –

    Filament ID (>= 1).

  • curve (CopickFilamentCurve) –

    The curve (a known kind).

  • **fields –

    Other CopickFilament fields (polarity_known, score, radius, metadata).

from_control_points

from_control_points(instance_id: int, control_points, step: float, kind: str = 'catmull-rom', alpha: float = 0.5, **fields) -> CopickFilament

A filament traced through control_points (catmull-rom or linear), with regenerated points.

Parameters:

  • instance_id (int) –

    Filament ID (>= 1).

  • control_points –

    (n, 3) control points in Angstrom, n >= 2, in order along the filament.

  • step (float) –

    Arc-length spacing of the regenerated points, in Angstrom (usually the voxel spacing).

  • kind (str, default: 'catmull-rom' ) –

    "catmull-rom" or "linear"; a bspline is made with from_curve.

  • alpha (float, default: 0.5 ) –

    Catmull-Rom parameterisation.

  • **fields –

    Other CopickFilament fields.

curve_is_current

curve_is_current() -> bool

Whether the filament has a curve of a known kind that still describes its points.

with_control_points

with_control_points(control_points, step: Optional[float] = None) -> CopickFilament

A copy with moved or new control points and regenerated points, keeping the curve's kind.

A bspline keeps its degree and knots, so it needs as many control points as before. A filament without a current curve of a known kind gets a catmull-rom curve.

Parameters:

  • control_points –

    The new (n, 3) control points in Angstrom.

  • step (Optional[float], default: None ) –

    Arc-length spacing of the regenerated points; default the curve's (or, without a curve, the median spacing of points).

editable_curve

editable_curve(tolerance: Optional[float] = None, step: Optional[float] = None, kinds: Iterable[str] = CURVE_KINDS) -> CopickFilamentCurve

The curve an editor should show: the filament's own if it is current and of one of kinds, otherwise a catmull-rom curve derived from points (copick.util.filaments.control_points_from_polyline).

Parameters:

  • tolerance (Optional[float], default: None ) –

    Largest distance of the derived curve from points, in Angstrom; default half step.

  • step (Optional[float], default: None ) –

    Spacing of the derived curve's points; default the median spacing of points.

  • kinds (Iterable[str], default: CURVE_KINDS ) –

    The curve kinds the editor supports.

editable_control_points

editable_control_points(tolerance: Optional[float] = None, step: Optional[float] = None, kinds: Iterable[str] = CURVE_KINDS) -> np.ndarray

The (n, 3) control points of editable_curve(...).

reversed

reversed() -> CopickFilament

The filament traversed backwards: points and the curve both reversed.