Inferer¶
Main inferer class to utilize the PeTu models.
Allows to easily provide various combinations of input modalities to obtain high quality predictions.
All available models are listed in the petu.constants module.
- class petu.inferer.Inferer(device: str | None = 'cuda', cuda_visible_devices: str | None = '0')¶
Bases:
object- infer(t1c: str | Path | ndarray | None = None, fla: str | Path | ndarray | None = None, t1: str | Path | ndarray | None = None, t2: str | Path | ndarray | None = None, ET_segmentation_file: str | Path | None = None, CC_segmentation_file: str | Path | None = None, T2H_segmentation_file: str | Path | None = None, et_dust_threshold: int = 0, et_dust_connectivity: int = 26, cc_dust_threshold: int = 0, cc_dust_connectivity: int = 26, t2h_dust_threshold: int = 0, t2h_dust_connectivity: int = 26) Tuple[ndarray, ndarray, ndarray]¶
Infer segmentations based on provided images.
- Parameters:
t1c (Optional[str | Path | np.ndarray], optional) – T1C image. Defaults to None.
fla (Optional[str | Path | np.ndarray], optional) – FLAIR image. Defaults to None.
t1 (Optional[str | Path | np.ndarray], optional) – T1 image. Defaults to None.
t2 (Optional[str | Path | np.ndarray], optional) – T2 image. Defaults to None.
ET_segmentation_file (Optional[str | Path], optional) – Path to save ET segmentation. Defaults to None.
CC_segmentation_file (Optional[str | Path], optional) – Path to save CC segmentation. Defaults to None.
T2H_segmentation_file (Optional[str | Path], optional) – Path to save T2H segmentation. Defaults to None.
et_dust_threshold (int, optional) – Minimum size of connected components to keep for ET. Defaults to 0.
et_dust_connectivity (int, optional) – Connectivity for connected component analysis for ET. Defaults to 26. Reference: https://en.wikipedia.org/wiki/Pixel_connectivity
cc_dust_threshold (int, optional) – Minimum size of connected components to keep for CC. Defaults to 0.
cc_dust_connectivity (int, optional) – Connectivity for connected component analysis for CC. Defaults to 26. Reference: https://en.wikipedia.org/wiki/Pixel_connectivity
t2h_dust_threshold (int, optional) – Minimum size of connected components to keep for T2H. Defaults to 0.
t2h_dust_connectivity (int, optional) – Connectivity for connected component analysis for T2H. Defaults to 26. Reference: https://en.wikipedia.org/wiki/Pixel_connectivity
- Returns:
Tuple of segmentations: (ET, CC, T2H) as numpy arrays.
- Return type:
Tuple[np.ndarray, np.ndarray, np.ndarray]