save_detection_arrays_to_qupath_json¶

save_detection_arrays_to_qupath_json(detection_arrays, scale_factor=(1.0, 1.0), class_dict=None, save_path=None)[source]¶

Write nucleus detection arrays to QuPath JSON.

Produces a FeatureCollection where each detection is represented as a Point geometry with classification metadata and probability score.

Parameters:
  • detection_arrays (dict[str, da.Array]) – A dictionary containing the detection fields: - "x": dask array of x coordinates (np.uint32). - "y": dask array of y coordinates (np.uint32). - "classes": dask array of class IDs (np.uint32). - "probabilities": dask array of detection scores (np.float32).

  • scale_factor (tuple[float, float], optional) – Multiplicative factors applied to the x and y coordinates before saving. The scaled coordinates are rounded to integer pixel locations. Defaults to (1.0, 1.0).

  • class_dict (dict or None) – Optional mapping of class IDs to class names or remapped IDs. If None, an identity mapping is used based on the detected class IDs.

  • save_path (Path or None) – Destination path for saving the QuPath-compatible .json file. If None, an in-memory JSON-compatible representation of all detections is returned instead of writing to disk.

Returns:

  • If save_path is provided: the path to the saved .json file.

  • If save_path is None: an in-memory dict representing QuPath JSON containing all detections.

Return type:

Path or QuPath