parameters: (channel1, channel2, channel3, channel1color, channel2color,
                       channel3Color, value_max, saturation_max, common_range,
                       common_min, common_max)
return_statement: return red, green, blue
docstring: Colors voxels in 3 color dimensions but not necessarily canonical red, green, and blue
          Parameters
          ----------
          channel1 : ndarray or Volume
              voxel values for first channel
          channel2 : ndarray or Volume
              voxel values for second channel
          channel3 : ndarray or Volume
              voxel values for third channel
          channel1color : tuple<uint8, uint8, uint8>
              color in RGB for first channel
          channel2color : tuple<uint8, uint8, uint8>
              color in RGB for second channel
          channel3Color : tuple<uint8, uint8, uint8>
              color in RGB for third channel
          value_max : float, optional
              Maximum HSV value for voxel colors. If not given, will be the value of
              the average of the three channel colors.
          saturation_max : float [0, 1]
              Maximum HSV saturation for voxel colors.
          common_range : bool
              Use the same vmin and vmax for all three color channels?
          common_min : float, optional
              Predetermined shared vmin. Does nothing if shared_range == False. If not given,
              will be the 1st percentile of all values across all three channels.
          common_max : float, optional
              Predetermined shared vmax. Does nothing if shared_range == False. If not given,
              will be the 99th percentile of all values across all three channels
  
          Returns
          -------
          red : ndarray of channel1.shape
              uint8 array of red values
          green : ndarray of data2.shape
              uint8 array of green values
          blue : ndarray of data3.shape
              uint8 array of blue values
docstring_summary: Colors voxels in 3 color dimensions but not necessarily canonical red, green, and blue
          Parameters
          ----------
          channel1 : ndarray or Volume
              voxel values for first channel
          channel2 : ndarray or Volume
              voxel values for second channel
          channel3 : ndarray or Volume
              voxel values for third channel
          channel1color : tuple<uint8, uint8, uint8>
              color in RGB for first channel
          channel2color : tuple<uint8, uint8, uint8>
              color in RGB for second channel
          channel3Color : tuple<uint8, uint8, uint8>
              color in RGB for third channel
          value_max : float, optional
              Maximum HSV value for voxel colors. If not given, will be the value of
              the average of the three channel colors.
          saturation_max : float [0, 1]
              Maximum HSV saturation for voxel colors.
          common_range : bool
              Use the same vmin and vmax for all three color channels?
          common_min : float, optional
              Predetermined shared vmin. Does nothing if shared_range == False. If not given,
              will be the 1st percentile of all values across all three channels.
          common_max : float, optional
              Predetermined shared vmax. Does nothing if shared_range == False. If not given,
              will be the 99th percentile of all values across all three channels
docstring_tokens: Colors voxels in 3 color dimensions but not necessarily canonical red green and blue Parameters ---------- channel1 : ndarray or Volume voxel values for first channel channel2 : ndarray or Volume voxel values for second channel channel3 : ndarray or Volume voxel values for third channel channel1color : tuple<uint8 uint8 uint8 > color in RGB for first channel channel2color : tuple<uint8 uint8 uint8 > color in RGB for second channel channel3Color : tuple<uint8 uint8 uint8 > color in RGB for third channel value_max : float optional Maximum HSV value for voxel colors . If not given will be the value of the average of the three channel colors . saturation_max : float [ 0 1 ] Maximum HSV saturation for voxel colors . common_range : bool Use the same vmin and vmax for all three color channels? common_min : float optional Predetermined shared vmin . Does nothing if shared_range == False . If not given will be the 1st percentile of all values across all three channels . common_max : float optional Predetermined shared vmax . Does nothing if shared_range == False . If not given will be the 99th percentile of all values across all three channels
function: def color_voxels(channel1, channel2, channel3, channel1color, channel2color,
                       channel3Color, value_max, saturation_max, common_range,
                       common_min, common_max):
          """
          Colors voxels in 3 color dimensions but not necessarily canonical red, green, and blue
          Parameters
          ----------
          channel1 : ndarray or Volume
              voxel values for first channel
          channel2 : ndarray or Volume
              voxel values for second channel
          channel3 : ndarray or Volume
              voxel values for third channel
          channel1color : tuple<uint8, uint8, uint8>
              color in RGB for first channel
          channel2color : tuple<uint8, uint8, uint8>
              color in RGB for second channel
          channel3Color : tuple<uint8, uint8, uint8>
              color in RGB for third channel
          value_max : float, optional
              Maximum HSV value for voxel colors. If not given, will be the value of
              the average of the three channel colors.
          saturation_max : float [0, 1]
              Maximum HSV saturation for voxel colors.
          common_range : bool
              Use the same vmin and vmax for all three color channels?
          common_min : float, optional
              Predetermined shared vmin. Does nothing if shared_range == False. If not given,
              will be the 1st percentile of all values across all three channels.
          common_max : float, optional
              Predetermined shared vmax. Does nothing if shared_range == False. If not given,
              will be the 99th percentile of all values across all three channels
  
          Returns
          -------
          red : ndarray of channel1.shape
              uint8 array of red values
          green : ndarray of data2.shape
              uint8 array of green values
          blue : ndarray of data3.shape
              uint8 array of blue values
  
          """
          # normalize each channel to [0, 1]
          data1 = np.nan_to_num(channel1.data if isinstance(channel1, VolumeData) else channel1).astype(np.float)
          data2 = np.nan_to_num(channel2.data if isinstance(channel2, VolumeData) else channel2).astype(np.float)
          data3 = np.nan_to_num(channel3.data if isinstance(channel3, VolumeData) else channel3).astype(np.float)
  
          if (data1.shape != data2.shape) or (data2.shape != data3.shape):
              raise ValueError('Volumes are of different shapes')
  
          if common_range:
              if common_min is None:
                  if common_max is None:
                      common_min = np.percentile(np.hstack((data1, data2, data3)), 1)
                  else:
                      common_min = 0
              if common_max is None:
                  common_max = np.percentile(np.hstack((data1, data2, data3)), 99)
              data1 -= common_min
              data2 -= common_min
              data3 -= common_min
              data1 /= (common_max - common_min)
              data2 /= (common_max - common_min)
              data3 /= (common_max - common_min)
          else:
              channelMin = np.percentile(data1, 1)
              channelMax = np.percentile(data1, 99)
              data1 -= channelMin
              data1 /= (channelMax - channelMin)
              channelMin = np.percentile(data2, 1)
              channelMax = np.percentile(data2, 99)
              data2 -= channelMin
              data2 /= (channelMax - channelMin)
              channelMin = np.percentile(data3, 1)
              channelMax = np.percentile(data3, 99)
              data3 -= channelMin
              data3 /= (channelMax - channelMin)
          data1 = np.clip(data1, 0, 1)
          data2 = np.clip(data2, 0, 1)
          data3 = np.clip(data3, 0, 1)
  
          channel1color = np.array(channel1color)
          channel2color = np.array(channel2color)
          channel3Color = np.array(channel3Color)
  
          averageColor = (channel1color + channel2color + channel3Color) / 3
  
          if value_max is None:
              _, _, value = RGB2HSV(averageColor)
              value_max = value
  
          red = np.zeros_like(data1, np.uint8)
          green = np.zeros_like(data1, np.uint8)
          blue = np.zeros_like(data1, np.uint8)
          for i in range(data1.size):
              this_color = data1.flat[i] * channel1color + data2.flat[i] * channel2color + data3.flat[i] * channel3Color
              this_color /= 3.0
              if (value_max != 1.0) or (saturation_max != 1.0):
                  hue, saturation, value = RGB2HSV(this_color)
                  saturation /= saturation_max
                  value /= value_max
                  if saturation > 1:
                      saturation = 1.0
                  if value > 1:
                      value = 1.0
                  this_color = HSV2RGB([hue, saturation, value])
              red.flat[i] = this_color[0]
              green.flat[i] = this_color[1]
              blue.flat[i] = this_color[2]
  
          return red, green, blue
