misc¶

Miscellaneous small functions repeatedly used in tiatoolbox.

Functions

add_from_dat

Add annotations from a .dat file to an existing store.

anns_from_hoverdict

Helper function to create list of Annotation objects.

assert_dtype_int

Generate error if dtype is not int.

cast_to_min_dtype

Cast the input array to the minimal data type required to represent its values.

contrast_enhancer

Enhance contrast of the input image using intensity adjustment.

create_smart_array

Allocate a NumPy or Zarr array depending on available memory and a threshold.

dict_to_store_patch_predictions

Converts output of the PatchPredictor engine to AnnotationStore or QuPath json.

dict_to_store_semantic_segmentor

Converts output of TIAToolbox SemanticSegmentor engine to AnnotationStore.

download_data

Download data from a given URL to location.

get_bounding_box

Get bounding box coordinate information.

get_luminosity_tissue_mask

Get tissue mask based on the luminosity of the input image.

get_zarr_array

Converts a zarr array into a numpy array.

grab_files_from_dir

Grab file paths specified by file extensions.

imread

Read an image as numpy.ndarray.

imwrite

Write numpy array to an image.

load_stain_matrix

Load a stain matrix as a numpy array.

make_default_dict

Helper function to create a default typedict if none is provided.

make_valid_poly

Helper function to make a valid polygon.

parse_cv2_interpolaton

Convert a string to a OpenCV (cv2) interpolation enum.

patch_predictions_as_annotations

Helper function to generate annotation per patch predictions.

patch_predictions_as_qupath_json

Helper function to generate QuPath JSON per patch predictions.

ppu2mpp

Convert pixels per unit (ppu) to microns per pixel (mpp).

process_contours

Process contours and hierarchy to create annotations.

read_locations

Read annotations as pandas DataFrame.

save_annotations

Saves Annotation Store to disk.

save_as_json

Save data to a json file.

save_qupath_json

Saves QuPath JSON to disk.

save_yaml

Save dictionary as yaml.

select_cv2_interpolation

Return appropriate interpolation method for opencv based image resize.

select_device

Selects the appropriate device as requested.

split_path_name_ext

Split path of a file to directory path, file name and extensions.

store_from_dat

Load annotations from a hovernet-style .dat file.

string_to_tuple

Splits input string to tuple at ','.

tqdm_dask_progress_bar

Helper function for tqdm_dask_progress_bar.

unzip_data

Extract data from zip file.

update_tqdm_desc

Helper function to update tqdm progress bar description.

write_probability_heatmap_as_ome_tiff

Saves output probability maps from segmentation models as heatmaps.