code: def return_dat(self, chan, begsam, endsam):
          
          memmap_file = Path(self.filename).with_suffix('.dat')
          if not memmap_file.exists():
              raise FileNotFoundError('Could not find ' + str(memmap_file))
  
          data = memmap(str(memmap_file), self.dtype, mode='c',
                        shape=self.memshape, order='F')
  
          n_smp = self.memshape[1]
          dat = data[chan, max((begsam, 0)):min((endsam, n_smp))].astype(float64)
  
          if begsam < 0:
  
              pad = empty((dat.shape[0], 0 - begsam))
              pad.fill(NaN)
              dat = c_[pad, dat]
  
          if endsam >= n_smp:
  
              pad = empty((dat.shape[0], endsam - n_smp))
              pad.fill(NaN)
              dat = c_[dat, pad]
  
          return dat
docs: Return the data as 2D numpy.ndarray.
  
          Parameters
          ----------
          chan : int or list
              index (indices) of the channels to read
          begsam : int
              index of the first sample
          endsam : int
              index of the last sample
  
          Returns
          -------
          numpy.ndarray
              A 2d matrix, with dimension chan X samples. To save memory, the
              data are memory-mapped, and you cannot change the values on disk.
  
          Raises
          ------
          FileNotFoundError
              if .dat file is not in the same directory, with the same name.
  
          Notes
          -----
          When asking for an interval outside the data boundaries, it returns NaN
          for those values. It then converts the memmap to a normal numpy array,
          I think, and so it reads the data into memory. However, I'm not 100%
          sure that this is what happens.