code: def replace_inside(outer_cmap, inner_cmap, vmin, vmax):
      """Replace a colormap by another inside a pair of values."""
      assert vmin < vmax, ValueError("vmin must be smaller than vmax")
      assert vmin >= 0, ValueError(
          f"vmin must be larger than 0, {vmin} was passed."
      )
      assert vmax <= 1, ValueError(
          f"vmax must be smaller than 1, {vmax} was passed."
      )
      outer_cdict = outer_cmap._segmentdata.copy()
      inner_cdict = inner_cmap._segmentdata.copy()
  
      cdict = {}
      for this_cdict, cmap in [
          (outer_cdict, outer_cmap),
          (inner_cdict, inner_cmap),
      ]:
          if hasattr(this_cdict["red"], "__call__"):
              ps = _np.linspace(0, 1, 25)
              colors = cmap(ps)
              this_cdict["red"] = []
              this_cdict["green"] = []
              this_cdict["blue"] = []
              for p, (r, g, b, a) in zip(ps, colors):
                  this_cdict["red"].append((p, r, r))
                  this_cdict["green"].append((p, g, g))
                  this_cdict["blue"].append((p, b, b))
  
      for c_index, color in enumerate(("red", "green", "blue")):
          color_lst = []
  
          for value, c1, c2 in outer_cdict[color]:
              if value >= vmin:
                  break
              color_lst.append((value, c1, c2))
  
          color_lst.append(
              (
                  vmin,
                  outer_cmap(vmin)[c_index],
                  inner_cmap(vmin)[c_index],
              )
          )
  
          for value, c1, c2 in inner_cdict[color]:
              if value <= vmin:
                  continue
              if value >= vmax:
                  break
              color_lst.append((value, c1, c2))
  
          color_lst.append(
              (
                  vmax,
                  inner_cmap(vmax)[c_index],
                  outer_cmap(vmax)[c_index],
              )
          )
  
          for value, c1, c2 in outer_cdict[color]:
              if value <= vmax:
                  continue
              color_lst.append((value, c1, c2))
  
          cdict[color] = color_lst
  
      return _colors.LinearSegmentedColormap(
          f"{inner_cmap.name}_inside_{outer_cmap.name}",
          cdict,
          _rc["image.lut"],
      )
  
file_path: nipy/nipy/labs/viz_tools/cm.py
imports: import numpy
  from matplotlib import cm
  from matplotlib import colors
  from matplotlib import rcParams
label_desc: Use image node_id 6 for calling a global function with example usage: replace_inside(outer_cmap, inner_cmap, vmin, vmax) and returns: _colors