code: def applyslicer(array, slicer, pmask, cval = 0):
          r
          l = len(slicer)
          patch = numpy.zeros(list(pmask.shape[:l]) + list(array.shape[l:]), array.dtype)
          if not 0 == cval: patch.fill(cval)
          sliced = array[slicer]
          patch[pmask] = sliced.reshape([numpy.prod(sliced.shape[:l])] + list(sliced.shape[l:]))
          return patch
docs: r"""
          Apply a slicer returned by the iterator to a new array of the same
          dimensionality as the one used to initialize the iterator.
          
          Notes
          -----
          If ``array`` has more dimensions than ``slicer`` and ``pmask``, the first ones
          are sliced.
          
          Parameters
          ----------
          array : array_like
              A n-dimensional array.
          slicer : list
              List if `slice()` instances as returned by `next()`.
          pmask : narray
              The array mask as returned by `next()`.
          cval : number
              Value to fill undefined positions.            
              
          Experiments
          -----------
          >>> import numpy
          >>> from medpy.iterators import CentredPatchIterator
          >>> arr = numpy.arange(0, 25).reshape((5,5))
          >>> for patch, pmask, _, slicer in CentredPatchIterator(arr, 3):
          >>>     new_patch = CentredPatchIterator.applyslicer(arr, slicer, pmask)
          >>>     print numpy.all(new_patch == patch)
          True
          ...