code: def crop_zeros(img_array):
      if len(img_array.shape) == 4:
          img_array = np.amax(img_array, axis=3)
      assert len(img_array.shape) == 3
      x_dim, y_dim, z_dim = tuple(img_array.shape)
      x_zeros, y_zeros, z_zeros = np.where(img_array == 0.0)
      # x-plans that are not uniformly equal to zeros
      (x_to_keep,) = np.where(np.bincount(x_zeros) < y_dim * z_dim)
      x_min = min(x_to_keep)
      x_max = max(x_to_keep) + 1
      (y_to_keep,) = np.where(np.bincount(y_zeros) < x_dim * z_dim)
      y_min = min(y_to_keep)
      y_max = max(y_to_keep) + 1
      (z_to_keep,) = np.where(np.bincount(z_zeros) < x_dim * y_dim)
      z_min = min(z_to_keep)
      z_max = max(z_to_keep) + 1
      return x_min, x_max, y_min, y_max, z_min, z_max
  
file_path: NiftyNet/demos/BRATS17/rename_crop_BRATS.py
imports: import os
  import SimpleITK
  import nibabel
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: crop_zeros(img_array) and returns: x_min,  x_max,  y_min,  y_max,  z_min,  z_max