dcnum.segm.segmenter_mpo
Attributes
Classes
Segmenter with multiprocessing operation |
|
Worker process for CPU-based segmentation |
|
Worker process for CPU-based segmentation |
|
Worker process for CPU-based segmentation |
Module Contents
- dcnum.segm.segmenter_mpo.mp_spawn = None
- class dcnum.segm.segmenter_mpo.MPOSegmenter(*, num_workers: int | None = None, kwargs_mask: dict | None = None, debug: bool = False, **kwargs)[source]
Bases:
dcnum.segm.segmenter.Segmenter,abc.ABCSegmenter with multiprocessing operation
- Parameters:
num_workers – Number of workers (processes) to spawn
kwargs_mask (dict) – Keyword arguments for mask post-processing (see process_labels)
debug (bool) – Debugging parameters
kwargs – Additional, optional keyword arguments for
segment_algorithmdefined in the subclass.
- hardware_processor = 'cpu'
Required hardware (“cpu” or “gpu”) defined in first-level subclass.
- num_workers
- slot_list = None
List of ChunkSlot instances
- mp_slot_index
The slot that is currently being worked on
- mp_active
Event that defines whether the workers are allowed to do work
- mp_num_workers_done
Number of workers that are done processing the slot
- mp_shutdown
Shutdown event tells workers to stop when set to != 0
- _worker_starter = None
- _workers = []
- segment_batch(images: numpy.ndarray, bg_off: numpy.ndarray | None = None)[source]
Perform batch segmentation of images
Before segmentation, an optional background offset correction with
bg_offis performed. After segmentation, mask postprocessing is performed according to the segmenter class definition.- Parameters:
images (3d np.ndarray of shape (N, Y, X)) – The time-series image data. First axis is time.
bg_off (1D np.ndarray of length N) – Optional 1D numpy array with background offset
Notes
If the segmentation algorithm only accepts background-corrected images, then images must already be background-corrected, except for the optional bg_off.
- segment_chunk(chunk: int, slot_list: list)[source]
Segment the image data of one ChunkSlot
- Parameters:
chunk – The data chunk index to perform segmentation on
slot_list – List of ChunkSlotData instances (e.g. SlotRegister.slots)
- Returns:
mask – The chunk_slot.mask numpy view on the shared boolean mask array.
- Return type:
np.array
- class dcnum.segm.segmenter_mpo.MPOSegmenterWorker(segmenter, sl_start: int, sl_stop: int)[source]
Worker process for CPU-based segmentation
- Parameters:
segmenter (.segmenter_mpo.MPOSegmenter) – The segmentation instance
sl_start (int) – Start of slice of input array to process
sl_stop (int) – Stop of slice of input array to process
- segmenter
- slot_list
List of ChunkSlot instances
- mp_slot_index
The slot that is currently being worked on
- mp_active
Whether the workers are allowed to do work
- mp_num_workers_done
Number of workers that are done processing the slot
- mp_shutdown
Shutdown bit tells workers to stop when set to != 0
- sl_start
- sl_stop
- class dcnum.segm.segmenter_mpo.MPOSegmenterWorkerProcess(*args, **kwargs)[source]
Bases:
MPOSegmenterWorker,mp_spawnWorker process for CPU-based segmentation
- Parameters:
segmenter (.segmenter_mpo.MPOSegmenter) – The segmentation instance
sl_start (int) – Start of slice of input array to process
sl_stop (int) – Stop of slice of input array to process
- class dcnum.segm.segmenter_mpo.MPOSegmenterWorkerThread(*args, **kwargs)[source]
Bases:
MPOSegmenterWorker,threading.ThreadWorker process for CPU-based segmentation
- Parameters:
segmenter (.segmenter_mpo.MPOSegmenter) – The segmentation instance
sl_start (int) – Start of slice of input array to process
sl_stop (int) – Stop of slice of input array to process