code: def draw_lattice_2d(nrows, ncols, delta):
      r"""Create a regular lattice of nrows x ncols squares.
  
      Creates an image (2D array) of a regular lattice of nrows x ncols squares.
      The size of each square is delta x delta pixels (not counting the
      separation lines). The lines are one pixel width.
  
      Parameters
      ----------
      nrows : int
          the number of squares to be drawn vertically
      ncols : int
          the number of squares to be drawn horizontally
      delta : int
          the size of each square of the grid. Each square is delta x delta
          pixels
  
      Returns
      -------
      lattice : array, shape (R, C)
          the image (2D array) of the segular lattice. The shape (R, C) of the
          array is given by
          R = 1 + (delta + 1) * nrows
          C = 1 + (delta + 1) * ncols
      """
      lattice = np.ndarray(
          (1 + (delta + 1) * nrows, 1 + (delta + 1) * ncols),
          dtype=np.float64,
      )
  
      # Fill the lattice with "white"
      lattice[...] = 127
  
      # Draw the horizontal lines in "black"
      for i in range(nrows + 1):
          lattice[i * (delta + 1), :] = 0
  
      # Draw the vertical lines in "black"
      for j in range(ncols + 1):
          lattice[:, j * (delta + 1)] = 0
  
      return lattice
  
file_path: dipy/dipy/viz/regtools.py
imports: import numpy
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 4 for calling a global function with example usage: draw_lattice_2d(nrows, ncols, delta) and returns: lattice