cellmap_flow.post.postprocessors
Attributes
Classes
Base class for post-processing methods. |
|
Apply sigmoid activation to convert logits to probabilities. |
|
Base class for post-processing methods. |
|
Base class for post-processing methods. |
|
Threshold, then fill the background holes each foreground blob encloses. |
|
An id per connected object of one channel's nonzero voxels ( |
|
Base class for post-processing methods. |
|
Objects from affinities by mutex watershed ( |
|
Base class for post-processing methods. |
|
Cellpose's masks, made from a Cellpose model's flows output. |
|
Base class for post-processing methods. |
|
Base class for post-processing methods. |
Functions
|
Returns a list of dictionaries containing the names and parameters of all subclasses of PostProcessor. |
|
Get postprocessors from either dict or list format. |
Module Contents
- cellmap_flow.post.postprocessors.logger
- class cellmap_flow.post.postprocessors.PostProcessor
Base class for post-processing methods.
- property is_segmentation
- problem_with(model_config)
Why this step cannot run on
model_config’s output, or None when it can.Checked by the dashboard before it applies a chain: a step that fails on every chunk does so inside the model’s server, where the page shows only an empty layer.
- class cellmap_flow.post.postprocessors.SigmoidPostprocessor
Apply sigmoid activation to convert logits to probabilities.
- property dtype
- class cellmap_flow.post.postprocessors.DefaultPostprocessor(clip_min: float = -1.0, clip_max: float = 1.0, bias: float = 1.0, multiplier: float = 127.5)
Base class for post-processing methods.
- clip_min
- clip_max
- bias
- multiplier
- property dtype
- property is_segmentation
- class cellmap_flow.post.postprocessors.ThresholdPostprocessor(threshold: float = 0.5)
Base class for post-processing methods.
- threshold
- property dtype
- property is_segmentation
- class cellmap_flow.post.postprocessors.FillHolesPostprocessor(threshold: float = 0.0)
Threshold, then fill the background holes each foreground blob encloses.
For compact single-instance organelles (a nucleus, say) that never have interior gaps; not for structures with a real lumen. It runs per chunk with no halo, so a hole that touches the chunk’s boundary is not enclosed within the chunk and stays unfilled.
- threshold
- property dtype
- property is_segmentation
- class cellmap_flow.post.postprocessors.LabelPostprocessor(channel: int = 0, connectivity: int = 1, min_size: int = 0, per_slice: bool = False)
An id per connected object of one channel’s nonzero voxels (
segment.connected_components).connectivity: 1 faces (the default), 2 faces and edges, 3 all neighbours.min_size: objects of fewer voxels become background.per_slice: each z slice labelled on its own, in 2D. The other channels pass through, as uint32.- channel = 0
- connectivity
- min_size = 0
- per_slice
- property dtype
- property is_segmentation
- class cellmap_flow.post.postprocessors.MortonSegmentationRelabeling(channel: int = 0)
Base class for post-processing methods.
- channel = 0
- num_previous_segments = 0
- use_exact = True
- property dtype
- property is_segmentation
- class cellmap_flow.post.postprocessors.AffinityPostprocessor(bias: float = 0.0, neighborhood: str = '[\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [3, 0, 0],\n [0, 3, 0],\n [0, 0, 3],\n [9, 0, 0],\n [0, 9, 0],\n [0, 0, 9],\n ]')
Objects from affinities by mutex watershed (
segment.mutex_watershed).bias: the affinity above which neighbours join, and below which a fragment’s mean makes it background.neighborhood: the offset each channel compares, as the model was trained with. Ids are offset by the chunk’s Morton index, so they are unique across chunks.- bias
- neighborhood
- use_exact = True
- num_previous_segments = 0
- property dtype
- property is_segmentation
- property num_channels
- class cellmap_flow.post.postprocessors.SimpleBlockwiseMerger(channel: int = 0, face_erosion_iterations: int = 0)
Base class for post-processing methods.
- channel = 0
- face_erosion_iterations = 0
- use_exact = True
- equivalences
- chunk_slice_position_to_coords_id_dict
- slices
- keys_to_skip
- equivalences_json()
The equivalences so far, read while no other chunk is adding to them.
- calculate_equivalences()
- property dtype
- property is_segmentation
- class cellmap_flow.post.postprocessors.CellposeMasksPostprocessor(flow_threshold: float = 0.4, cellprob_threshold: float = 0.0, min_size: int = 15, stitch_threshold: float = 0.0, niter: int = 200)
Cellpose’s masks, made from a Cellpose model’s flows output.
Cellpose turns its three output channels into objects by following each pixel’s flow to where the flows converge. Run here, on a server with
output: flows(channels flow_y, flow_x and cell, the probability), its thresholds can be changed from the dashboard and the layer redrawn, whereoutput: masksfixes them when the server starts. Put it first in the chain, on the flows as served. It needs Cellpose, which a Cellpose model’s server has.Each slice is segmented on its own, as Cellpose segments a 2D image;
stitch_thresholdabove 0 joins a slice’s object to the next slice’s one it overlaps by that IoU (Cellpose’s stitch3D), else each slice’s ids follow the previous slice’s. Ids are unique within the chunk: follow with MortonSegmentationRelabeling for ids unique across chunks.- Parameters:
flow_threshold – how far an object’s flows may be from those its shape implies before it is dropped (Cellpose’s; 0 keeps all).
cellprob_threshold – the cell probability, as a logit, over which a pixel is followed (Cellpose’s; 0 is a probability of 0.5).
min_size – objects of fewer pixels are removed (per slice; in 3D after stitching).
stitch_threshold – IoU joining objects across slices; 0 is off.
niter – flow-following steps (Cellpose’s default, 200).
- uses_device = True
- flow_threshold
- cellprob_threshold
- min_size = 15
- stitch_threshold
- niter = 200
- problem_with(model_config)
None for a Cellpose model (or a finetune of one) served with
output: flows.
- property dtype
- property is_segmentation
- property num_channels
- class cellmap_flow.post.postprocessors.ChannelSelection(channels: str = '0')
Base class for post-processing methods.
- channels
- property num_channels
- class cellmap_flow.post.postprocessors.LambdaPostprocessor(expression: str)
Base class for post-processing methods.
- expression
- property dtype
- cellmap_flow.post.postprocessors.get_postprocessors_list() list[dict]
Returns a list of dictionaries containing the names and parameters of all subclasses of PostProcessor.
- cellmap_flow.post.postprocessors.get_postprocessors(elms) list[PostProcessor]
Get postprocessors from either dict or list format.