Skip to content

CopickFilamentCurve

copick.models.CopickFilamentCurve

Bases: BaseModel

The editable or fitted representation of a filament's centreline, from which its points are regenerated.

The curve is optional; points stay the canonical centreline. See docs/datamodel.md (Filaments, Editable curves) for the specification, and copick.util.filaments for the reference implementation.

Attributes:

  • kind (str) –

    "catmull-rom" (passes through its control points; interactive tracing), "linear", or "bspline" (a fitted B-spline, stored exactly). Other kinds are kept as they are but never evaluated.

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

    [[x, y, z], ...] in Angstrom, in the direction of points; the B-spline coefficients for "bspline".

  • step (float) –

    Arc-length spacing of the regenerated points, in Angstrom.

  • alpha (Optional[float]) –

    Catmull-Rom parameterisation; 0.5 (centripetal) when not given.

  • degree (Optional[int]) –

    B-spline degree (1-5).

  • knots (Optional[List[float]]) –

    B-spline knots, clamped.

  • smoothing (Optional[float]) –

    The fit's smoothing factor (scipy's s). Descriptive only.

model_config

model_config = ConfigDict(extra='allow')

kind

kind: str = Field(min_length=1)

control_points

control_points: List[Tuple[float, float, float]]

step

step: float = Field(gt=0)

alpha

alpha: Optional[float] = None

degree

degree: Optional[int] = None

knots

knots: Optional[List[float]] = None

smoothing

smoothing: Optional[float] = Field(None, ge=0)

is_known

is_known: bool

Whether this copick evaluates the curve's kind.

passes_through_control_points

passes_through_control_points: bool

Whether the curve passes through every control point (all but bspline).

validate_curve

validate_curve() -> CopickFilamentCurve

Check a curve of a known kind against its kind's rules.

evaluate

evaluate() -> np.ndarray

The (N, 3) centreline points regenerated from this curve.

anchors

anchors() -> np.ndarray

The points the curve passes through: its control points, or a B-spline at its knots.

is_current_for

is_current_for(points) -> bool

Whether this curve still describes points (never, for an unknown kind).

reversed

reversed() -> CopickFilamentCurve

The same curve traversed backwards.

from_tck

from_tck(tck, step: float, smoothing: Optional[float] = None, scale: float = 1.0) -> CopickFilamentCurve

A bspline curve from scipy's splprep output.

Parameters:

  • tck –

    (knots, [cx, cy, cz], degree), with the coefficients of the x, y and z coordinates.

  • step (float) –

    Arc-length spacing of the regenerated points, in Angstrom.

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

    The fit's smoothing factor, recorded on the curve.

  • scale (float, default: 1.0 ) –

    Factor from the fit's coordinates to Angstrom (the voxel spacing for a fit in voxels).

Returns: