cellmap_segmentation_challenge.postprocess

cellmap_segmentation_challenge.postprocess#

Functions

process_volume(input_container, ...[, labels])

Postprocess a volume in a zarr container with an arbitrary function.

rescale_volume(input_container, output_path, ...)

Rescale volumes within a zarr container.

resize_volume(input_container, output_path, ...)

Resize volumes within a zarr container to a given shape.

threshold_volume(input_container[, ...])

Threshold a volume in a zarr container.

cellmap_segmentation_challenge.postprocess.threshold_volume(input_container: str | UPath, threshold: float | list[float] | dict[str, float] = 0.5, output_path: str | UPath = 'thresholded.zarr', labels: list[str] | None = None)[source]#

Threshold a volume in a zarr container.

Parameters:
  • input_container (str | UPath) – The path to the zarr container containing the data for each label.

  • threshold (float | list[float] | dict[str, float]) – The threshold(s) to apply to each label. If a float, the same threshold is applied to all labels. If a list, the thresholds are applied to the labels in order. If a dict, the thresholds are applied to the labels with the corresponding keys.

  • output_path (UPath) – The path to the zarr container to write the thresholded data to.

  • labels (Optional[list[str]], optional) – The labels to threshold in the zarr container. If None, all labels are thresholded. Default is None.

cellmap_segmentation_challenge.postprocess.process_volume(input_container: str | UPath, process_func: Callable | list[Callable] | dict[str, Callable] | PathLike, output_path: str | UPath, labels: list[str] | None = None)[source]#

Postprocess a volume in a zarr container with an arbitrary function.

Parameters:
  • input_container (str | UPath) – The path to the zarr container containing the data for each label.

  • process_func (Callable | list[Callable] | dict[str, Callable] | os.PathLike) – The function(s) to apply to each label. If a Callable, the same function is applied to all labels. If a list, the functions are applied to the labels in order. If a dict, the functions are applied to the labels with the corresponding keys. If an os.PathLike, the function is loaded from the file at the path (the function should be called process_func in the python file). This last option should take a numpy array as input and return a numpy array as output. This allows for more complex postprocessing functions to be used.

  • output_path (UPath) – The path to the zarr container to write the thresholded data to.

  • labels (Optional[list[str]], optional) – The labels to process in the zarr container. If None, all labels are processed. Default is None.

cellmap_segmentation_challenge.postprocess.rescale_volume(input_container: str | UPath, output_path: str | UPath, output_voxel_size: list[float] | list[list[float]] | dict[str, list[float]], labels: list[str] | None = None)[source]#

Rescale volumes within a zarr container.

Parameters:
  • input_container (str | UPath) – The path to the zarr container containing the data for each label.

  • output_path (UPath) – The path to the zarr container to write the rescaled data to.

  • output_voxel_size (list[float] | list[list[float]] | dict[str, list[float]]) – The voxel size(s) to rescale the labels to. If a list, the same voxel size is applied to all labels. If a list of lists, the voxel sizes are applied to the labels in order. If a dict, the voxel sizes are applied to the labels with the corresponding keys.

  • labels (Optional[list[str]], optional) – The labels to rescale in the zarr container. If None, all labels are rescaled. Default is None

cellmap_segmentation_challenge.postprocess.resize_volume(input_container: str | UPath, output_path: str | UPath, output_shape: list[int] | list[list[int]] | dict[str, list[int]], labels: list[str] | None = None)[source]#

Resize volumes within a zarr container to a given shape.

Parameters:
  • input_container (str | UPath) – The path to the zarr container containing the data for each label.

  • output_path (UPath) – The path to the zarr container to write the resized data to.

  • output_shape (list[int] | list[list[int]] | dict[str, list[int]]) – The shape(s) to resize the labels to. If a list, the same shape is applied to all labels. If a list of lists, the shapes are applied to the labels in order. If a dict, the shapes are applied to the labels with the corresponding keys.

  • labels (Optional[list[str]], optional) – The labels to resize in the zarr container. If None, all labels are resized. Default is None