Skip to content

CopickPicks

copick.models.CopickPicks

Encapsulates all data pertaining to a specific set of picked points. This includes the locations, orientations, and other metadata for the set of points.

Attributes:

  • run (CopickRun) –

    Reference to the run this pick belongs to.

  • meta (CopickPicksFile) –

    Metadata for this pick.

  • points (List[CopickPoint]) –

    Points for this pick. Either populated from storage or lazily loaded when CopickPicks.points is accessed for the first time.

  • from_tool (bool) –

    Flag to indicate if this pick was generated by a tool.

  • pickable_object_name (str) –

    Pickable object name from CopickConfig.pickable_objects[...].name

  • user_id (str) –

    Unique identifier for the user or tool name.

  • session_id (str) –

    Unique identifier for the pick session

  • trust_orientation (bool) –

    Flag to indicate if the angles are known for this pick or should be ignored.

  • color (Union[Tuple[int, int, int, int], None]) –

    Color of the pickable object this pick belongs to.

__init__

__init__(run: CopickRun, file: CopickPicksFile)

Parameters:

  • run (CopickRun) –

    Reference to the run this pick belongs to.

  • file (CopickPicksFile) –

    Metadata for this set of points.

load

load() -> CopickPicksFile

Load the points from storage.

Returns:

store

store()

Store the points (set using CopickPicks.points property).

refresh

refresh() -> None

Refresh the points from storage.

delete

delete() -> None

Delete the pick record.

numpy

numpy() -> Tuple[np.ndarray, np.ndarray]

Return the points as a [N, 3] numpy array (N, [x, y, z]) and the transforms as a [N, 4, 4] numpy array. Format of the transforms is:

[[rxx, rxy, rxz, tx],
 [ryx, ryy, ryz, ty],
 [rzx, rzy, rzz, tz],
 [  0,   0,   0,  1]]

Returns:

  • Tuple[ndarray, ndarray] –

    Tuple[np.ndarray, np.ndarray]: The picks and transforms as numpy arrays.

instance_ids

instance_ids() -> np.ndarray

Return the instance IDs of the points as a [N] integer array.

For filament objects the instance ID is the filament ID (starting at 1; 0 means unassigned).

scores

scores() -> np.ndarray

Return the scores of the points as a [N] float array (1.0 where a point has no score).

full_positions

full_positions() -> np.ndarray

Return the particle centres as a [N, 3] array in Angstrom: each point's location plus the translation of its transform, which holds shifts such as those refined during subtomogram averaging.

Use this, not the locations returned by numpy(), wherever a particle is placed, drawn or extracted.

from_numpy

from_numpy(positions: ndarray, transforms: Optional[ndarray] = None, instance_ids: Optional[ndarray] = None, scores: Optional[ndarray] = None) -> None

Set the points and transforms from numpy arrays, and store them.

Parameters:

  • positions (ndarray) –

    [N, 3] numpy array of positions (N, [x, y, z]).

  • transforms (Optional[ndarray], default: None ) –

    [N, 4, 4] numpy array of orientations. If None, transforms will be set to the identity matrix. Format of the transforms is:

    [[rxx, rxy, rxz, tx],
     [ryx, ryy, ryz, ty],
     [rzx, rzy, rzz, tz],
     [  0,   0,   0,  1]]
    

  • instance_ids (Optional[ndarray], default: None ) –

    [N] integer array of instance IDs (>= 0). For filament objects, the filament ID of each point (starting at 1). If None, every point gets 0.

  • scores (Optional[ndarray], default: None ) –

    [N] array of finite scores. If None, every point gets 1.0.

Raises:

  • ValueError –

    If the array lengths differ, an instance ID is negative or not an integer, or a score is not finite.

df

df(format: str = 'relion', **kwargs) -> pd.DataFrame

Returns the points as a pandas DataFrame with columns based on the format.

For format="relion", keyword arguments go to copick.util.relion.picks_to_df_relion (voxel_spacing, tilt_series_pixel_size, tomogram_center).

from_df

from_df(df: DataFrame, format: str = 'relion', **kwargs) -> None

Set the points from a pandas DataFrame with columns based on the format.

For format="relion", keyword arguments go to copick.util.relion.relion_df_to_picks (optics, tilt_series_pixel_size, tomogram_center, relion_version).