MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/data/wsi_datasets.py:213–276  ·  view source on GitHub ↗
(
        self,
        data: Sequence,
        patch_size: int | tuple[int, int] | None = None,
        patch_level: int | None = None,
        mask_level: int = 0,
        overlap: tuple[float, float] | float = 0.0,
        offset: tuple[int, int] | int | str = (0, 0),
        offset_limits: tuple[tuple[int, int], tuple[int, int]] | tuple[int, int] | None = None,
        transform: Callable | None = None,
        include_label: bool = False,
        center_location: bool = False,
        additional_meta_keys: Sequence[str] = (ProbMapKeys.LOCATION, ProbMapKeys.SIZE, ProbMapKeys.COUNT),
        reader="cuCIM",
        seed: int = 0,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

211 """
212
213 def __init__(
214 self,
215 data: Sequence,
216 patch_size: int | tuple[int, int] | None = None,
217 patch_level: int | None = None,
218 mask_level: int = 0,
219 overlap: tuple[float, float] | float = 0.0,
220 offset: tuple[int, int] | int | str = (0, 0),
221 offset_limits: tuple[tuple[int, int], tuple[int, int]] | tuple[int, int] | None = None,
222 transform: Callable | None = None,
223 include_label: bool = False,
224 center_location: bool = False,
225 additional_meta_keys: Sequence[str] = (ProbMapKeys.LOCATION, ProbMapKeys.SIZE, ProbMapKeys.COUNT),
226 reader="cuCIM",
227 seed: int = 0,
228 **kwargs,
229 ):
230 super().__init__(
231 data=[],
232 patch_size=patch_size,
233 patch_level=patch_level,
234 transform=transform,
235 include_label=include_label,
236 center_location=center_location,
237 additional_meta_keys=additional_meta_keys,
238 reader=reader,
239 **kwargs,
240 )
241 self.overlap = overlap
242 self.set_random_state(seed)
243 # Set the offset config
244 self.random_offset = False
245 if isinstance(offset, str):
246 if offset == "random":
247 self.random_offset = True
248 self.offset_limits: tuple[tuple[int, int], tuple[int, int]] | None
249 if offset_limits is None:
250 self.offset_limits = None
251 elif isinstance(offset_limits, tuple):
252 if isinstance(offset_limits[0], int):
253 self.offset_limits = (offset_limits, offset_limits)
254 elif isinstance(offset_limits[0], tuple):
255 self.offset_limits = offset_limits
256 else:
257 raise ValueError(
258 "The offset limits should be either a tuple of integers or tuple of tuple of integers."
259 )
260 else:
261 raise ValueError("The offset limits should be a tuple.")
262 else:
263 raise ValueError(
264 f'Invalid string for offset "{offset}". It should be either "random" as a string,'
265 "an integer, or a tuple of integers defining the offset."
266 )
267 else:
268 self.offset = ensure_tuple_rep(offset, 2)
269
270 self.mask_level = mask_level

Callers

nothing calls this directly

Calls 5

ensure_tuple_repFunction · 0.90
extendMethod · 0.80
__init__Method · 0.45
set_random_stateMethod · 0.45

Tested by

no test coverage detected