CopickTiltSeries
copick.models.CopickTiltSeries
Encapsulates a tilt series: a stack of 2D images (section, y, x) stored as a multiscale OME-Zarr image,
and its metadata (see CopickTiltSeriesMetadata).
The images are stored like on the CryoET Data Portal: chunks of one image, levels binned by 2 along y and x only. The metadata is read lazily from the Zarr group, so listing tilt series does not open their stores.
Attributes:
-
run(CopickRun) –Reference to the run this tilt series belongs to.
-
meta(CopickTiltSeriesMeta) –Identity of this tilt series.
-
ts_type(str) –Type of the tilt series.
metadata
The metadata of this tilt series, or None if it holds no images yet.
pixel_size
Pixel size of the full-size images in Angstrom, or None if the tilt series holds no images.
shape
Shape (section, y, x) of the full-size images, or None if the tilt series holds no images.
alignments
All alignments of this tilt series in its run, best first (see CopickRun.get_alignments).
valid_alignments
The alignments of this tilt series from their authors, best first; placeholders are left out.
default_alignment
The best valid alignment of this tilt series, or None if there is none.
__init__
Parameters:
-
run(CopickRun) –Reference to the run this tilt series belongs to.
-
meta(CopickTiltSeriesMeta) –Identity of this tilt series.
store_metadata
Store metadata in the Zarr group of this tilt series.
Parameters:
-
metadata(Optional[CopickTiltSeriesMetadata], default:None) –The metadata to store. Default: the current metadata (e.g. after editing it in place).
Raises:
-
ValueError–If the tilt series holds no images, or the metadata does not fit them.
zarr
Override to return the Zarr store for this tilt series. Also needs to handle creating the store if it doesn't exist.
numpy
numpy(zarr_group: str = '0', sections: slice = slice(None, None), y: slice = slice(None, None), x: slice = slice(None, None)) -> np.ndarray
Return images of the tilt series as a numpy array (section, y, x).
Parameters:
-
zarr_group(str, default:'0') –Multiscale level to read.
-
sections(slice, default:slice(None, None)) –Slice of sections.
-
y(slice, default:slice(None, None)) –Slice along y.
-
x(slice, default:slice(None, None)) –Slice along x.
Returns:
-
ndarray–np.ndarray: The images.
section
Return one image of the tilt series.
Parameters:
-
index(int) –Section of the image.
-
zarr_group(str, default:'0') –Multiscale level to read.
Returns:
-
ndarray–np.ndarray: The image
(y, x).
from_numpy
from_numpy(data: Any, pixel_size: Optional[float] = None, levels: int = TILT_SERIES_LEVELS, dtype: Optional[dtype] = np.float32, chunks: Tuple[int, int, int] = TILT_SERIES_CHUNKS, metadata: Optional[CopickTiltSeriesMetadata] = None) -> None
Write the images of the tilt series and their multiscale pyramid, replacing any stored images.
The images are written one section at a time, so data may be any array-like indexable per section, e.g. a
memory-mapped MRC file. The stored metadata is kept if it still fits the images; otherwise it is replaced by
metadata holding only the image geometry.
Parameters:
-
data(Any) –The images, shape
(section, y, x). -
pixel_size(Optional[float], default:None) –Pixel size in Angstrom. Default: that of
metadataor of the stored metadata. -
levels(int, default:TILT_SERIES_LEVELS) –Number of levels in the pyramid.
-
dtype(Optional[dtype], default:float32) –Data type of the stored images;
Nonekeeps the type ofdata. -
chunks(Tuple[int, int, int], default:TILT_SERIES_CHUNKS) –Chunk shape of every level.
-
metadata(Optional[CopickTiltSeriesMetadata], default:None) –Metadata to store with the images.
Raises:
-
ValueError–If no pixel size is known, or the metadata does not fit the images.
set_region
set_region(data: ndarray, zarr_group: str = '0', sections: slice = slice(None, None), y: slice = slice(None, None), x: slice = slice(None, None)) -> None
Overwrite a region of one multiscale level. The other levels are not updated.
Parameters:
-
data(ndarray) –The region's new content, shape
(section, y, x). -
zarr_group(str, default:'0') –Multiscale level to write.
-
sections(slice, default:slice(None, None)) –Slice of sections.
-
y(slice, default:slice(None, None)) –Slice along y.
-
x(slice, default:slice(None, None)) –Slice along x.