code: def return_dat(self, chan, begsam, endsam):
          
          if begsam < 0:
              begpad = -1 * begsam
              begsam = 0
          else:
              begpad = 0
  
          if endsam > self.n_smp:
              endpad = endsam - self.n_smp
              endsam = self.n_smp
          else:
              endpad = 0
  
          first_sam = DATA_PRECISION * self.n_chan * begsam
          toread_sam = DATA_PRECISION * self.n_chan * (endsam - begsam)
  
          with open(join(self.filename, EEG_FILE), 'rb') as f:
              f.seek(first_sam)
              x = f.read(toread_sam)
  
          dat = _read_dat(x)
          dat = reshape(dat, (self.n_chan, -1), 'F')
          dat = self.convertion(dat[chan, :])
          dat = pad(dat, ((0, 0), (begpad, endpad)),
                    mode='constant', constant_values=NaN)
  
          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