SampleBaseImage#
- class astropathdb.db_io._sample_utils.SampleBaseImage(astrodb, sampleid)#
Helper class for the lazy image loading.
Functionality is driven through
build_multiscale_datatree_image()which returns a multiscale datatree image that can be directly added to aSpatialDataobject.
SampleBaseImage Attributes#
SampleBaseImage Methods#
|
Build a multiscale dask datatree image for a sample's image pyramid. |
SampleBaseImage References#
Attribute Reference#
Method Reference#
- method build_multiscale_datatree_image(tile_dims=None)#
Build a multiscale dask datatree image for a sample’s image pyramid.
The scales are from 0 (highest resolution) to 9 (lowest resolution) and named ‘scaleX’, with X indicating the resolution (ex.
scale0).Note
The scale is reversed from what is in the database where the scales are 9 to 0 (highest to lowest resolution).
- Parameters:
tile_dims (tuple[DataArray, DataArray] | None) – A list of two dataframes specifying the image dimensions for the sample. The dataframe should have columns x,y,level for distinct combinations. The second should have a single column
ztypefor the distinct image z layers, in any order (Defaults toNoneand will be automatically grabbed from the database).- Returns:
A multiscale image in DataTree format where the image itself is a Dask object which queries the regions when requested. Its channels are the
ztypelayers in ascending order.- Return type:
Private Attribute Reference#
- attribute __astrodb#
- attribute __sampleid#
Private Method Reference#
- static __hex_to_image(x, image_dtype=np.int8)#
Convert image hex string to an image.
- method __organize_chunk(img_dict, start_positions, chunk_size, num_tiles, z_range)#
Organize the image chunk from the query into a usable (z,y,x) image.
- Parameters:
img_dict (dict) – A dictionary mapping of the query with keys (x,y,z) and values holding the image query results
start_positions (tuple) – Starting tile positions for the mapping.
chunk_size (tuple) – The actual chunk sizes in y and x directions
num_tiles (tuple) – The number of tiles in the query, used to get edges
z_range (list) – The z range of the tiles
- Returns:
A numpy array the size of the input chunk
- Return type:
- static __preprocess_img_result(q_result)#
Pre-process the query result into a dictionary for faster access.
Create a dictionary to store (x, y, z) -> img for fast access
- method __query_img(start_positions, end_positions, level)#
- method __retrieve_chunk(level, start_positions, chunk_size, z_range)#
- method _create_dask_img(image_tiles, level, z_range, image_edge)#
- method _add_scale(shape, level, z_range)#