sparkocr.utils.svs.phi_redaction#
Module Contents#
Functions#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Convert a list of dictionaries (with stringified 'coordinates') into a standard format. |
|
|
|
Extract base name from a tile file path, supporting both PNG and JPG (case-insensitive). |
|
|
|
|
|
Find the thumbnail page index using Aperio SVS conventions. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Modifies tiles in an SVS file to remove sensitive information by drawing black rectangles. |
|
|
- calculate_actual_level_height(level_info)#
- calculate_actual_level_width(level_info)#
- calculate_max_group_mem_gb(mem_per_worker_gb=1.5, ram_fraction=0.75, overhead_mem_gb=2.0)#
- chunk_list(lst, n)#
- dataframe_to_detections(detections_df)#
- detect_tile_level(folder_path)#
- detections_to_dataframe(detections_dict, dir_path, svs_name, level)#
- df2list(tiles_deid)#
Convert a list of dictionaries (with stringified ‘coordinates’) into a standard format. Returns a list of dicts with keys ‘file_path’ and ‘bbox’ (list of (x, y, w, h) tuples).
- estimate_svs_memory_gb(svs_path)#
- extract_base_name(tile_path)#
Extract base name from a tile file path, supporting both PNG and JPG (case-insensitive). Extracts everything before ‘_L<digits>_T<digits>.<ext>’
- extract_svs_name_from_tiles(files_path)#
- find_intersecting_tiles(x1, y1, x2, y2, level_info)#
- find_thumbnail_index(tif)#
Find the thumbnail page index using Aperio SVS conventions.
- get_existing_extension(dir_path, svs_name, level, tile_num)#
- get_svs_info_from_images(files_path)#
- get_tile_position_and_size(tile_index, level_info)#
- group_svs_files_by_memory(svs_files, max_group_mem_gb=6.0)#
- prepare_thumbnail_deid(only_thumbnail_deid, main_folder)#
- process_file(svs_path, tiles_deid, thumbnail_deid, output_svs_path=None, create_new_svs_file=False)#
- redact_phi_in_tiles(svs_path, tiles_deid, main_folder, output_svs_path=None, create_new_svs_file=False)#
Modifies tiles in an SVS file to remove sensitive information by drawing black rectangles. Can operate on a single SVS file or a directory containing multiple SVS files. The function will first scale the detections to all pyramid levels before applying deidentification. Parameters: - svs_path (str): Path to a single SVS file or a directory containing SVS files. - tiles_deid (list or DataFrame): List of dictionaries or a PySpark DataFrame containing the de-identification instructions. - main_folder (str): Path to folder containing tile directories. - output_svs_path (str, optional): Path where the new de-identified SVS file(s) will be saved. - create_new_svs_file (bool): If True, creates new SVS files instead of modifying originals. - max_group_mem_gb (float): Max memory per group for batching files.
- scale_boxes_to_all_levels(detections_df, main_folder)#
- setup_logging()#