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.

contrast_enhancer

Enhance contrast of the input image using intensity adjustment.

dict_to_store

Converts (and optionally saves) output of TIAToolbox engines as AnnotationStore.

dict_to_zarr

Saves the output of TIAToolbox engines to a zarr file.

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.

grab_files_from_dir

Grab file paths specified by file extensions.

imread

Read an image as numpy array.

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.

model_to

Transfers model to cpu/gpu.

parse_cv2_interpolaton

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

ppu2mpp

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

read_locations

Read annotations as pandas DataFrame.

save_as_json

Save data to a json file.

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 ','.

unzip_data

Extract data from zip file.