StructuredQuery#
- class astropathdb.db_io._sample_utils.StructuredQuery(*args, input_kwargs, kind, **kwargs)#
Bases:
BasicSampleQueriesCreate a structured query for elements.
StructuredQuery Attributes#
StructuredQuery Properties#
Returns the query string for the element query. |
|
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. |
StructuredQuery 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. |
StructuredQuery References#
Attribute Reference#
- attribute kind#
- attribute kwargs#
- 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 Method Reference#
- method _validate_input_kwargs(*, input_kwargs)#
Validates the input kwargs for the element query.
If the input_kwargs is a bool or str, it will be converted to an empty dict. If it is a Mapping, it will be returned as a dict. If it is not one of these types, a TypeError will be raised.
- method _parse_element_column_input(_input_kwargs)#