BasicSampleQueries#
- class astropathdb.db_io._sample_utils.BasicSampleQueries(astrodb, sampleid)#
Basic queries for samples in the AstroPath databases.
BasicSampleQueries Attributes#
BasicSampleQueries Properties#
Returns the sampleids to query. |
|
Returns a list of one query for the max and min cellid in a sample. |
|
Returns a list of two queries for the image dimensions for a sample. |
BasicSampleQueries Methods#
|
Parse the cell boundaries queries into 20 separate queries for speed. |
|
Create parquet files for the cells in the samples. |
|
Create parquet files for the cells geometries in the samples. |
|
Create parquet files for the cells positions in the samples. |
BasicSampleQueries References#
Attribute Reference#
- attribute astrodb#
Property Reference#
- property samples#
-
Returns the sampleids to query.
If the element is ‘cells’, it returns the sampleids for all cell elements; otherwise it returns the sampleids for the specified element.
- property cell_range_query#
-
Returns a list of one query for the max and min cellid in a sample.
Note
Returns the strings for the query not the results.
Method Reference#
- method query_by_cell_ranges(base_query, min_cellid=None, max_cellid=None, cell_ranges=None, sample=None, *, is_and=True)#
Parse the cell boundaries queries into 20 separate queries for speed.
The cell boundaries take longer to query. To improve the speed we parse the cell boundaries into 20 queries based on the cellid range for the sample and pass those in parallel.
- method create_cells_parquet(directory, slideids=None, base_query='SELECT * FROM CELLTAG', *, is_and=False, file_spec='cells')#
Create parquet files for the cells in the samples.
- Parameters:
directory (str) – The directory to save the parquet files. Each sample will be saved in a subdirectory under “slide ID / wsi”.
slideids (list | DataFrame) – A list of slide IDs to use for the samples. If None, the sample name will be used as the slide ID.
base_query (str) – The base query to use for the cells.
is_and (bool) – Whether to use ‘and’ or ‘where’ in the query.
file_spec (str) – The file specification to use for the parquet files. Defaults to ‘cells’ (i.e. creates ‘cells.parquet’).
- Return type:
None
- method create_cells_geoms_parquet(directory, slideids=None, btype=0)#
Create parquet files for the cells geometries in the samples.
- Parameters:
directory (str) – The directory to save the parquet files. Each sample will be saved in a subdirectory under “slide ID / wsi”.
slideids (list | DataFrame) – A list of slide IDs to use for the samples. If None, the sample name will be used as the slide ID.
btype (int) – The boundary type to use for the cells. 0 for boundaries, 1 for nuclei. Defaults to 0.
- Return type:
None
- method create_cells_positions_parquet(directory, slideids=None)#
Create parquet files for the cells positions in the samples.
Private Attribute Reference#
- attribute __samples#
Private Method Reference#
- method _sample_cell_range(cell_ranges, sample)#
Get the min and max cellid for the sample.
- method _lookup_slideid(slideids, sample, idx)#
- method _write_cells_parquet(directory, slideid, file_spec, df)#
Write the DataFrame to a parquet file in the specified directory.