code: def find_valley_range(vector, min_distance=4):
      """
      Internal finder peaks and valley ranges.
      Returns UNSORTED indices of maxima in input vector.
      Returns range of valleys before and after maximum
      """
  
      # http://users.monash.edu.au/~dengs/resource/papers/icme08.pdf
      # find min and max with mode = wrap
      mode = "wrap"
      minima = local_minima(vector, min_distance, mode)
      maxima = local_maxima(vector, min_distance, mode)
  
      if len(maxima) > len(minima):
          if vector[maxima[0]] >= vector[maxima[-1]]:
              maxima = maxima[1:]
          else:
              maxima = maxima[:-1]
  
      if len(maxima) == len(minima):
          valley_range = numpy.asarray(
              [
                  minima[ii + 1] - minima[ii]
                  for ii in range(len(minima) - 1)
              ]
              + [len(vector) - minima[-1] + minima[0]]
          )
          if minima[0] < maxima[0]:
              minima = numpy.asarray(list(minima) + [minima[0]])
          else:
              minima = numpy.asarray(list(minima) + [minima[-1]])
      else:
          valley_range = numpy.asarray(
              [minima[ii + 1] - minima[ii] for ii in range(len(maxima))]
          )
  
      return maxima, minima, valley_range
  
file_path: medpy/medpy/features/texture.py
imports: import numpy
  from scipy.ndimage import uniform_filter, sobel, maximum_filter, minimum_filter, gaussian_filter
  from scipy import stats
  from math import factorial
label_desc: Use image node_id 6 for calling a global function with example usage: find_valley_range(vector, min_distance) and returns: maxima,  minima,  valley_range