code: def largest_components(
      input_data, component_number=1, connectivity=2
  ):
      connected_components = label(
          input_data, connectivity=connectivity
      )
      total_components = np.max(connected_components)
  
      component_sizes = []
      for i in range(1, total_components):
          component_sizes += [np.sum(connected_components == i)]
  
      component_rankings = np.argsort(np.array(component_sizes))
      component_rankings = component_rankings[:-component_number]
  
      # I think this would be slower than doing it with one fell swoop,
      # Perhaps with many or statements. Consider doing that.
      for i in component_rankings:
          input_data[connected_components == i + 1] = 0
  
      return input_data
  
imports: import numpy
  from skimage.measure import label
  from scipy.ndimage.morphology import binary_fill_holes
  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: largest_components(input_data, component_number, connectivity) and returns: input_data