function_tokens: def color_voxels ( channel1 , channel2 , channel3 , channel1color , channel2color , channel3Color , value_max , saturation_max , common_range , common_min , common_max ) : # normalize each channel to [0, 1] data1 = np . nan_to_num ( channel1 . data if isinstance ( channel1 , VolumeData ) else channel1 ) . astype ( np . float ) data2 = np . nan_to_num ( channel2 . data if isinstance ( channel2 , VolumeData ) else channel2 ) . astype ( np . float ) data3 = np . nan_to_num ( channel3 . data if isinstance ( channel3 , VolumeData ) else channel3 ) . astype ( np . float ) if ( data1 . shape != data2 . shape ) or ( data2 . shape != data3 . shape ) : raise ValueError ( 'Volumes are of different shapes' ) if common_range : if common_min is None : if common_max is None : common_min = np . percentile ( np . hstack ( ( data1 , data2 , data3 ) ) , 1 ) else : common_min = 0 if common_max is None : common_max = np . percentile ( np . hstack ( ( data1 , data2 , data3 ) ) , 99 ) data1 -= common_min data2 -= common_min data3 -= common_min data1 /= ( common_max - common_min ) data2 /= ( common_max - common_min ) data3 /= ( common_max - common_min ) else : channelMin = np . percentile ( data1 , 1 ) channelMax = np . percentile ( data1 , 99 ) data1 -= channelMin data1 /= ( channelMax - channelMin ) channelMin = np . percentile ( data2 , 1 ) channelMax = np . percentile ( data2 , 99 ) data2 -= channelMin data2 /= ( channelMax - channelMin ) channelMin = np . percentile ( data3 , 1 ) channelMax = np . percentile ( data3 , 99 ) data3 -= channelMin data3 /= ( channelMax - channelMin ) data1 = np . clip ( data1 , 0 , 1 ) data2 = np . clip ( data2 , 0 , 1 ) data3 = np . clip ( data3 , 0 , 1 ) channel1color = np . array ( channel1color ) channel2color = np . array ( channel2color ) channel3Color = np . array ( channel3Color ) averageColor = ( channel1color + channel2color + channel3Color ) / 3 if value_max is None : _ , _ , value = RGB2HSV ( averageColor ) value_max = value red = np . zeros_like ( data1 , np . uint8 ) green = np . zeros_like ( data1 , np . uint8 ) blue = np . zeros_like ( data1 , np . uint8 ) for i in range ( data1 . size ) : this_color = data1 . flat [ i ] * channel1color + data2 . flat [ i ] * channel2color + data3 . flat [ i ] * channel3Color this_color /= 3.0 if ( value_max != 1.0 ) or ( saturation_max != 1.0 ) : hue , saturation , value = RGB2HSV ( this_color ) saturation /= saturation_max value /= value_max if saturation > 1 : saturation = 1.0 if value > 1 : value = 1.0 this_color = HSV2RGB ( [ hue , saturation , value ] ) red . flat [ i ] = this_color [ 0 ] green . flat [ i ] = this_color [ 1 ] blue . flat [ i ] = this_color [ 2 ] return red , green , blue