cellmil.features.feature_extractor¶
Classes
|
Feature extractor for whole slide images. |
- cellmil.features.feature_extractor._pool_init(extractor_type: ExtractorType) None[source]¶
Initializer for multiprocessing Pool to create one Extractor per process.
- class cellmil.features.feature_extractor.FeatureExtractor(config: FeatureExtractorConfig)[source]¶
Bases:
objectFeature extractor for whole slide images.
- __init__(config: FeatureExtractorConfig)[source]¶
- static _load_patch(patched_slide_path: Path, row: int, col: int) ndarray[Any, Any][source]¶
Load a patch image from the file system.
- Parameters:
- Returns:
The patch image as a numpy array
- Return type:
np.ndarray
- Raises:
FileNotFoundError – If the patch file doesn’t exist
- static _get_patch_path(patched_slide_path: Path, row: int, col: int) Path[source]¶
Get the path to a patch file based on row and column coordinates.
- _save_pt(results: list[dict[str, Any]])[source]¶
Save extracted features to a PyTorch file. (Faster than JSON)
- _results_to_tensor(data: list[dict[str, Any]]) Tensor[source]¶
Convert a dictionary of features to a PyTorch tensor.
- Parameters:
data – List of dictionaries containing cell_id and features
- Returns:
- Tensor of shape [N, D] where N is the number of cells
and D is the number of features
- Return type:
- static _get_morphological_features(item: dict[str, Any]) Optional[dict[str, Any]][source]¶
Process a single cell and extract features.
- static create_cell_mask(cell_contour: list[list[int]], patch_bounds: tuple[int, int, int, int], patch_shape: tuple[int, int]) tuple[numpy.ndarray[Any, Any], int][source]¶
Create a binary mask from cell contour for a specific patch region only.
- Parameters:
cell_contour – List of [x, y] coordinates defining the cell boundary
patch_bounds – Tuple of (x_min, y_min, x_max, y_max) defining the patch region
patch_shape – Tuple of (height, width) for the output mask
- Returns:
Binary mask array with shape patch_shape