:class:`~.BasicSampleQueries` ====================================================================================================================================================== .. py:class:: astropathdb.db_io._sample_utils.BasicSampleQueries(astrodb, sampleid) :single-line-parameter-list: Basic queries for samples in the AstroPath databases. :class:`~.astropathdb.db_io._sample_utils.BasicSampleQueries` *Attributes* ------------------------------------------------------------------------------------------------------------------------------------------------------ .. autoapisummary:: :signatures: none astropathdb.db_io._sample_utils.BasicSampleQueries.astrodb :class:`~.astropathdb.db_io._sample_utils.BasicSampleQueries` *Properties* ------------------------------------------------------------------------------------------------------------------------------------------------------ .. autoapisummary:: :signatures: none astropathdb.db_io._sample_utils.BasicSampleQueries.samples astropathdb.db_io._sample_utils.BasicSampleQueries.cell_range_query astropathdb.db_io._sample_utils.BasicSampleQueries.image_dims_query :class:`~.astropathdb.db_io._sample_utils.BasicSampleQueries` *Methods* ------------------------------------------------------------------------------------------------------------------------------------------------------ .. autoapisummary:: :signatures: none astropathdb.db_io._sample_utils.BasicSampleQueries.query_by_cell_ranges astropathdb.db_io._sample_utils.BasicSampleQueries.create_cells_parquet astropathdb.db_io._sample_utils.BasicSampleQueries.create_cells_geoms_parquet astropathdb.db_io._sample_utils.BasicSampleQueries.create_cells_positions_parquet :class:`~.astropathdb.db_io._sample_utils.BasicSampleQueries` *References* ------------------------------------------------------------------------------------------------------------------------------------------------------ .. py:currentmodule:: astropathdb.db_io._sample_utils.BasicSampleQueries *Attribute Reference* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. py:attribute:: astrodb *Property Reference* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. py:property:: samples :type: str | int | list[int] 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. .. py:property:: cell_range_query :type: list 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. .. py:property:: image_dims_query :type: list Returns a list of two queries for the image dimensions for a sample. The first query is for the unique (x, y, level) combinations, the second is for the unique ztype layers. .. note:: Returns the strings for the queries not the results. *Method Reference* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. py:method:: query_by_cell_ranges(base_query, min_cellid = None, max_cellid = None, cell_ranges = None, sample = None, *, is_and = True) :single-line-parameter-list: 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. .. py:method:: create_cells_parquet(directory, slideids = None, base_query = 'SELECT * FROM CELLTAG', *, is_and = False, file_spec = 'cells') :single-line-parameter-list: Create parquet files for the cells in the samples. :param directory: The directory to save the parquet files. Each sample will be saved in a subdirectory under "slide ID / wsi". :param slideids: A list of slide IDs to use for the samples. If None, the sample name will be used as the slide ID. :param base_query: The base query to use for the cells. :param is_and: Whether to use 'and' or 'where' in the query. :param file_spec: The file specification to use for the parquet files. Defaults to 'cells' (i.e. creates 'cells.parquet'). .. py:method:: create_cells_geoms_parquet(directory, slideids = None, btype = 0) :single-line-parameter-list: Create parquet files for the cells geometries in the samples. :param directory: The directory to save the parquet files. Each sample will be saved in a subdirectory under "slide ID / wsi". :param slideids: A list of slide IDs to use for the samples. If None, the sample name will be used as the slide ID. :param btype: The boundary type to use for the cells. 0 for boundaries, 1 for nuclei. Defaults to 0. .. py:method:: create_cells_positions_parquet(directory, slideids = None) :single-line-parameter-list: Create parquet files for the cells positions in the samples. :param directory: The directory to save the parquet files. Each sample will be saved in a subdirectory under "slide ID / wsi". :param slideids: A list of slide IDs to use for the samples. If None, the sample name will be used as the slide ID. *Private Attribute Reference* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. py:attribute:: __samples *Private Method Reference* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. py:method:: _sample_cell_range(cell_ranges, sample) :single-line-parameter-list: Get the min and max cellid for the sample. :param cell_ranges: A DataFrame with the min and max cellid for a sample. :param sample: The sample for which to get the cell range. :returns: A tuple with the min and max cellid for the sample. .. py:method:: _check_slideids_input(slideids) :single-line-parameter-list: .. py:method:: _lookup_slideid(slideids, sample, idx) :single-line-parameter-list: .. py:method:: _write_cells_parquet(directory, slideid, file_spec, df) :single-line-parameter-list: Write the DataFrame to a parquet file in the specified directory. :param directory: The directory to save the parquet file. :param slideid: The slide ID. :param file_spec: The file specification for the parquet file. :param df: The DataFrame to save.