code: def assd(result, reference, voxelspacing=None, connectivity=1):
      """
      Average symmetric surface distance.
  
      Computes the average symmetric surface distance (ASD) between the binary objects in
      two images.
  
      Parameters
      ----------
      result : array_like
          Input data containing objects. Can be any type but will be converted
          into binary: background where 0, object everywhere else.
      reference : array_like
          Input data containing objects. Can be any type but will be converted
          into binary: background where 0, object everywhere else.
      voxelspacing : float or sequence of floats, optional
          The voxelspacing in a distance unit i.e. spacing of elements
          along each dimension. If a sequence, must be of length equal to
          the input rank; if a single number, this is used for all axes. If
          not specified, a grid spacing of unity is implied.
      connectivity : int
          The neighbourhood/connectivity considered when determining the surface
          of the binary objects. This value is passed to
          `scipy.ndimage.generate_binary_structure` and should usually be :math:`> 1`.
          The decision on the connectivity is important, as it can influence the results
          strongly. If in doubt, leave it as it is.
  
      Returns
      -------
      assd : float
          The average symmetric surface distance between the object(s) in ``result`` and the
          object(s) in ``reference``. The distance unit is the same as for the spacing of
          elements along each dimension, which is usually given in mm.
  
      See also
      --------
      :func:`asd`
      :func:`hd`
  
      Notes
      -----
      This is a real metric, obtained by calling
  
      >>> __surface_distances(result, reference)
  
      and
  
      >>> __surface_distances(reference, result)
  
      and then averaging the two lists. The binary images can therefore be supplied in any order.
      """
      assd = numpy.mean(
          (
              __surface_distances(
                  result, reference, voxelspacing, connectivity
              ),
              __surface_distances(
                  reference, result, voxelspacing, connectivity
              ),
          )
      )
      return assd
  
imports: import numpy
  from scipy.ndimage import _ni_support
  from scipy.ndimage import distance_transform_edt, binary_erosion, generate_binary_structure
  from scipy.ndimage import label, find_objects
  from scipy.stats import pearsonr
label_desc: Use image node_id 12 for calling a global function with example usage: assd(result, reference, voxelspacing, connectivity) and returns: assd