Iterators API Reference¶
ImageProcessingIterator¶
ngio.experimental.iterators.ImageProcessingIterator
¶
ImageProcessingIterator(
input_image: Image,
output_image: Image,
input_channel_selection: ChannelSlicingInputType = None,
output_channel_selection: ChannelSlicingInputType = None,
axes_order: Sequence[str] | None = None,
input_transforms: Sequence[TransformProtocol]
| None = None,
output_transforms: Sequence[TransformProtocol]
| None = None,
)
Bases: AbstractIteratorBuilder[ndarray, Array]
Base class for iterators over ROIs.
Initialize the iterator with a ROI table and input/output images.
Parameters:
-
input_image(Image) –The input image to be used as input for the segmentation.
-
output_image(Image) –The image where the ROIs will be written.
-
input_channel_selection(ChannelSlicingInputType, default:None) –Optional selection of channels to use for the input image.
-
output_channel_selection(ChannelSlicingInputType, default:None) –Optional selection of channels to use for the output image.
-
axes_order(Sequence[str] | None, default:None) –Optional axes order for the segmentation.
-
input_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the input image.
-
output_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the output label.
Source code in ngio/experimental/iterators/_image_processing.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
grid
¶
grid(
size_x: int | None = None,
size_y: int | None = None,
size_z: int | None = None,
size_t: int | None = None,
stride_x: int | None = None,
stride_y: int | None = None,
stride_z: int | None = None,
stride_t: int | None = None,
base_name: str = "",
) -> Self
Create a grid of ROIs based on the input image dimensions.
Source code in ngio/experimental/iterators/_abstract_iterator.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
by_yx
¶
by_yx() -> Self
Return a new iterator that iterates over ROIs by YX coordinates.
Source code in ngio/experimental/iterators/_abstract_iterator.py
91 92 93 94 | |
by_zyx
¶
Return a new iterator that iterates over ROIs by ZYX coordinates.
Parameters:
-
strict(bool, default:True) –If True, only iterate over ZYX if a Z axis is present and not of size 1.
Source code in ngio/experimental/iterators/_abstract_iterator.py
96 97 98 99 100 101 102 103 104 105 | |
by_chunks
¶
Return a new iterator that iterates over ROIs by chunks.
Parameters:
-
overlap_xy(int, default:0) –Overlap in XY dimensions.
-
overlap_z(int, default:0) –Overlap in Z dimension.
Returns:
-
SegmentationIterator(Self) –A new iterator with chunked ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
product
¶
product(other: list[Roi] | GenericRoiTable) -> Self
Cartesian product of the current ROIs with an arbitrary list of ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
122 123 124 125 126 127 | |
iter
¶
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[NumpyPipeType],
DataSetterProtocol[NumpyPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[NumpyPipeType]]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[DaskPipeType],
DataSetterProtocol[DaskPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[DaskPipeType]]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[NumpyPipeType, DataSetterProtocol[NumpyPipeType]]
]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[NumpyPipeType]
iter(
lazy: bool = False,
data_mode: Literal["numpy", "dask"] = "dask",
iterator_mode: Literal[
"readwrite", "readonly"
] = "readwrite",
) -> Generator
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
iter_as_numpy
¶
iter_as_numpy()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
291 292 293 294 295 | |
iter_as_dask
¶
iter_as_dask()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
297 298 299 300 301 | |
map_as_numpy
¶
map_as_numpy(
func: Callable[[NumpyPipeType], NumpyPipeType],
mapper: MapperProtocol[NumpyPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
map_as_dask
¶
map_as_dask(
func: Callable[[DaskPipeType], DaskPipeType],
mapper: MapperProtocol[DaskPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
check_if_regions_overlap
¶
check_if_regions_overlap() -> bool
Check if any of the ROIs overlap logically.
If two ROIs cover the same pixel, they are considered to overlap. This does not consider chunking or other storage details.
Returns:
-
bool(bool) –True if any ROIs overlap. False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
require_no_regions_overlap
¶
require_no_regions_overlap() -> None
Ensure that the Iterator's ROIs do not overlap.
Source code in ngio/experimental/iterators/_abstract_iterator.py
359 360 361 362 | |
check_if_chunks_overlap
¶
check_if_chunks_overlap() -> bool
Check if any of the ROIs overlap in terms of chunks.
If two ROIs cover the same chunk, they are considered to overlap in chunks. This does not consider pixel-level overlaps.
Returns:
-
bool(bool) –True if any ROIs overlap in chunks, False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
require_no_chunks_overlap
¶
require_no_chunks_overlap() -> None
Ensure that the ROIs do not overlap in terms of chunks.
Source code in ngio/experimental/iterators/_abstract_iterator.py
387 388 389 390 | |
get_init_kwargs
¶
get_init_kwargs() -> dict
Return the initialization arguments for the iterator.
Source code in ngio/experimental/iterators/_image_processing.py
77 78 79 80 81 82 83 84 85 86 87 | |
build_numpy_getter
¶
Source code in ngio/experimental/iterators/_image_processing.py
89 90 91 92 93 94 95 96 97 | |
build_numpy_setter
¶
Source code in ngio/experimental/iterators/_image_processing.py
99 100 101 102 103 104 105 106 107 | |
build_dask_getter
¶
build_dask_getter(roi: Roi) -> DataGetterProtocol[Array]
Source code in ngio/experimental/iterators/_image_processing.py
109 110 111 112 113 114 115 116 117 | |
build_dask_setter
¶
build_dask_setter(roi: Roi) -> DataSetterProtocol[Array]
Source code in ngio/experimental/iterators/_image_processing.py
119 120 121 122 123 124 125 126 127 | |
post_consolidate
¶
post_consolidate()
Source code in ngio/experimental/iterators/_image_processing.py
129 130 | |
SegmentationIterator¶
ngio.experimental.iterators.SegmentationIterator
¶
SegmentationIterator(
input_image: Image,
output_label: Label,
channel_selection: ChannelSlicingInputType = None,
axes_order: Sequence[str] | None = None,
input_transforms: Sequence[TransformProtocol]
| None = None,
output_transforms: Sequence[TransformProtocol]
| None = None,
)
Bases: AbstractIteratorBuilder[ndarray, Array]
Base class for iterators over ROIs.
Initialize the iterator with a ROI table and input/output images.
Parameters:
-
input_image(Image) –The input image to be used as input for the segmentation.
-
output_label(Label) –The label image where the ROIs will be written.
-
channel_selection(ChannelSlicingInputType, default:None) –Optional selection of channels to use for the segmentation.
-
axes_order(Sequence[str] | None, default:None) –Optional axes order for the segmentation.
-
input_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the input image.
-
output_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the output label.
Source code in ngio/experimental/iterators/_segmentation.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
grid
¶
grid(
size_x: int | None = None,
size_y: int | None = None,
size_z: int | None = None,
size_t: int | None = None,
stride_x: int | None = None,
stride_y: int | None = None,
stride_z: int | None = None,
stride_t: int | None = None,
base_name: str = "",
) -> Self
Create a grid of ROIs based on the input image dimensions.
Source code in ngio/experimental/iterators/_abstract_iterator.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
by_yx
¶
by_yx() -> Self
Return a new iterator that iterates over ROIs by YX coordinates.
Source code in ngio/experimental/iterators/_abstract_iterator.py
91 92 93 94 | |
by_zyx
¶
Return a new iterator that iterates over ROIs by ZYX coordinates.
Parameters:
-
strict(bool, default:True) –If True, only iterate over ZYX if a Z axis is present and not of size 1.
Source code in ngio/experimental/iterators/_abstract_iterator.py
96 97 98 99 100 101 102 103 104 105 | |
by_chunks
¶
Return a new iterator that iterates over ROIs by chunks.
Parameters:
-
overlap_xy(int, default:0) –Overlap in XY dimensions.
-
overlap_z(int, default:0) –Overlap in Z dimension.
Returns:
-
SegmentationIterator(Self) –A new iterator with chunked ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
product
¶
product(other: list[Roi] | GenericRoiTable) -> Self
Cartesian product of the current ROIs with an arbitrary list of ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
122 123 124 125 126 127 | |
iter
¶
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[NumpyPipeType],
DataSetterProtocol[NumpyPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[NumpyPipeType]]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[DaskPipeType],
DataSetterProtocol[DaskPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[DaskPipeType]]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[NumpyPipeType, DataSetterProtocol[NumpyPipeType]]
]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[NumpyPipeType]
iter(
lazy: bool = False,
data_mode: Literal["numpy", "dask"] = "dask",
iterator_mode: Literal[
"readwrite", "readonly"
] = "readwrite",
) -> Generator
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
iter_as_numpy
¶
iter_as_numpy()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
291 292 293 294 295 | |
iter_as_dask
¶
iter_as_dask()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
297 298 299 300 301 | |
map_as_numpy
¶
map_as_numpy(
func: Callable[[NumpyPipeType], NumpyPipeType],
mapper: MapperProtocol[NumpyPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
map_as_dask
¶
map_as_dask(
func: Callable[[DaskPipeType], DaskPipeType],
mapper: MapperProtocol[DaskPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
check_if_regions_overlap
¶
check_if_regions_overlap() -> bool
Check if any of the ROIs overlap logically.
If two ROIs cover the same pixel, they are considered to overlap. This does not consider chunking or other storage details.
Returns:
-
bool(bool) –True if any ROIs overlap. False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
require_no_regions_overlap
¶
require_no_regions_overlap() -> None
Ensure that the Iterator's ROIs do not overlap.
Source code in ngio/experimental/iterators/_abstract_iterator.py
359 360 361 362 | |
check_if_chunks_overlap
¶
check_if_chunks_overlap() -> bool
Check if any of the ROIs overlap in terms of chunks.
If two ROIs cover the same chunk, they are considered to overlap in chunks. This does not consider pixel-level overlaps.
Returns:
-
bool(bool) –True if any ROIs overlap in chunks, False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
require_no_chunks_overlap
¶
require_no_chunks_overlap() -> None
Ensure that the ROIs do not overlap in terms of chunks.
Source code in ngio/experimental/iterators/_abstract_iterator.py
387 388 389 390 | |
get_init_kwargs
¶
get_init_kwargs() -> dict
Return the initialization arguments for the iterator.
Source code in ngio/experimental/iterators/_segmentation.py
71 72 73 74 75 76 77 78 79 80 | |
build_numpy_getter
¶
Source code in ngio/experimental/iterators/_segmentation.py
82 83 84 85 86 87 88 89 90 | |
build_numpy_setter
¶
Source code in ngio/experimental/iterators/_segmentation.py
92 93 94 95 96 97 98 99 100 | |
build_dask_getter
¶
build_dask_getter(roi: Roi) -> DataGetterProtocol[Array]
Source code in ngio/experimental/iterators/_segmentation.py
102 103 104 105 106 107 108 109 110 | |
build_dask_setter
¶
build_dask_setter(roi: Roi) -> DataSetterProtocol[Array]
Source code in ngio/experimental/iterators/_segmentation.py
112 113 114 115 116 117 118 119 120 | |
post_consolidate
¶
post_consolidate()
Source code in ngio/experimental/iterators/_segmentation.py
122 123 | |
MaskedSegmentationIterator¶
ngio.experimental.iterators.MaskedSegmentationIterator
¶
MaskedSegmentationIterator(
input_image: MaskedImage,
output_label: Label,
channel_selection: ChannelSlicingInputType = None,
axes_order: Sequence[str] | None = None,
input_transforms: Sequence[TransformProtocol]
| None = None,
output_transforms: Sequence[TransformProtocol]
| None = None,
)
Bases: SegmentationIterator
Base class for iterators over ROIs.
Initialize the iterator with a ROI table and input/output images.
Parameters:
-
input_image(MaskedImage) –The input image to be used as input for the segmentation.
-
output_label(Label) –The label image where the ROIs will be written.
-
channel_selection(ChannelSlicingInputType, default:None) –Optional selection of channels to use for the segmentation.
-
axes_order(Sequence[str] | None, default:None) –Optional axes order for the segmentation.
-
input_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the input image.
-
output_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the output label.
Source code in ngio/experimental/iterators/_segmentation.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
grid
¶
grid(
size_x: int | None = None,
size_y: int | None = None,
size_z: int | None = None,
size_t: int | None = None,
stride_x: int | None = None,
stride_y: int | None = None,
stride_z: int | None = None,
stride_t: int | None = None,
base_name: str = "",
) -> Self
Create a grid of ROIs based on the input image dimensions.
Source code in ngio/experimental/iterators/_abstract_iterator.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
by_yx
¶
by_yx() -> Self
Return a new iterator that iterates over ROIs by YX coordinates.
Source code in ngio/experimental/iterators/_abstract_iterator.py
91 92 93 94 | |
by_zyx
¶
Return a new iterator that iterates over ROIs by ZYX coordinates.
Parameters:
-
strict(bool, default:True) –If True, only iterate over ZYX if a Z axis is present and not of size 1.
Source code in ngio/experimental/iterators/_abstract_iterator.py
96 97 98 99 100 101 102 103 104 105 | |
by_chunks
¶
Return a new iterator that iterates over ROIs by chunks.
Parameters:
-
overlap_xy(int, default:0) –Overlap in XY dimensions.
-
overlap_z(int, default:0) –Overlap in Z dimension.
Returns:
-
SegmentationIterator(Self) –A new iterator with chunked ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
product
¶
product(other: list[Roi] | GenericRoiTable) -> Self
Cartesian product of the current ROIs with an arbitrary list of ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
122 123 124 125 126 127 | |
iter
¶
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[NumpyPipeType],
DataSetterProtocol[NumpyPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[NumpyPipeType]]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[DaskPipeType],
DataSetterProtocol[DaskPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[DaskPipeType]]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[NumpyPipeType, DataSetterProtocol[NumpyPipeType]]
]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[NumpyPipeType]
iter(
lazy: bool = False,
data_mode: Literal["numpy", "dask"] = "dask",
iterator_mode: Literal[
"readwrite", "readonly"
] = "readwrite",
) -> Generator
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
iter_as_numpy
¶
iter_as_numpy()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
291 292 293 294 295 | |
iter_as_dask
¶
iter_as_dask()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
297 298 299 300 301 | |
map_as_numpy
¶
map_as_numpy(
func: Callable[[NumpyPipeType], NumpyPipeType],
mapper: MapperProtocol[NumpyPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
map_as_dask
¶
map_as_dask(
func: Callable[[DaskPipeType], DaskPipeType],
mapper: MapperProtocol[DaskPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
check_if_regions_overlap
¶
check_if_regions_overlap() -> bool
Check if any of the ROIs overlap logically.
If two ROIs cover the same pixel, they are considered to overlap. This does not consider chunking or other storage details.
Returns:
-
bool(bool) –True if any ROIs overlap. False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
require_no_regions_overlap
¶
require_no_regions_overlap() -> None
Ensure that the Iterator's ROIs do not overlap.
Source code in ngio/experimental/iterators/_abstract_iterator.py
359 360 361 362 | |
check_if_chunks_overlap
¶
check_if_chunks_overlap() -> bool
Check if any of the ROIs overlap in terms of chunks.
If two ROIs cover the same chunk, they are considered to overlap in chunks. This does not consider pixel-level overlaps.
Returns:
-
bool(bool) –True if any ROIs overlap in chunks, False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
require_no_chunks_overlap
¶
require_no_chunks_overlap() -> None
Ensure that the ROIs do not overlap in terms of chunks.
Source code in ngio/experimental/iterators/_abstract_iterator.py
387 388 389 390 | |
get_init_kwargs
¶
get_init_kwargs() -> dict
Return the initialization arguments for the iterator.
Source code in ngio/experimental/iterators/_segmentation.py
175 176 177 178 179 180 181 182 183 184 | |
build_numpy_getter
¶
build_numpy_getter(roi: Roi)
Source code in ngio/experimental/iterators/_segmentation.py
186 187 188 189 190 191 192 193 194 195 196 | |
build_numpy_setter
¶
build_numpy_setter(roi: Roi)
Source code in ngio/experimental/iterators/_segmentation.py
198 199 200 201 202 203 204 205 206 207 208 | |
build_dask_getter
¶
build_dask_getter(roi: Roi)
Source code in ngio/experimental/iterators/_segmentation.py
210 211 212 213 214 215 216 217 218 219 220 | |
build_dask_setter
¶
build_dask_setter(roi: Roi)
Source code in ngio/experimental/iterators/_segmentation.py
222 223 224 225 226 227 228 229 230 231 232 | |
post_consolidate
¶
post_consolidate()
Source code in ngio/experimental/iterators/_segmentation.py
234 235 | |
FeatureExtractorIterator¶
ngio.experimental.iterators.FeatureExtractorIterator
¶
FeatureExtractorIterator(
input_image: Image,
input_label: Label,
channel_selection: ChannelSlicingInputType = None,
axes_order: Sequence[str] | None = None,
input_transforms: Sequence[TransformProtocol]
| None = None,
label_transforms: Sequence[TransformProtocol]
| None = None,
)
Bases: AbstractIteratorBuilder[NumpyPipeType, DaskPipeType]
Base class for iterators over ROIs.
Initialize the iterator with a ROI table and input/output images.
Parameters:
-
input_image(Image) –The input image to be used as input for the segmentation.
-
input_label(Label) –The input label with the segmentation masks.
-
channel_selection(ChannelSlicingInputType, default:None) –Optional selection of channels to use for the segmentation.
-
axes_order(Sequence[str] | None, default:None) –Optional axes order for the segmentation.
-
input_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the input image.
-
label_transforms(Sequence[TransformProtocol] | None, default:None) –Optional transforms to apply to the output label.
Source code in ngio/experimental/iterators/_feature.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
grid
¶
grid(
size_x: int | None = None,
size_y: int | None = None,
size_z: int | None = None,
size_t: int | None = None,
stride_x: int | None = None,
stride_y: int | None = None,
stride_z: int | None = None,
stride_t: int | None = None,
base_name: str = "",
) -> Self
Create a grid of ROIs based on the input image dimensions.
Source code in ngio/experimental/iterators/_abstract_iterator.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
by_yx
¶
by_yx() -> Self
Return a new iterator that iterates over ROIs by YX coordinates.
Source code in ngio/experimental/iterators/_abstract_iterator.py
91 92 93 94 | |
by_zyx
¶
Return a new iterator that iterates over ROIs by ZYX coordinates.
Parameters:
-
strict(bool, default:True) –If True, only iterate over ZYX if a Z axis is present and not of size 1.
Source code in ngio/experimental/iterators/_abstract_iterator.py
96 97 98 99 100 101 102 103 104 105 | |
by_chunks
¶
Return a new iterator that iterates over ROIs by chunks.
Parameters:
-
overlap_xy(int, default:0) –Overlap in XY dimensions.
-
overlap_z(int, default:0) –Overlap in Z dimension.
Returns:
-
SegmentationIterator(Self) –A new iterator with chunked ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
product
¶
product(other: list[Roi] | GenericRoiTable) -> Self
Cartesian product of the current ROIs with an arbitrary list of ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
122 123 124 125 126 127 | |
iter
¶
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[NumpyPipeType],
DataSetterProtocol[NumpyPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[NumpyPipeType]]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[
DataGetterProtocol[DaskPipeType],
DataSetterProtocol[DaskPipeType],
]
]
iter(
lazy: Literal[True],
data_mode: Literal["dask"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[DataGetterProtocol[DaskPipeType]]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readwrite"],
) -> Generator[
tuple[NumpyPipeType, DataSetterProtocol[NumpyPipeType]]
]
iter(
lazy: Literal[False],
data_mode: Literal["numpy"],
iterator_mode: Literal["readonly"] = ...,
) -> Generator[NumpyPipeType]
iter(
lazy: bool = False,
data_mode: Literal["numpy", "dask"] = "dask",
iterator_mode: Literal[
"readwrite", "readonly"
] = "readwrite",
) -> Generator
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_abstract_iterator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
map_as_numpy
¶
map_as_numpy(
func: Callable[[NumpyPipeType], NumpyPipeType],
mapper: MapperProtocol[NumpyPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
map_as_dask
¶
map_as_dask(
func: Callable[[DaskPipeType], DaskPipeType],
mapper: MapperProtocol[DaskPipeType] | None = None,
) -> None
Apply a transformation function to the ROI pixels.
Source code in ngio/experimental/iterators/_abstract_iterator.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
check_if_regions_overlap
¶
check_if_regions_overlap() -> bool
Check if any of the ROIs overlap logically.
If two ROIs cover the same pixel, they are considered to overlap. This does not consider chunking or other storage details.
Returns:
-
bool(bool) –True if any ROIs overlap. False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
require_no_regions_overlap
¶
require_no_regions_overlap() -> None
Ensure that the Iterator's ROIs do not overlap.
Source code in ngio/experimental/iterators/_abstract_iterator.py
359 360 361 362 | |
check_if_chunks_overlap
¶
check_if_chunks_overlap() -> bool
Check if any of the ROIs overlap in terms of chunks.
If two ROIs cover the same chunk, they are considered to overlap in chunks. This does not consider pixel-level overlaps.
Returns:
-
bool(bool) –True if any ROIs overlap in chunks, False otherwise.
Source code in ngio/experimental/iterators/_abstract_iterator.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
require_no_chunks_overlap
¶
require_no_chunks_overlap() -> None
Ensure that the ROIs do not overlap in terms of chunks.
Source code in ngio/experimental/iterators/_abstract_iterator.py
387 388 389 390 | |
get_init_kwargs
¶
get_init_kwargs() -> dict
Return the initialization arguments for the iterator.
Source code in ngio/experimental/iterators/_feature.py
125 126 127 128 129 130 131 132 133 134 | |
build_numpy_getter
¶
build_numpy_getter(roi: Roi) -> NumpyFeatureGetter
Source code in ngio/experimental/iterators/_feature.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
build_dask_getter
¶
build_dask_getter(roi: Roi) -> DaskFeatureGetter
Source code in ngio/experimental/iterators/_feature.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
build_numpy_setter
¶
build_numpy_setter(roi: Roi) -> None
Source code in ngio/experimental/iterators/_feature.py
174 175 | |
build_dask_setter
¶
build_dask_setter(roi: Roi) -> None
Source code in ngio/experimental/iterators/_feature.py
177 178 | |
post_consolidate
¶
post_consolidate()
Source code in ngio/experimental/iterators/_feature.py
180 181 | |
iter_as_numpy
¶
iter_as_numpy()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_feature.py
183 184 185 | |
iter_as_dask
¶
iter_as_dask()
Create an iterator over the pixels of the ROIs.
Source code in ngio/experimental/iterators/_feature.py
187 188 189 | |