new_contents: import numpy as np
  from numpy import zeros
  from dipy.segment.threshold import upper_bound_by_percent, upper_bound_by_rate
  from numpy.testing import assert_equal, run_module_suite
  
  
  def test_adjustment():
  
      imga = zeros([128, 128])
  
      for y in range(128):
          for x in range(128):
              if y > 10 and y < 115 and x > 10 and x < 115:
                  imga[x, y] = 100
              if y > 39 and y < 88 and x > 39 and x < 88:
                  imga[x, y] = 150
              if y > 59 and y < 69 and x > 59 and x < 69:
                  imga[x, y] = 255
  
      # rate = 0.1
      high_1 = upper_bound_by_rate(imga)
      high_2 = upper_bound_by_percent(imga)
      vol1 = np.interp(imga, xp=[imga.min(), high_1], fp=[0, 255])
      vol2 = np.interp(imga, xp=[imga.min(), high_2], fp=[0, 255])
      count2 = (88 - 40) * (88 - 40)
      count1 = (114 - 10) * (114 - 10)
      count3 = (69 - 60) * (69 - 60)
      count1_test = 0
      count2_test = 0
      count3_test = 0
  
      count2_upper = (88 - 40) * (88 - 40)
      count1_upper = (114 - 10) * (114 - 10)
      count3_upper = (69 - 60) * (69 - 60)
      count1_upper_test = 0
      count2_upper_test = 0
      count3_upper_test = 0
  
      if high_1 < 150:
          count3 = count2
  
      if high_2 < 150:
          count3_upper = count2_upper
  
      for i in range(128):
          for j in range(128):
              if vol1[i][j] == 255:
                  count3_test = count3_test + 1
              if vol1[i][j] > 220:
                  count2_test = count2_test + 1
              if vol1[i][j] > 0:
                  count1_test = count1_test + 1
  
      for i in range(128):
          for j in range(128):
              if vol2[i][j] == 255:
                  count3_upper_test = count3_upper_test + 1
              if vol2[i][j] > 220:
                  count2_upper_test = count2_upper_test + 1
              if vol2[i][j] > 0:
                  count1_upper_test = count1_upper_test + 1
  
      assert_equal(count2, count2_test)
      assert_equal(count1, count1_test)
      assert_equal(count3, count3_test)
  
      assert_equal(count2_upper, count2_upper_test)
      assert_equal(count1_upper, count1_upper_test)
      assert_equal(count3_upper, count3_upper_test)
  
  
  if __name__ == '__main__':
      run_module_suite()
  
subject: add intensity adjustment test