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.features
is accessed for the first time. -
tomo_type
(str
) –Type of the tomogram.
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
None
if 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.
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.