class_docstr: Compute confidence map from an ultrasound image.
  This transform uses the method introduced by Karamalis et al. in https://doi.org/10.1016/j.media.2012.07.005.
  It generates a confidence map by setting source and sink points in the image and computing the probability
  for random walks to reach the source for each pixel.
  
  Args:
      alpha (float, optional): Alpha parameter. Defaults to 2.0.
      beta (float, optional): Beta parameter. Defaults to 90.0.
      gamma (float, optional): Gamma parameter. Defaults to 0.05.
      mode (str, optional): 'RF' or 'B' mode data. Defaults to 'B'.
      sink_mode (str, optional): Sink mode. Defaults to 'all'. If 'mask' is selected, a mask must be when calling
          the transform. Can be 'all', 'mid', 'min', or 'mask'.
docstr: Compute confidence map
  
  Args:
      img (NDArray): Processed image.
      seeds (NDArray): Seeds for the random walks framework. These are indices of the source and sink nodes.
      labels (NDArray): Labels for the random walks framework. These represent the classes or groups of the seeds.
      beta: Random walks parameter that defines the sensitivity of the Gaussian weighting function.
      gamma: Horizontal penalty factor that adjusts the weight of horizontal edges in the Laplacian.
  
  Returns:
      map: Confidence map which shows the probability of each pixel belonging to the source or sink group.
docstr_tok: ["Compute","confidence","map","Args",":","img","(","NDArray",")",":","Processed","image",".","seeds","(","NDArray",")",":","Seeds","for","the","random","walks","framework",".","These","are","indices","of","the","source","and","sink","nodes",".","labels","(","NDArray",")",":","Labels","for","the","random","walks","framework",".","These","represent","the","classes","or","groups","of","the","seeds",".","beta",":","Random","walks","parameter","that","defines","the","sensitivity","of","the","Gaussian","weighting","function",".","gamma",":","Horizontal","penalty","factor","that","adjusts","the","weight","of","horizontal","edges","in","the","Laplacian",".","Returns",":","map",":","Confidence","map","which","shows","the","probability","of","each","pixel","belonging","to","the","source","or","sink","group","."]
code: def confidence_estimation(self, img, seeds, labels, beta, gamma):
      """Compute confidence map
  
      Args:
          img (NDArray): Processed image.
          seeds (NDArray): Seeds for the random walks framework. These are indices of the source and sink nodes.
          labels (NDArray): Labels for the random walks framework. These represent the classes or groups of the seeds.
          beta: Random walks parameter that defines the sensitivity of the Gaussian weighting function.
          gamma: Horizontal penalty factor that adjusts the weight of horizontal edges in the Laplacian.
  
      Returns:
          map: Confidence map which shows the probability of each pixel belonging to the source or sink group.
      """
  
      # Index matrix with boundary padding
      idx = (
          np.arange(1, img.shape[0] * img.shape[1] + 1)
          .reshape(img.shape[1], img.shape[0])
          .T
      )
      pad = 1
  
      padded_idx = np.pad(
          idx, (pad, pad), "constant", constant_values=(0, 0)
      )
      padded_img = np.pad(
          img, (pad, pad), "constant", constant_values=(0, 0)
      )
  
      # Laplacian
      lap = self.confidence_laplacian(
          padded_idx, padded_img, beta, gamma
      )
  
      # Select marked columns from Laplacian to create L_M and B^T
      b = lap[:, seeds]
  
      # Select marked nodes to create B^T
      n = np.sum(padded_idx > 0).item()
      i_u = np.setdiff1d(
          np.arange(n), seeds.astype(int)
      )  # Index of unmarked nodes
      b = b[i_u, :]
  
      # Remove marked nodes from Laplacian by deleting rows and cols
      keep_indices = np.setdiff1d(np.arange(lap.shape[0]), seeds)
      lap = csc_matrix(lap[keep_indices, :][:, keep_indices])
  
      # Define M matrix
      m = np.zeros((seeds.shape[0], 1), dtype="float64")
      m[:, 0] = labels == 1
  
      # Right-handside (-B^T*M)
      rhs = -b @ m
  
      # Solve linear system
      x = self._solve_linear_system(lap, rhs)
  
      # Prepare output
      probabilities = np.zeros((n,), dtype="float64")
      # Probabilities for unmarked nodes
      probabilities[i_u] = x
      # Max probability for marked node
      probabilities[seeds[labels == 1].astype(int)] = 1.0
  
      # Final reshape with same size as input image (no padding)
      probabilities = probabilities.reshape(
          (img.shape[1], img.shape[0])
      ).T
  
      return probabilities
  
file_path: MONAI/monai/data/ultrasound_confidence_map.py
imports: from __future__ import annotations
  import numpy
  from numpy.typing import NDArray
  from monai.utils import min_version, optional_import
label_desc: Use image node_id 8 for calling the UltrasoundConfidenceMap obj's underlying member method code with example usage: obj.confidence_estimation(img, seeds, labels, beta, gamma) and returns: probabilities