spacr.object
============

.. py:module:: spacr.object




Module Contents
---------------

.. py:function:: generate_cellpose_masks(src, settings, object_type)

.. py:function:: generate_organelle_masks(src, settings, object_type)

   Generate organelle masks using multiple segmentation strategies.

   Supports four morphology modes:
       - 'spots': punctate structures (lipid droplets, vesicles, peroxisomes)
       - 'network': filamentous/reticular structures (mitochondria, microtubules, ER tubules)
       - 'irregular': irregular-shaped organelles (Golgi, ER cisternae, lysosomes)
       - 'ring': hollow / ring-shaped structures (endosomes, autophagosomes, late lysosomes)

   Each mode can use different backends:
       - 'cellpose': deep-learning segmentation via Cellpose
       - 'stardist': star-convex polygon instance segmentation (spots only)
       - 'otsu': global Otsu thresholding with morphological cleanup
       - 'adaptive': local adaptive thresholding
       - 'log': Laplacian of Gaussian blob detection (spots, ring)
       - 'dog': Difference of Gaussians blob detection (spots, ring)
       - 'ridge': ridge/tubeness filter (network only)
       - 'hysteresis': dual-threshold hysteresis (network only)
       - 'unet': user-provided U-Net semantic segmentation (network only)

   :param src: Path to the mask source directory containing .npz stacks.
   :type src: str
   :param settings: Configuration dictionary. Organelle-specific keys (all prefixed with
                    'organelle_') are documented in _set_organelle_defaults.
   :type settings: dict
   :param object_type: Should be 'organelle' (or a custom name used for folder naming).
   :type object_type: str

   :returns: Masks are saved as .npy files in ``{src}/{object_type}_mask_stack/``.
   :rtype: None


