thor.pp.preprocess_image
- thor.pp.preprocess_image(image_path, bbox=None, color_image=True, nuclei_seg_path=None, nuclei_seg_format=None, nuclei_centroids_path=None, context_size='mean', extract_image_feature_custom_func=None, remove_outlier=True, save_path=None)[source]
Preprocess the image and extract features from the cells.
- Parameters:
image_path (str) – Path to the full resolution image to process.
bbox (tuple, optional) – Bounding box of the image. Format is (lower_left, upper_right). If not provided, the whole image will be processed. lower_left and upper_right are tuples of x and y coordinates.
color_image (bool, optional) – Whether to extract color features from the image. Default is True.
nuclei_seg_path (str) – Path to the nuclei segmentation result file.
nuclei_seg_format (str) – Format of the nuclei segmentation result file. Can be ‘cellpose’, ‘mask_array_npz’ or ‘cellprofiler’.
nuclei_centroids_path (str) – Path to the nuclei centroids. The format should be a csv file with columns x and y for the x and y coordinates of the nuclei centroids. Index of the dataframe should be the cell labels.
context_size (numeric or str, optional) – Radius of the square image patch to extract around each cell (unit: pixel). Valid values are numeric or ‘median’, ‘mean’, ‘min’, ‘max’. If provided as str, the radius is estimated from the nearest cell distances.
extract_image_feature_custom_func (function) – Custom function to extract additional features from the image patches. The function should be written in a way that takes a list of image patches as input and return a dataframe of features.
remove_outlier (bool) – Whether to remove outlier cells. Default is True.
save_path (str) – Path to save the extracted features.