code: def dice_cost_function(input_data, ground_truth):
      """Calculate the dice coefficient.
  
      Parameters
      ----------
      input_data, ground_truth : NumPy
          Arrays to be compared.
  
      Returns
      -------
      float
          Dice coefficient.
  
      """
  
      im1 = np.asarray(input_data).astype(np.bool)
      im2 = np.asarray(ground_truth).astype(np.bool)
  
      if im1.shape != im2.shape:
          raise ValueError(
              "Shape mismatch: Predicted data and ground truth must have the same shape."
          )
  
      im_sum = im1.sum() + im2.sum()
      if im_sum == 0:
          return 0
  
      # Compute Dice coefficient
      intersection = np.logical_and(im1, im2)
  
      return 2.0 * intersection.sum() / im_sum
  
file_path: DeepNeuro/deepneuro/postprocessing/statistics.py
imports: import csv
  import numpy
  from skimage.measure import label
  from deepneuro.postprocessing.postprocessor import Postprocessor
  from deepneuro.utilities.util import add_parameter
label_desc: Use image node_id 1 for calling a global function with example usage: dice_cost_function(input_data, ground_truth) and returns: unknown, int