code: def calc_max_3D_diameter(
      input_data,
      pixdim=None,
      affine=None,
      mask_value=0,
      axis=2,
      calc_multiple=False,
  ):
      """Combine repeated code with 2D max diameter?"""
  
      input_data, input_affine = read_image_files(
          input_data, return_affine=True
      )
  
      pixdim = _get_pixdim(pixdim, affine, input_affine)
  
      input_data = input_data[..., -1]
  
      connected_components = label(input_data, connectivity=2)
      component_labels = np.unique(connected_components)
  
      max_3ds = []
  
      major_diameter = None
      for label_idx in component_labels:
          component = connected_components.astype(int)
          component[connected_components != label_idx] = 0
  
          major_diameter = [None]
  
          if np.sum(component) == 0:
              continue
  
          label_properties = regionprops(component)
          current_major = label_properties[0].major_axis_length
          current_orientation = label_properties[0].orientation
          print(current_orientation)
  
          if major_diameter is None:
              major_diameter = current_major
          elif current_major > major_diameter:
              major_diameter = current_major
  
          if major_diameter is not None:
              max_3ds += [major_diameter * pixdim[0] * pixdim[1]]
  
      if calc_multiple:
          return max_3ds
      else:
          return max(max_3ds)
  
file_path: DeepNeuro/deepneuro/outputs/measure.py
imports: import numpy
  from skimage.morphology import label
  from skimage.measure import regionprops, mesh_surface_area, marching_cubes
  from scipy import signal
  from deepneuro.utilities.conversion import read_image_files
label_desc: Use image node_id 3 for calling a global function with example usage: calc_max_3D_diameter(input_data, pixdim, affine, mask_value, axis, calc_multiple) and returns: max_3ds, max