Skip to content

CopickObject

copick.models.CopickObject

Object that can be picked or segmented in a tomogram.

Attributes:

  • meta (PickableObject) –

    Metadata for this object.

  • root (CopickRoot) –

    Reference to the root this object belongs to.

  • name (str) –

    Name of the object.

  • is_particle (bool) –

    Whether this object should be represented by points (True) or segmentation masks (False).

  • label (Union[int, None]) –

    Numeric label/id for the object, as used in multilabel segmentation masks. Must be unique.

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

    RGBA color for the object.

  • emdb_id (Union[str, None]) –

    EMDB ID for the object.

  • pdb_id (Union[str, None]) –

    PDB ID for the object.

  • map_threshold (Union[float, None]) –

    Threshold to apply to the map when rendering the isosurface.

  • radius (Union[float, None]) –

    Radius of the particle, when displaying as a sphere.

__init__(root: CopickRoot, meta: PickableObject)

Parameters:

  • root(CopickRoot)

    The copick project root.

  • meta (PickableObject) –

    The metadata for this object.

zarr() -> Union[None, MutableMapping]

Override this method to return a zarr store for this object. Should return None if CopickObject.is_particle is False or there is no associated map.

numpy(zarr_group: str = '0', x: slice = slice(None, None), y: slice = slice(None, None), z: slice = slice(None, None)) -> Union[None, np.ndarray]

Returns the content of the Zarr-File for this object as a numpy array. Multiscale group and slices are supported.

Parameters:

  • zarr_group (str, default: '0' ) –

    Zarr group to access.

  • x (slice, default: slice(None, None) ) –

    Slice for the x-axis.

  • y (slice, default: slice(None, None) ) –

    Slice for the y-axis.

  • z (slice, default: slice(None, None) ) –

    Slice for the z-axis.

Returns:

  • Union[None, ndarray]

    np.ndarray: The object as a numpy array.

from_numpy(data: np.ndarray, voxel_size: float, dtype: Optional[np.dtype] = np.float32) -> None

Set the object from a numpy array.

Parameters:

  • data (ndarray) –

    The segmentation as a numpy array.

  • voxel_size (float) –

    Voxel size of the object.

  • dtype (Optional[dtype], default: float32 ) –

    Data type of the segmentation. Default is np.float32.

set_region(data: np.ndarray, zarr_group: str = '0', x: slice = slice(None, None), y: slice = slice(None, None), z: slice = slice(None, None)) -> None

Set a region of the object from a numpy array.

Parameters:

  • data (ndarray) –

    The object's subregion as a numpy array.

  • zarr_group (str, default: '0' ) –

    Zarr group to access.

  • x (slice, default: slice(None, None) ) –

    Slice for the x-axis.

  • y (slice, default: slice(None, None) ) –

    Slice for the y-axis.

  • z (slice, default: slice(None, None) ) –

    Slice for the z-axis.