MCPcopy Create free account
hub / github.com/PathologyDataScience/HiPS / SlideCollagenFeatureExtractor

Class SlideCollagenFeatureExtractor

hips/SlideFeatureExtractor.py:46–638  ·  view source on GitHub ↗

Extracts collagen features from MuTIsWSIRunner ouput.

Source from the content-addressed store, hash-verified

44
45
46class SlideCollagenFeatureExtractor(object):
47 """
48 Extracts collagen features from MuTIsWSIRunner ouput.
49 """
50 def __init__(
51 self,
52 slide_dir: str,
53 output_dir: str,
54 wsi_file: str,
55 *,
56 slide_name: str = None,
57 mpp: float = 0.5,
58 roi_size: int = 512,
59 topk_salient_rois: int = 256,
60 min_stroma_ratio=0.3,
61 min_tumor_ratio=0.2,
62 region_prop_names: Iterable[str] = None,
63 max_axis_ratio_for_fiber=0.2,
64 monitor: str = "",
65 logger: Any = None,
66 _region_class_map: Dict[str, str] = None,
67 _nucleus_class_map: Dict[str, str] = None,
68 _debug: bool = False,
69 ):
70 """
71 This represents the slide as a feature matrix summarizing
72 the collagen with tumor-associated stroma.
73 """
74 self.slide_dir = slide_dir
75 self.output_dir = output_dir
76 self.wsi_file = wsi_file
77 self.slide_name = slide_name or os.path.basename(slide_dir)
78 self.mpp = mpp
79 self.roi_size = roi_size
80 self.topk_salient_rois = topk_salient_rois
81 self.min_stroma_ratio = min_stroma_ratio
82 self.min_tumor_ratio = min_tumor_ratio
83 self.max_axis_ratio_for_fiber = max_axis_ratio_for_fiber
84 self.monitor = monitor
85 self.logger = logger or logging.getLogger(__name__)
86 self._debug = _debug
87
88 # codes and class map for most relevant classes
89 self._region_class_map = _region_class_map or {
90 'TILS': 'STROMA', # tils-dense stroma is still stroma!
91 }
92 self._rcd = RegionCellCombination.REGION_CODES
93 self._nucleus_class_map = _nucleus_class_map or {
94 'ActiveStromalCellNOS': 'StromalCellNOS',
95 }
96 self._ncd = RegionCellCombination.NUCLEUS_CODES
97
98 # region props to extract per collagen fibril edge
99 self._region_prop_names = region_prop_names or (
100 'label',
101 'area', # fibril edge length -- a bit noisy d.t. looping
102 'major_axis_length', # more robust than area visually
103 'minor_axis_length',

Calls

no outgoing calls

Tested by

no test coverage detected