CopickTomogram
copick.models.CopickTomogram
Encapsulates all data pertaining to a specific tomogram. This includes the features for this tomogram and the associated Zarr-store.
Attributes:
-
voxel_spacing(CopickVoxelSpacing) –Reference to the voxel spacing this tomogram belongs to.
-
meta(CopickTomogramMeta) –Metadata for this tomogram.
-
features(List[CopickFeatures]) –Features for this tomogram. Either populated from config or lazily loaded when
CopickTomogram.featuresis accessed for the first time. -
tomo_type(str) –Type of the tomogram.
link_id
Identifier of this tomogram within its run, as alignments name the tomograms they apply to.
shape
Shape (z, y, x) of the full-size tomogram, or None if it holds no data.
alignment_link
What this tomogram was reconstructed from, or None if unknown.
Resolved from, in order: an alignment of the run naming this (read-only) tomogram, the link recorded with the tomogram, and the link its source records (e.g. the CryoET Data Portal).
alignment
The alignment this tomogram was reconstructed with, or None if unknown.
tilt_series
The tilt series this tomogram was reconstructed from, or None if unknown.
get_features
Get feature maps by type.
Parameters:
-
feature_type(str) –Type of the feature map to retrieve.
Returns:
-
CopickFeatures(Union[CopickFeatures, None]) –The feature map with the given type, or
Noneif not found.
new_features
Create a new feature map object. Also creates the Zarr-store for the map in the storage backend.
Parameters:
-
feature_type(str) –Type of the feature map to create.
-
exist_ok(bool, default:False) –Whether to raise an error if the feature map already exists.
-
**kwargs–Additional keyword arguments for the feature map metadata.
Returns:
-
CopickFeatures(CopickFeatures) –The newly created feature map object.
Raises:
-
ValueError–If a feature map with the given type already exists for this tomogram.
zarr
Override to return the Zarr store for this tomogram. Also needs to handle creating the store if it doesn't exist.
set_alignment
set_alignment(alignment: Union[CopickAlignment, str, None], reference_offset: Optional[Tuple[float, float, float]] = None, strict: bool = False) -> None
Record the alignment this tomogram was reconstructed with, or remove the record.
A writable tomogram records the link itself. A read-only tomogram is named by the (writable) alignment instead; removing such a link restores the link the tomogram or its source record, if any.
Parameters:
-
alignment(Union[CopickAlignment, str, None]) –The alignment or its name;
Noneremoves the link. -
reference_offset(Optional[Tuple[float, float, float]], default:None) –Offset in Angstrom from this tomogram's CETS frame to the alignment's reference volume frame, if they do not share the alignment's rotation centre.
-
strict(bool, default:False) –Whether a tomogram whose extent differs from the alignment's reference volume by more than a voxel is an error rather than a warning.
Raises:
-
ValueError–If the alignment is not in this tomogram's run.
-
PermissionError–If neither the tomogram nor the alignment can record the link.
numpy
numpy(zarr_group: str = '0', x: slice = slice(None, None), y: slice = slice(None, None), z: slice = slice(None, None)) -> np.ndarray
Returns the content of the Zarr-File for this tomogram 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:
-
ndarray–np.ndarray: The tomogram as a numpy array.
from_numpy
Set the tomogram from a numpy array and compute multiscale pyramid. By default, three levels of the pyramid are computed.
Parameters:
-
data(ndarray) –The segmentation as a numpy array.
-
levels(int, default:3) –Number of levels in the multiscale pyramid.
-
dtype(Optional[dtype], default:float32) –Data type of the segmentation. Default is
np.float32.
set_region
set_region(data: 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 tomogram from a numpy array.
Parameters:
-
data(ndarray) –The tomogram'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.